|
| 1 | +# Developer Guide |
| 2 | + |
| 3 | +This guide covers development workflows for contributing to claude-session-logger. |
| 4 | + |
| 5 | +## Quick Start for Development |
| 6 | + |
| 7 | +```bash |
| 8 | +# Clone and enter the project |
| 9 | +git clone https://github.com/DazzleML/claude-session-logger.git |
| 10 | +cd claude-session-logger |
| 11 | + |
| 12 | +# Install as local plugin for testing |
| 13 | +claude plugin marketplace add "./" |
| 14 | +claude plugin install session-logger@dazzle-claude-plugins |
| 15 | + |
| 16 | +# Start a new Claude Code session to load the hooks |
| 17 | +``` |
| 18 | + |
| 19 | +## Project Structure |
| 20 | + |
| 21 | +``` |
| 22 | +claude-session-logger/ |
| 23 | +├── .claude-plugin/ # Plugin packaging |
| 24 | +│ ├── plugin.json # Plugin metadata (version here) |
| 25 | +│ └── marketplace.json # Marketplace config (version here too) |
| 26 | +├── hooks/ |
| 27 | +│ ├── hooks.json # Hook registration |
| 28 | +│ └── scripts/ |
| 29 | +│ └── log-command.py # Main logging logic |
| 30 | +├── commands/ # Slash commands (/renameAI, /sessioninfo) |
| 31 | +├── scripts-repo/ # Development scripts |
| 32 | +│ ├── sync-versions.py # Version synchronization |
| 33 | +│ └── update-version.sh # Git version string updater |
| 34 | +├── version.py # Canonical version source (MAJOR.MINOR.PATCH) |
| 35 | +└── docs/ |
| 36 | + ├── installation.md # User installation guide |
| 37 | + └── dev.md # This file |
| 38 | +``` |
| 39 | + |
| 40 | +## Version Management |
| 41 | + |
| 42 | +### Version Locations |
| 43 | + |
| 44 | +Version numbers exist in multiple files. **`version.py` is the source of truth.** |
| 45 | + |
| 46 | +| File | Field | Example | |
| 47 | +|------|-------|---------| |
| 48 | +| `version.py` | `MAJOR`, `MINOR`, `PATCH` | `0`, `1`, `4` | |
| 49 | +| `version.py` | `__version__` | `0.1.4_main_12-20260201-abc123` | |
| 50 | +| `.claude-plugin/plugin.json` | `"version"` | `"0.1.4"` | |
| 51 | +| `.claude-plugin/marketplace.json` | `"version"` (×2) | `"0.1.4"` | |
| 52 | + |
| 53 | +### Sync Versions Script |
| 54 | + |
| 55 | +The `sync-versions.py` script keeps everything in sync: |
| 56 | + |
| 57 | +```bash |
| 58 | +# Check if versions are synchronized |
| 59 | +python scripts-repo/sync-versions.py --check |
| 60 | + |
| 61 | +# Bump patch version (0.1.4 -> 0.1.5) |
| 62 | +python scripts-repo/sync-versions.py --bump patch |
| 63 | + |
| 64 | +# Bump minor version (0.1.4 -> 0.2.0) |
| 65 | +python scripts-repo/sync-versions.py --bump minor |
| 66 | + |
| 67 | +# Bump major version (0.1.4 -> 1.0.0) - requires confirmation |
| 68 | +python scripts-repo/sync-versions.py --bump major |
| 69 | + |
| 70 | +# Demote patch version (0.1.4 -> 0.1.3) |
| 71 | +python scripts-repo/sync-versions.py --demote patch |
| 72 | + |
| 73 | +# Demote minor version (0.1.4 -> 0.0.0) |
| 74 | +python scripts-repo/sync-versions.py --demote minor |
| 75 | + |
| 76 | +# Set version directly (e.g., 0.1.4 -> 0.2.1) |
| 77 | +python scripts-repo/sync-versions.py --set 0.2.1 |
| 78 | + |
| 79 | +# Skip confirmation for major changes (use with caution) |
| 80 | +python scripts-repo/sync-versions.py --bump major --force |
| 81 | +python scripts-repo/sync-versions.py --set 2.0.0 --force |
| 82 | + |
| 83 | +# Preview changes without modifying |
| 84 | +python scripts-repo/sync-versions.py --bump patch --dry-run |
| 85 | + |
| 86 | +# Sync without updating git version string |
| 87 | +python scripts-repo/sync-versions.py --no-git-ver |
| 88 | + |
| 89 | +# Clear plugin cache for development testing (--dev-refresh) |
| 90 | +python scripts-repo/sync-versions.py --dev-refresh # Clears target version |
| 91 | +python scripts-repo/sync-versions.py --set 0.1.4 --dev-refresh # Clears 0.1.4 |
| 92 | +python scripts-repo/sync-versions.py --dev-refresh 0.1.3 0.1.4 # Clears multiple versions |
| 93 | + |
| 94 | +# Preview cache clearing without removing |
| 95 | +python scripts-repo/sync-versions.py --dev-refresh --dry-run |
| 96 | + |
| 97 | +# Skip confirmation prompts (use after reviewing with --dry-run) |
| 98 | +python scripts-repo/sync-versions.py --dev-refresh 0.1.3 0.1.4 --force |
| 99 | +``` |
| 100 | + |
| 101 | +### Version Bumping Workflow |
| 102 | + |
| 103 | +```bash |
| 104 | +# 1. Make your code changes |
| 105 | +# 2. Update CHANGELOG.md with new version section |
| 106 | +# 3. Bump and sync versions |
| 107 | +python scripts-repo/sync-versions.py --bump patch |
| 108 | + |
| 109 | +# 4. Verify everything is in sync |
| 110 | +python scripts-repo/sync-versions.py --check |
| 111 | + |
| 112 | +# 5. Commit all changes |
| 113 | +git add -A |
| 114 | +git commit -m "Release v0.1.5: description of changes" |
| 115 | + |
| 116 | +# 6. Tag the release |
| 117 | +git tag v0.1.5 |
| 118 | +git push origin main --tags |
| 119 | +``` |
| 120 | + |
| 121 | +## Testing Changes |
| 122 | + |
| 123 | +### Local Plugin Testing |
| 124 | + |
| 125 | +After modifying hook scripts, reload them in Claude Code: |
| 126 | + |
| 127 | +```bash |
| 128 | +# Method 1: Update the plugin (preferred) |
| 129 | +claude plugin update session-logger@dazzle-claude-plugins |
| 130 | + |
| 131 | +# Method 2: Full reinstall (if update doesn't work) |
| 132 | +claude plugin marketplace remove dazzle-claude-plugins |
| 133 | +claude plugin marketplace add "./" |
| 134 | +claude plugin install session-logger@dazzle-claude-plugins |
| 135 | + |
| 136 | +# IMPORTANT: Always restart Claude Code session after updating |
| 137 | +# Hooks are loaded at session start |
| 138 | +``` |
| 139 | + |
| 140 | +### Verifying Hook Loading |
| 141 | + |
| 142 | +1. **Check debug log:** |
| 143 | + ```bash |
| 144 | + tail -f ~/.claude/logs/hook-debug.log |
| 145 | + ``` |
| 146 | + |
| 147 | +2. **Use /sessioninfo command** (if installed): |
| 148 | + ``` |
| 149 | + > /sessioninfo |
| 150 | + Session ID: abc123... |
| 151 | + Session Name: my-project |
| 152 | + ``` |
| 153 | + |
| 154 | +3. **Check sesslog output:** |
| 155 | + ```bash |
| 156 | + ls -la ~/.claude/sesslogs/ |
| 157 | + cat ~/.claude/sesslogs/*/.*sesslog*.log |
| 158 | + ``` |
| 159 | + |
| 160 | +### Testing Specific Features |
| 161 | + |
| 162 | +| Feature | How to Test | |
| 163 | +|---------|-------------| |
| 164 | +| Grep logging | Run a Grep tool, check for `pattern \| "glob"` format | |
| 165 | +| Write/Edit preview | Write a file, check for `← "content..."` in log | |
| 166 | +| Agent context | Use Task tool with Explore, check for `Bash\|Explore:` | |
| 167 | +| Auto-naming | Start session in a project folder, check directory name | |
| 168 | + |
| 169 | +## Debugging |
| 170 | + |
| 171 | +### Hook Debug Log |
| 172 | + |
| 173 | +All hook activity is logged to: |
| 174 | +``` |
| 175 | +~/.claude/logs/hook-debug.log |
| 176 | +``` |
| 177 | + |
| 178 | +Add debug statements in `log-command.py`: |
| 179 | +```python |
| 180 | +debug_log(f"My debug message: {variable}") |
| 181 | +``` |
| 182 | + |
| 183 | +### Common Issues |
| 184 | + |
| 185 | +| Issue | Solution | |
| 186 | +|-------|----------| |
| 187 | +| Stale plugin version | Remove marketplace, re-add, reinstall | |
| 188 | +| Hook not firing | Check hooks.json path, restart session | |
| 189 | +| Permission errors | Check file permissions in ~/.claude/ | |
| 190 | +| Unicode errors | Ensure UTF-8 encoding in file operations | |
| 191 | + |
| 192 | +### Session State Files |
| 193 | + |
| 194 | +Session state is persisted in `~/.claude/session-states/`: |
| 195 | +- `{id}.json` - Full session state |
| 196 | +- `{id}.name-cache` - Cached session name |
| 197 | +- `{id}.run` - Current run number |
| 198 | +- `{id}.started` - Session start marker |
| 199 | + |
| 200 | +## Code Style |
| 201 | + |
| 202 | +- Python 3.9+ compatible |
| 203 | +- Use type hints where practical |
| 204 | +- Keep functions focused and documented |
| 205 | +- Use `debug_log()` for troubleshooting output |
| 206 | +- Handle cross-platform paths via `dazzle_filekit` |
| 207 | + |
| 208 | +## Dependencies |
| 209 | + |
| 210 | +- **dazzle-filekit** - Cross-platform path normalization and symlink creation |
| 211 | + ```bash |
| 212 | + pip install dazzle-filekit |
| 213 | + ``` |
| 214 | + |
| 215 | +## Pull Request Checklist |
| 216 | + |
| 217 | +- [ ] Code changes tested locally |
| 218 | +- [ ] Version bumped with `sync-versions.py` |
| 219 | +- [ ] CHANGELOG.md updated |
| 220 | +- [ ] All versions in sync (`--check` passes) |
| 221 | +- [ ] Documentation updated if needed |
| 222 | +- [ ] No sensitive data in commits |
0 commit comments