git_workflow.md
1 # Git Workflow 2 3 Git best practices and common commands for ECHO development. 4 5 ## Before Committing 6 7 ```bash 8 # 1. Run tests 9 cd apps/echo_shared && mix test 10 cd apps/ceo && mix test 11 12 # 2. Check git status 13 git status 14 15 # 3. Review changes 16 git diff 17 18 # 4. Check recent commits (for message style) 19 git log --oneline -5 20 ``` 21 22 ## Creating Commits 23 24 ```bash 25 # Stage changes 26 git add apps/ceo/lib/ceo.ex 27 git add apps/echo_shared/lib/ 28 29 # Or stage all 30 git add -A 31 32 # Commit with message 33 git commit -m "$(cat <<'EOF' 34 feat: Add budget approval tool to CEO agent 35 36 - Implement approve_budget tool with authority limits 37 - Add validation for budget amounts 38 - Integrate with DecisionEngine for escalation 39 - Add tests for autonomous and escalation flows 40 41 🤖 Generated with [Claude Code](https://claude.com/claude-code) 42 43 Co-Authored-By: Claude <noreply@anthropic.com> 44 EOF 45 )" 46 ``` 47 48 ## Commit Message Format 49 50 ``` 51 <type>: <subject> 52 53 <body> 54 55 🤖 Generated with [Claude Code](https://claude.com/claude-code) 56 57 Co-Authored-By: Claude <noreply@anthropic.com> 58 ``` 59 60 **Types:** 61 - `feat:` - New feature 62 - `fix:` - Bug fix 63 - `refactor:` - Code refactoring 64 - `docs:` - Documentation changes 65 - `test:` - Adding or updating tests 66 - `chore:` - Maintenance tasks 67 68 ## Creating Pull Requests 69 70 ```bash 71 # 1. Create and switch to new branch 72 git checkout -b feature/budget-approval 73 74 # 2. Make changes and commit 75 # ... development ... 76 git add -A 77 git commit -m "..." 78 79 # 3. Push to remote 80 git push -u origin feature/budget-approval 81 82 # 4. Create PR using gh CLI 83 gh pr create --title "feat: Add budget approval tool" --body "$(cat <<'EOF' 84 ## Summary 85 - Implement budget approval tool for CEO agent 86 - Add authority limits ($1M autonomous, >$1M escalate) 87 - Include comprehensive test coverage 88 89 ## Test plan 90 - [x] Unit tests for approve_budget tool 91 - [x] Integration tests for decision flow 92 - [x] Manual testing in autonomous mode 93 94 🤖 Generated with [Claude Code](https://claude.com/claude-code) 95 EOF 96 )" 97 ``` 98 99 ## Common Commands 100 101 ```bash 102 # Undo last commit (keep changes) 103 git reset --soft HEAD~1 104 105 # Undo changes to file 106 git checkout -- file.ex 107 108 # Stash changes 109 git stash 110 git stash pop 111 112 # View commit history 113 git log --oneline --graph --all 114 115 # Show changes in commit 116 git show <commit-hash> 117 118 # Amend last commit (ONLY if not pushed) 119 git commit --amend 120 121 # Pull latest changes 122 git pull origin main 123 124 # Rebase on main 125 git fetch origin 126 git rebase origin/main 127 ``` 128 129 ## Pre-commit Hooks 130 131 If you get pre-commit hook failures: 132 133 ```bash 134 # Fix formatting 135 mix format 136 137 # Fix Credo warnings 138 mix credo --strict 139 140 # Run tests 141 mix test 142 143 # Retry commit 144 git commit -m "..." 145 ``` 146 147 ## Safety Guidelines 148 149 - ✅ **DO** run tests before committing 150 - ✅ **DO** write descriptive commit messages 151 - ✅ **DO** use conventional commit format 152 - ❌ **DON'T** force push to main/master 153 - ❌ **DON'T** commit secrets or credentials 154 - ❌ **DON'T** commit large binary files 155 - ❌ **DON'T** amend pushed commits (unless alone on branch) 156 157 **Used in:** 158 - CLAUDE.md (Git workflow section) 159 - All agent development 160 - scripts/claude.md