oden-forge 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/CLAUDE.md +75 -0
- package/.claude/commands/oden/architect.md +204 -0
- package/.claude/commands/oden/checklist.md +199 -0
- package/.claude/commands/oden/daily.md +223 -0
- package/.claude/commands/oden/debug.md +203 -0
- package/.claude/commands/oden/epic.md +224 -0
- package/.claude/commands/oden/git.md +259 -0
- package/.claude/commands/oden/help.md +304 -0
- package/.claude/commands/oden/init-agents.md +268 -0
- package/.claude/commands/oden/init-mcp.md +460 -0
- package/.claude/commands/oden/init.md +495 -0
- package/.claude/commands/oden/mcp.md +585 -0
- package/.claude/commands/oden/prd.md +134 -0
- package/.claude/commands/oden/research.md +207 -0
- package/.claude/commands/oden/review.md +146 -0
- package/.claude/commands/oden/spec.md +539 -0
- package/.claude/commands/oden/sync.md +286 -0
- package/.claude/commands/oden/tasks.md +156 -0
- package/.claude/commands/oden/test.md +200 -0
- package/.claude/commands/oden/work.md +791 -0
- package/.claude/epics/.gitkeep +0 -0
- package/.claude/hooks/README.md +130 -0
- package/.claude/hooks/bash-worktree-fix.sh +189 -0
- package/.claude/prds/.gitkeep +0 -0
- package/.claude/rules/agent-coordination.md +224 -0
- package/.claude/rules/branch-operations.md +147 -0
- package/.claude/rules/datetime.md +118 -0
- package/.claude/rules/frontmatter-operations.md +58 -0
- package/.claude/rules/github-operations.md +89 -0
- package/.claude/rules/oden-methodology.md +111 -0
- package/.claude/rules/path-standards.md +155 -0
- package/.claude/rules/standard-patterns.md +174 -0
- package/.claude/rules/strip-frontmatter.md +82 -0
- package/.claude/rules/worktree-operations.md +136 -0
- package/.claude/scripts/oden/blocked.sh +72 -0
- package/.claude/scripts/oden/epic-list.sh +101 -0
- package/.claude/scripts/oden/epic-show.sh +91 -0
- package/.claude/scripts/oden/epic-status.sh +90 -0
- package/.claude/scripts/oden/help.sh +71 -0
- package/.claude/scripts/oden/in-progress.sh +74 -0
- package/.claude/scripts/oden/init.sh +192 -0
- package/.claude/scripts/oden/next.sh +65 -0
- package/.claude/scripts/oden/prd-list.sh +89 -0
- package/.claude/scripts/oden/prd-status.sh +63 -0
- package/.claude/scripts/oden/search.sh +71 -0
- package/.claude/scripts/oden/standup.sh +89 -0
- package/.claude/scripts/oden/status.sh +42 -0
- package/.claude/scripts/oden/validate.sh +101 -0
- package/.claude/settings.json +27 -0
- package/MIGRATION.md +217 -0
- package/README.md +368 -0
- package/bin/install.js +155 -0
- package/bin/migrate.js +191 -0
- package/bin/oden-forge.js +114 -0
- package/bin/post-install.js +47 -0
- package/bin/pre-uninstall.js +108 -0
- package/install.sh +231 -0
- package/package.json +76 -0
|
File without changes
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Claude Hooks Configuration
|
|
2
|
+
|
|
3
|
+
## Bash Worktree Fix Hook
|
|
4
|
+
|
|
5
|
+
This hook automatically fixes the Bash tool's directory reset issue when working in git worktrees.
|
|
6
|
+
|
|
7
|
+
### Problem
|
|
8
|
+
|
|
9
|
+
The Bash tool resets to the main project directory after every command, making it impossible to work in worktrees without manually prefixing every command with `cd /path/to/worktree &&`.
|
|
10
|
+
|
|
11
|
+
### Solution
|
|
12
|
+
|
|
13
|
+
The pre-tool-use hook automatically detects when you're in a worktree and injects the necessary `cd` prefix to all Bash commands.
|
|
14
|
+
|
|
15
|
+
### How It Works
|
|
16
|
+
|
|
17
|
+
1. **Detection**: Before any Bash command executes, the hook checks if `.git` is a file (worktree) or directory (main repo)
|
|
18
|
+
2. **Injection**: If in a worktree, prepends `cd /absolute/path/to/worktree && ` to the command
|
|
19
|
+
3. **Transparency**: Agents don't need to know about this - it happens automatically
|
|
20
|
+
|
|
21
|
+
### Configuration
|
|
22
|
+
|
|
23
|
+
Add to your `.claude/settings.json`:
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"hooks": {
|
|
29
|
+
"pre-tool-use": {
|
|
30
|
+
"Bash": {
|
|
31
|
+
"enabled": true,
|
|
32
|
+
"script": ".claude/hooks/bash-worktree-fix.sh",
|
|
33
|
+
"apply_to_subagents": true
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Testing
|
|
41
|
+
|
|
42
|
+
To test the hook:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Enable debug mode
|
|
46
|
+
export CLAUDE_HOOK_DEBUG=true
|
|
47
|
+
|
|
48
|
+
# Test in main repo (should pass through)
|
|
49
|
+
.claude/hooks/bash-worktree-fix.sh "ls -la"
|
|
50
|
+
|
|
51
|
+
# Test in worktree (should inject cd)
|
|
52
|
+
cd /path/to/worktree
|
|
53
|
+
.claude/hooks/bash-worktree-fix.sh "npm install"
|
|
54
|
+
# Output: cd "/path/to/worktree" && npm install
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Advanced Features
|
|
58
|
+
|
|
59
|
+
The script handles:
|
|
60
|
+
|
|
61
|
+
- Background processes (`&`)
|
|
62
|
+
- Piped commands (`|`)
|
|
63
|
+
- Environment variable prefixes (`VAR=value command`)
|
|
64
|
+
- Commands that already have `cd`
|
|
65
|
+
- Commands using absolute paths
|
|
66
|
+
- Debug logging with `CLAUDE_HOOK_DEBUG=true`
|
|
67
|
+
|
|
68
|
+
### Edge Cases Handled
|
|
69
|
+
|
|
70
|
+
1. **Double-prefix prevention**: Won't add prefix if command already starts with `cd`
|
|
71
|
+
2. **Absolute paths**: Skips injection for commands using absolute paths
|
|
72
|
+
3. **Special commands**: Skips for `pwd`, `echo`, `export`, etc. that don't need context
|
|
73
|
+
4. **Background processes**: Correctly handles `&` at the end of commands
|
|
74
|
+
5. **Pipe chains**: Injects only at the start of pipe chains
|
|
75
|
+
|
|
76
|
+
### Troubleshooting
|
|
77
|
+
|
|
78
|
+
If the hook isn't working:
|
|
79
|
+
|
|
80
|
+
1. **Verify the hook is executable:**
|
|
81
|
+
```bash
|
|
82
|
+
chmod +x .claude/hooks/bash-worktree-fix.sh
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
2. **Enable debug logging to see what's happening:**
|
|
86
|
+
```bash
|
|
87
|
+
export CLAUDE_HOOK_DEBUG=true
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
3. **Test the hook manually with a sample command:**
|
|
91
|
+
```bash
|
|
92
|
+
cd /path/to/worktree
|
|
93
|
+
.claude/hooks/bash-worktree-fix.sh "npm test"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
4. **Check that your settings.json is valid JSON:**
|
|
97
|
+
```bash
|
|
98
|
+
cat .claude/settings.json | python -m json.tool
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Integration with Claude
|
|
102
|
+
|
|
103
|
+
Once configured, this hook will:
|
|
104
|
+
|
|
105
|
+
- Automatically apply to all Bash tool invocations
|
|
106
|
+
- Work for both main agent and sub-agents
|
|
107
|
+
- Be completely transparent to users
|
|
108
|
+
- Eliminate the need for worktree-specific instructions
|
|
109
|
+
|
|
110
|
+
### Result
|
|
111
|
+
|
|
112
|
+
With this hook in place, agents can work in worktrees naturally:
|
|
113
|
+
|
|
114
|
+
**Agent writes:**
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npm install
|
|
118
|
+
git status
|
|
119
|
+
npm run build
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
**Hook transforms to:**
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
cd /path/to/my/project/epic-feature && npm install
|
|
126
|
+
cd /path/to/my/project/epic-feature && git status
|
|
127
|
+
cd /path/to/my/project/epic-feature && npm run build
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Without the agent knowing or caring about the worktree context!**
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# POSIX-compliant pre-tool-use hook for Bash tool
|
|
3
|
+
# If inside a Git *worktree checkout*, prefix the incoming command with:
|
|
4
|
+
# cd '<worktree_root>' && <original_command>
|
|
5
|
+
# No sh -c. No tokenization. Quoting preserved. Robust worktree detection.
|
|
6
|
+
|
|
7
|
+
DEBUG_MODE="${CLAUDE_HOOK_DEBUG:-false}"
|
|
8
|
+
|
|
9
|
+
debug_log() {
|
|
10
|
+
case "${DEBUG_MODE:-}" in
|
|
11
|
+
true|TRUE|1|yes|YES)
|
|
12
|
+
printf '%s\n' "DEBUG [bash-worktree-fix]: $*" >&2
|
|
13
|
+
;;
|
|
14
|
+
esac
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# Safely single-quote a string for shell usage: foo'bar -> 'foo'"'"'bar'
|
|
18
|
+
shell_squote() {
|
|
19
|
+
printf "%s" "$1" | sed "s/'/'\"'\"'/g"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# Detect if CWD is inside a *linked worktree* and print the worktree root.
|
|
23
|
+
# Returns 0 with path on stdout if yes; 1 otherwise.
|
|
24
|
+
get_worktree_path() {
|
|
25
|
+
check_dir="$(pwd)"
|
|
26
|
+
|
|
27
|
+
if [ ! -d "${check_dir}" ]; then
|
|
28
|
+
debug_log "pwd is not a directory: ${check_dir}"
|
|
29
|
+
return 1
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
while [ "${check_dir}" != "/" ]; do
|
|
33
|
+
if [ -f "${check_dir}/.git" ]; then
|
|
34
|
+
gitdir_content=""
|
|
35
|
+
if [ -r "${check_dir}/.git" ]; then
|
|
36
|
+
IFS= read -r gitdir_content < "${check_dir}/.git" || gitdir_content=""
|
|
37
|
+
# Strip a possible trailing CR (CRLF files)
|
|
38
|
+
gitdir_content=$(printf %s "$gitdir_content" | tr -d '\r')
|
|
39
|
+
else
|
|
40
|
+
debug_log "Unreadable .git file at: ${check_dir}"
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
case "${gitdir_content}" in
|
|
44
|
+
gitdir:*)
|
|
45
|
+
gitdir_path=${gitdir_content#gitdir:}
|
|
46
|
+
# Trim leading spaces (portable)
|
|
47
|
+
while [ "${gitdir_path# }" != "${gitdir_path}" ]; do
|
|
48
|
+
gitdir_path=${gitdir_path# }
|
|
49
|
+
done
|
|
50
|
+
# Normalize to absolute
|
|
51
|
+
case "${gitdir_path}" in
|
|
52
|
+
/*) abs_gitdir="${gitdir_path}" ;;
|
|
53
|
+
*) abs_gitdir="${check_dir}/${gitdir_path}" ;;
|
|
54
|
+
esac
|
|
55
|
+
if [ -d "${abs_gitdir}" ]; then
|
|
56
|
+
case "${abs_gitdir}" in
|
|
57
|
+
*/worktrees/*)
|
|
58
|
+
debug_log "Detected worktree root: ${check_dir} (gitdir: ${abs_gitdir})"
|
|
59
|
+
printf '%s\n' "${check_dir}"
|
|
60
|
+
return 0
|
|
61
|
+
;;
|
|
62
|
+
*)
|
|
63
|
+
debug_log "Non-worktree .git indirection at: ${check_dir}"
|
|
64
|
+
return 1
|
|
65
|
+
;;
|
|
66
|
+
esac
|
|
67
|
+
else
|
|
68
|
+
debug_log "gitdir path does not exist: ${abs_gitdir}"
|
|
69
|
+
return 1
|
|
70
|
+
fi
|
|
71
|
+
;;
|
|
72
|
+
*)
|
|
73
|
+
debug_log "Unknown .git file format at: ${check_dir}"
|
|
74
|
+
return 1
|
|
75
|
+
;;
|
|
76
|
+
esac
|
|
77
|
+
|
|
78
|
+
elif [ -d "${check_dir}/.git" ]; then
|
|
79
|
+
# Regular repo with .git directory — not a linked worktree
|
|
80
|
+
debug_log "Found regular git repo at: ${check_dir}"
|
|
81
|
+
return 1
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
check_dir=$(dirname "${check_dir}")
|
|
85
|
+
done
|
|
86
|
+
|
|
87
|
+
debug_log "No git repository found"
|
|
88
|
+
return 1
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# Decide whether to skip prefixing.
|
|
92
|
+
# Returns 0 => SKIP (pass through as-is)
|
|
93
|
+
# Returns 1 => Prefix with cd
|
|
94
|
+
should_skip_command() {
|
|
95
|
+
cmd=$1
|
|
96
|
+
|
|
97
|
+
# Empty or whitespace-only?
|
|
98
|
+
# If there are no non-space characters, skip.
|
|
99
|
+
if [ -z "${cmd##*[![:space:]]*}" ]; then
|
|
100
|
+
debug_log "Skipping: empty/whitespace-only command"
|
|
101
|
+
return 0
|
|
102
|
+
fi
|
|
103
|
+
|
|
104
|
+
# Starts with optional spaces then 'cd' (with or without args)?
|
|
105
|
+
case "${cmd}" in
|
|
106
|
+
[[:space:]]cd|cd|[[:space:]]cd[[:space:]]*|cd[[:space:]]*)
|
|
107
|
+
debug_log "Skipping: command already begins with cd"
|
|
108
|
+
return 0
|
|
109
|
+
;;
|
|
110
|
+
esac
|
|
111
|
+
|
|
112
|
+
# Builtins / trivial commands that don't require dir context
|
|
113
|
+
case "${cmd}" in
|
|
114
|
+
:|[[:space:]]:|true|[[:space:]]true|false|[[:space:]]false|\
|
|
115
|
+
pwd|[[:space:]]pwd*|\
|
|
116
|
+
echo|[[:space:]]echo*|\
|
|
117
|
+
export|[[:space:]]export*|\
|
|
118
|
+
alias|[[:space:]]alias*|\
|
|
119
|
+
unalias|[[:space:]]unalias*|\
|
|
120
|
+
set|[[:space:]]set*|\
|
|
121
|
+
unset|[[:space:]]unset*|\
|
|
122
|
+
readonly|[[:space:]]readonly*|\
|
|
123
|
+
umask|[[:space:]]umask*|\
|
|
124
|
+
times|[[:space:]]times*|\
|
|
125
|
+
.|[[:space:]].[[:space:]]*)
|
|
126
|
+
debug_log "Skipping: trivial/builtin command"
|
|
127
|
+
return 0
|
|
128
|
+
;;
|
|
129
|
+
esac
|
|
130
|
+
|
|
131
|
+
# Do NOT skip absolute-path commands; many still depend on cwd.
|
|
132
|
+
# We want: cd '<root>' && /abs/cmd ... to preserve semantics.
|
|
133
|
+
|
|
134
|
+
return 1
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
# Inject the worktree prefix without changing semantics.
|
|
138
|
+
# We do NOT wrap in 'sh -c'. We just prepend 'cd ... && '.
|
|
139
|
+
# We preserve trailing '&' if present as the last non-space char.
|
|
140
|
+
inject_prefix() {
|
|
141
|
+
worktree_path=$1
|
|
142
|
+
command=$2
|
|
143
|
+
|
|
144
|
+
qpath=$(shell_squote "${worktree_path}")
|
|
145
|
+
|
|
146
|
+
# Right-trim spaces (portable loop)
|
|
147
|
+
trimmed=${command}
|
|
148
|
+
while [ "${trimmed% }" != "${trimmed}" ]; do
|
|
149
|
+
trimmed=${trimmed% }
|
|
150
|
+
done
|
|
151
|
+
|
|
152
|
+
case "${trimmed}" in
|
|
153
|
+
*"&")
|
|
154
|
+
cmd_without_bg=${trimmed%&}
|
|
155
|
+
while [ "${cmd_without_bg% }" != "${cmd_without_bg}" ]; do
|
|
156
|
+
cmd_without_bg=${cmd_without_bg% }
|
|
157
|
+
done
|
|
158
|
+
printf '%s\n' "cd '${qpath}' && ${cmd_without_bg} &"
|
|
159
|
+
;;
|
|
160
|
+
*)
|
|
161
|
+
printf '%s\n' "cd '${qpath}' && ${command}"
|
|
162
|
+
;;
|
|
163
|
+
esac
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
main() {
|
|
167
|
+
# Capture the raw command line exactly as provided
|
|
168
|
+
original_command="$*"
|
|
169
|
+
|
|
170
|
+
debug_log "Processing command: ${original_command}"
|
|
171
|
+
|
|
172
|
+
# Fast path: if not in a worktree, pass through unchanged
|
|
173
|
+
if ! worktree_path="$(get_worktree_path)"; then
|
|
174
|
+
debug_log "Not in worktree, passing through unchanged"
|
|
175
|
+
printf '%s\n' "${original_command}"
|
|
176
|
+
exit 0
|
|
177
|
+
fi
|
|
178
|
+
|
|
179
|
+
if should_skip_command "${original_command}"; then
|
|
180
|
+
debug_log "Passing through unchanged"
|
|
181
|
+
printf '%s\n' "${original_command}"
|
|
182
|
+
else
|
|
183
|
+
modified_command="$(inject_prefix "${worktree_path}" "${original_command}")"
|
|
184
|
+
debug_log "Modified command: ${modified_command}"
|
|
185
|
+
printf '%s\n' "${modified_command}"
|
|
186
|
+
fi
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
main "$@"
|
|
File without changes
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Agent Coordination
|
|
2
|
+
|
|
3
|
+
Rules for multiple agents working in parallel within the same epic worktree.
|
|
4
|
+
|
|
5
|
+
## Parallel Execution Principles
|
|
6
|
+
|
|
7
|
+
1. **File-level parallelism** - Agents working on different files never conflict
|
|
8
|
+
2. **Explicit coordination** - When same file needed, coordinate explicitly
|
|
9
|
+
3. **Fail fast** - Surface conflicts immediately, don't try to be clever
|
|
10
|
+
4. **Human resolution** - Conflicts are resolved by humans, not agents
|
|
11
|
+
|
|
12
|
+
## Work Stream Assignment
|
|
13
|
+
|
|
14
|
+
Each agent is assigned a work stream from the issue analysis:
|
|
15
|
+
```yaml
|
|
16
|
+
# From {issue}-analysis.md
|
|
17
|
+
Stream A: Database Layer
|
|
18
|
+
Files: src/db/*, migrations/*
|
|
19
|
+
Agent: backend-specialist
|
|
20
|
+
|
|
21
|
+
Stream B: API Layer
|
|
22
|
+
Files: src/api/*
|
|
23
|
+
Agent: api-specialist
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Agents should only modify files in their assigned patterns.
|
|
27
|
+
|
|
28
|
+
## File Access Coordination
|
|
29
|
+
|
|
30
|
+
### Check Before Modify
|
|
31
|
+
Before modifying a shared file:
|
|
32
|
+
```bash
|
|
33
|
+
# Check if file is being modified
|
|
34
|
+
git status {file}
|
|
35
|
+
|
|
36
|
+
# If modified by another agent, wait
|
|
37
|
+
if [[ $(git status --porcelain {file}) ]]; then
|
|
38
|
+
echo "Waiting for {file} to be available..."
|
|
39
|
+
sleep 30
|
|
40
|
+
# Retry
|
|
41
|
+
fi
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Atomic Commits
|
|
45
|
+
Make commits atomic and focused:
|
|
46
|
+
```bash
|
|
47
|
+
# Good - Single purpose commit
|
|
48
|
+
git add src/api/users.ts src/api/users.test.ts
|
|
49
|
+
git commit -m "Issue #1234: Add user CRUD endpoints"
|
|
50
|
+
|
|
51
|
+
# Bad - Mixed concerns
|
|
52
|
+
git add src/api/* src/db/* src/ui/*
|
|
53
|
+
git commit -m "Issue #1234: Multiple changes"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Communication Between Agents
|
|
57
|
+
|
|
58
|
+
### Through Commits
|
|
59
|
+
Agents see each other's work through commits:
|
|
60
|
+
```bash
|
|
61
|
+
# Agent checks what others have done
|
|
62
|
+
git log --oneline -10
|
|
63
|
+
|
|
64
|
+
# Agent pulls latest changes
|
|
65
|
+
git pull origin epic/{name}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Through Progress Files
|
|
69
|
+
Each stream maintains progress:
|
|
70
|
+
```markdown
|
|
71
|
+
# .claude/epics/{epic}/updates/{issue}/stream-A.md
|
|
72
|
+
---
|
|
73
|
+
stream: Database Layer
|
|
74
|
+
agent: backend-specialist
|
|
75
|
+
started: {datetime}
|
|
76
|
+
status: in_progress
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Completed
|
|
80
|
+
- Created user table schema
|
|
81
|
+
- Added migration files
|
|
82
|
+
|
|
83
|
+
## Working On
|
|
84
|
+
- Adding indexes
|
|
85
|
+
|
|
86
|
+
## Blocked
|
|
87
|
+
- None
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Through Analysis Files
|
|
91
|
+
The analysis file is the contract:
|
|
92
|
+
```yaml
|
|
93
|
+
# Agents read this to understand boundaries
|
|
94
|
+
Stream A:
|
|
95
|
+
Files: src/db/* # Agent A only touches these
|
|
96
|
+
Stream B:
|
|
97
|
+
Files: src/api/* # Agent B only touches these
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Handling Conflicts
|
|
101
|
+
|
|
102
|
+
### Conflict Detection
|
|
103
|
+
```bash
|
|
104
|
+
# If commit fails due to conflict
|
|
105
|
+
git commit -m "Issue #1234: Update"
|
|
106
|
+
# Error: conflicts exist
|
|
107
|
+
|
|
108
|
+
# Agent should report and wait
|
|
109
|
+
echo "❌ Conflict detected in {files}"
|
|
110
|
+
echo "Human intervention needed"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Conflict Resolution
|
|
114
|
+
Always defer to humans:
|
|
115
|
+
1. Agent detects conflict
|
|
116
|
+
2. Agent reports issue
|
|
117
|
+
3. Agent pauses work
|
|
118
|
+
4. Human resolves
|
|
119
|
+
5. Agent continues
|
|
120
|
+
|
|
121
|
+
Never attempt automatic merge resolution.
|
|
122
|
+
|
|
123
|
+
## Synchronization Points
|
|
124
|
+
|
|
125
|
+
### Natural Sync Points
|
|
126
|
+
- After each commit
|
|
127
|
+
- Before starting new file
|
|
128
|
+
- When switching work streams
|
|
129
|
+
- Every 30 minutes of work
|
|
130
|
+
|
|
131
|
+
### Explicit Sync
|
|
132
|
+
```bash
|
|
133
|
+
# Pull latest changes
|
|
134
|
+
git pull --rebase origin epic/{name}
|
|
135
|
+
|
|
136
|
+
# If conflicts, stop and report
|
|
137
|
+
if [[ $? -ne 0 ]]; then
|
|
138
|
+
echo "❌ Sync failed - human help needed"
|
|
139
|
+
exit 1
|
|
140
|
+
fi
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Agent Communication Protocol
|
|
144
|
+
|
|
145
|
+
### Status Updates
|
|
146
|
+
Agents should update their status regularly:
|
|
147
|
+
```bash
|
|
148
|
+
# Update progress file every significant step
|
|
149
|
+
echo "✅ Completed: Database schema" >> stream-A.md
|
|
150
|
+
git add stream-A.md
|
|
151
|
+
git commit -m "Progress: Stream A - schema complete"
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Coordination Requests
|
|
155
|
+
When agents need to coordinate:
|
|
156
|
+
```markdown
|
|
157
|
+
# In stream-A.md
|
|
158
|
+
## Coordination Needed
|
|
159
|
+
- Need to update src/types/index.ts
|
|
160
|
+
- Will modify after Stream B commits
|
|
161
|
+
- ETA: 10 minutes
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Parallel Commit Strategy
|
|
165
|
+
|
|
166
|
+
### No Conflicts Possible
|
|
167
|
+
When working on completely different files:
|
|
168
|
+
```bash
|
|
169
|
+
# These can happen simultaneously
|
|
170
|
+
Agent-A: git commit -m "Issue #1234: Update database"
|
|
171
|
+
Agent-B: git commit -m "Issue #1235: Update UI"
|
|
172
|
+
Agent-C: git commit -m "Issue #1236: Add tests"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Sequential When Needed
|
|
176
|
+
When touching shared resources:
|
|
177
|
+
```bash
|
|
178
|
+
# Agent A commits first
|
|
179
|
+
git add src/types/index.ts
|
|
180
|
+
git commit -m "Issue #1234: Update type definitions"
|
|
181
|
+
|
|
182
|
+
# Agent B waits, then proceeds
|
|
183
|
+
# (After A's commit)
|
|
184
|
+
git pull
|
|
185
|
+
git add src/api/users.ts
|
|
186
|
+
git commit -m "Issue #1235: Use new types"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Best Practices
|
|
190
|
+
|
|
191
|
+
1. **Commit early and often** - Smaller commits = fewer conflicts
|
|
192
|
+
2. **Stay in your lane** - Only modify assigned files
|
|
193
|
+
3. **Communicate changes** - Update progress files
|
|
194
|
+
4. **Pull frequently** - Stay synchronized with other agents
|
|
195
|
+
5. **Fail loudly** - Report issues immediately
|
|
196
|
+
6. **Never force** - No `--force` flags ever
|
|
197
|
+
|
|
198
|
+
## Common Patterns
|
|
199
|
+
|
|
200
|
+
### Starting Work
|
|
201
|
+
```bash
|
|
202
|
+
1. cd ../epic-{name}
|
|
203
|
+
2. git pull
|
|
204
|
+
3. Check {issue}-analysis.md for assignment
|
|
205
|
+
4. Update stream-{X}.md with "started"
|
|
206
|
+
5. Begin work on assigned files
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### During Work
|
|
210
|
+
```bash
|
|
211
|
+
1. Make changes to assigned files
|
|
212
|
+
2. Commit with clear message
|
|
213
|
+
3. Update progress file
|
|
214
|
+
4. Check for new commits from others
|
|
215
|
+
5. Continue or coordinate as needed
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Completing Work
|
|
219
|
+
```bash
|
|
220
|
+
1. Final commit for stream
|
|
221
|
+
2. Update stream-{X}.md with "completed"
|
|
222
|
+
3. Check if other streams need help
|
|
223
|
+
4. Report completion
|
|
224
|
+
```
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Branch Operations
|
|
2
|
+
|
|
3
|
+
Git branches enable parallel development by allowing multiple developers to work on the same repository with isolated changes.
|
|
4
|
+
|
|
5
|
+
## Creating Branches
|
|
6
|
+
|
|
7
|
+
Always create branches from a clean main branch:
|
|
8
|
+
```bash
|
|
9
|
+
# Ensure main is up to date
|
|
10
|
+
git checkout main
|
|
11
|
+
git pull origin main
|
|
12
|
+
|
|
13
|
+
# Create branch for epic
|
|
14
|
+
git checkout -b epic/{name}
|
|
15
|
+
git push -u origin epic/{name}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The branch will be created and pushed to origin with upstream tracking.
|
|
19
|
+
|
|
20
|
+
## Working in Branches
|
|
21
|
+
|
|
22
|
+
### Agent Commits
|
|
23
|
+
- Agents commit directly to the branch
|
|
24
|
+
- Use small, focused commits
|
|
25
|
+
- Commit message format: `Issue #{number}: {description}`
|
|
26
|
+
- Example: `Issue #1234: Add user authentication schema`
|
|
27
|
+
|
|
28
|
+
### File Operations
|
|
29
|
+
```bash
|
|
30
|
+
# Working directory is the current directory
|
|
31
|
+
# (no need to change directories like with worktrees)
|
|
32
|
+
|
|
33
|
+
# Normal git operations work
|
|
34
|
+
git add {files}
|
|
35
|
+
git commit -m "Issue #{number}: {change}"
|
|
36
|
+
|
|
37
|
+
# View branch status
|
|
38
|
+
git status
|
|
39
|
+
git log --oneline -5
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Parallel Work in Same Branch
|
|
43
|
+
|
|
44
|
+
Multiple agents can work in the same branch if they coordinate file access:
|
|
45
|
+
```bash
|
|
46
|
+
# Agent A works on API
|
|
47
|
+
git add src/api/*
|
|
48
|
+
git commit -m "Issue #1234: Add user endpoints"
|
|
49
|
+
|
|
50
|
+
# Agent B works on UI (coordinate to avoid conflicts!)
|
|
51
|
+
git pull origin epic/{name} # Get latest changes
|
|
52
|
+
git add src/ui/*
|
|
53
|
+
git commit -m "Issue #1235: Add dashboard component"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Merging Branches
|
|
57
|
+
|
|
58
|
+
When epic is complete, merge back to main:
|
|
59
|
+
```bash
|
|
60
|
+
# From main repository
|
|
61
|
+
git checkout main
|
|
62
|
+
git pull origin main
|
|
63
|
+
|
|
64
|
+
# Merge epic branch
|
|
65
|
+
git merge epic/{name}
|
|
66
|
+
|
|
67
|
+
# If successful, clean up
|
|
68
|
+
git branch -d epic/{name}
|
|
69
|
+
git push origin --delete epic/{name}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Handling Conflicts
|
|
73
|
+
|
|
74
|
+
If merge conflicts occur:
|
|
75
|
+
```bash
|
|
76
|
+
# Conflicts will be shown
|
|
77
|
+
git status
|
|
78
|
+
|
|
79
|
+
# Human resolves conflicts
|
|
80
|
+
# Then continue merge
|
|
81
|
+
git add {resolved-files}
|
|
82
|
+
git commit
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Branch Management
|
|
86
|
+
|
|
87
|
+
### List Active Branches
|
|
88
|
+
```bash
|
|
89
|
+
git branch -a
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Remove Stale Branch
|
|
93
|
+
```bash
|
|
94
|
+
# Delete local branch
|
|
95
|
+
git branch -d epic/{name}
|
|
96
|
+
|
|
97
|
+
# Delete remote branch
|
|
98
|
+
git push origin --delete epic/{name}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Check Branch Status
|
|
102
|
+
```bash
|
|
103
|
+
# Current branch info
|
|
104
|
+
git branch -v
|
|
105
|
+
|
|
106
|
+
# Compare with main
|
|
107
|
+
git log --oneline main..epic/{name}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Best Practices
|
|
111
|
+
|
|
112
|
+
1. **One branch per epic** - Not per issue
|
|
113
|
+
2. **Clean before create** - Always start from updated main
|
|
114
|
+
3. **Commit frequently** - Small commits are easier to merge
|
|
115
|
+
4. **Pull before push** - Get latest changes to avoid conflicts
|
|
116
|
+
5. **Use descriptive branches** - `epic/feature-name` not `feature`
|
|
117
|
+
|
|
118
|
+
## Common Issues
|
|
119
|
+
|
|
120
|
+
### Branch Already Exists
|
|
121
|
+
```bash
|
|
122
|
+
# Delete old branch first
|
|
123
|
+
git branch -D epic/{name}
|
|
124
|
+
git push origin --delete epic/{name}
|
|
125
|
+
# Then create new one
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Cannot Push Branch
|
|
129
|
+
```bash
|
|
130
|
+
# Check if branch exists remotely
|
|
131
|
+
git ls-remote origin epic/{name}
|
|
132
|
+
|
|
133
|
+
# Push with upstream
|
|
134
|
+
git push -u origin epic/{name}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Merge Conflicts During Pull
|
|
138
|
+
```bash
|
|
139
|
+
# Stash changes if needed
|
|
140
|
+
git stash
|
|
141
|
+
|
|
142
|
+
# Pull and rebase
|
|
143
|
+
git pull --rebase origin epic/{name}
|
|
144
|
+
|
|
145
|
+
# Restore changes
|
|
146
|
+
git stash pop
|
|
147
|
+
```
|