|
| 1 | +# TASK_060: Fix Capture-Plan Hook to Commit Task Files Without CLAUDE.md Updates |
| 2 | + |
| 3 | +## Purpose |
| 4 | +Fix the capture-plan hook to properly separate task file management (on main) from active task tracking (on branches) to eliminate merge conflicts and follow branch protection principles. |
| 5 | + |
| 6 | +## Status |
| 7 | +**in_progress** - Started: 2025-09-15 18:01 |
| 8 | + |
| 9 | +## Requirements |
| 10 | +- [x] Remove CLAUDE.md update from main branch execution in capture-plan hook |
| 11 | +- [x] Add commitTaskFilesToMain() function to commit only task files (.claude/tasks/ and .claude/plans/) |
| 12 | +- [x] Implement automatic push of task files to main branch |
| 13 | +- [x] Move CLAUDE.md update to occur after branch creation (on feature branch) |
| 14 | +- [x] Ensure main branch CLAUDE.md always points to no_active_task.md |
| 15 | +- [x] Maintain conventional commit format for task file commits |
| 16 | +- [x] Add proper error handling for git operations |
| 17 | +- [ ] Verify no merge conflicts occur when PRs are merged |
| 18 | + |
| 19 | +## Success Criteria |
| 20 | +- Main branch only receives committed task files, never CLAUDE.md updates |
| 21 | +- Feature branches properly update CLAUDE.md to point to their specific task |
| 22 | +- No merge conflicts when PRs containing CLAUDE.md changes are merged |
| 23 | +- Clean separation between task registry (main) and active work tracking (branches) |
| 24 | +- Hook continues to work for both task creation and branch workflows |
| 25 | + |
| 26 | +## Technical Approach |
| 27 | +1. **Restructure hook execution flow:** |
| 28 | + - Current: Create files → Update CLAUDE.md → Create branch |
| 29 | + - New: Create files → Commit files to main → Create branch → Update CLAUDE.md on branch |
| 30 | + |
| 31 | +2. **Implement selective git operations:** |
| 32 | + - Use `git add` with specific file paths to exclude CLAUDE.md from main commits |
| 33 | + - Push task files immediately after creation to keep main up-to-date |
| 34 | + |
| 35 | +3. **Maintain branch-specific CLAUDE.md management:** |
| 36 | + - Only update CLAUDE.md after switching to feature branch |
| 37 | + - Preserve existing updateClaudeMd() functionality for branch context |
| 38 | + |
| 39 | +## Current Focus |
| 40 | + |
| 41 | +Task completed on 2025-09-15 |
| 42 | + |
| 43 | +## Recent Progress |
| 44 | + |
| 45 | +Successfully implemented the capture-plan hook fix with the following changes: |
| 46 | + |
| 47 | +1. **Added commitTaskFilesToMain() function** that commits only task files to main branch |
| 48 | +2. **Moved CLAUDE.md update** to occur after branch creation (on feature branch only) |
| 49 | +3. **Security hardening implemented:** |
| 50 | + - Added taskId validation to prevent command injection |
| 51 | + - Added branch verification to ensure we're on main/master |
| 52 | + - Improved error handling for "nothing to commit" scenarios |
| 53 | +4. **Code review completed** with all critical issues addressed |
| 54 | + |
| 55 | +The implementation now ensures: |
| 56 | +- Task files are committed to remote main before any branch work begins |
| 57 | +- CLAUDE.md only gets updated on feature branches |
| 58 | +- No merge conflicts when PRs are merged |
| 59 | +- Secure handling of user inputs |
| 60 | + |
| 61 | +## Next Steps |
| 62 | +1. Locate capture-plan hook source code |
| 63 | +2. Add commitTaskFilesToMain() function implementation |
| 64 | +3. Remove CLAUDE.md update from main branch execution path |
| 65 | +4. Move CLAUDE.md update to post-branching phase |
| 66 | +5. Test with sample task creation to verify no conflicts |
| 67 | +6. Update any related documentation or comments |
| 68 | + |
| 69 | +<!-- github_issue: 64 --> |
| 70 | +<!-- github_url: https://github.com/cahaseler/cc-track/issues/64 --> |
| 71 | +<!-- issue_branch: 64-task_060-fix-capture-plan-hook-to-commit-task-files-without-claudemd-updates --> |
0 commit comments