Skip to content

Commit e2b68e2

Browse files
Nick Sullivanclaude
andcommitted
📚 Add adaptive review workflow and XML naming standards
Comprehensive documentation for `/autotask` autonomous workflow: - Adaptive validation & review that scales with task complexity - 7-phase workflow from task to PR-ready state - Intelligent agent orchestration (Dixon, Ada, Phil, Rivera, Petra) - Leverages existing git hooks instead of custom validation Enhanced prompt engineering standards: - Semantic XML tag naming (not numbered) - Prevents brittle tag structures that break on reordering - Clear examples and rationale for LLM-to-LLM communication Key philosophy: - Review intensity matches risk/complexity - Simple beats complex - Human control, AI preparation 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 18c4a0b commit e2b68e2

File tree

2 files changed

+329
-0
lines changed

2 files changed

+329
-0
lines changed

.cursor/rules/prompt-engineering.mdc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ const auth = new OAuth2Client(clientId, clientSecret);
317317

318318
Guidelines for XML structure:
319319

320+
- **Use semantic names, not numbers**: `<task-preparation>` not `<phase-1>`, `<create-pr>` not `<step-6>`
321+
- Numbered tags are brittle: reordering requires renumbering all tags and references
322+
- Semantic tags are self-documenting: `<validation-and-review>` tells you what it does
323+
- Example: A workflow with `<task-preparation>`, `<execution>`, `<review>` stays clear even when phases are added or reordered
320324
- Be consistent with tag names throughout your codebase (always use `<task>` not
321325
sometimes `<objective>`)
322326
- Use semantically meaningful tag names that describe the content
Lines changed: 325 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,325 @@
1+
# Optimal Development Workflow
2+
3+
## Your Development Profile
4+
5+
- **Work Types**: All (bugs, features, refactoring, research/POCs)
6+
- **Project Complexity**: Medium (multi-service, 10-100k LOC)
7+
- **Review Style**: Fully autonomous (trust AI completely)
8+
- **Risk Tolerance**: Aggressive (move fast, fix issues if they arise)
9+
10+
**Optimization Goal**: Maximum speed and autonomy with intelligent fail-fast mechanisms.
11+
12+
## Current Workflow Problems
13+
14+
1. **Sequential when could be faster**: Not using worktrees for isolation
15+
2. **Late validation**: Finding issues in CI instead of locally
16+
3. **Manual agent selection**: Not systematically using the right agent for the job
17+
4. **Waiting for bot feedback**: Then manually addressing it
18+
19+
## The Solution: `/autotask`
20+
21+
One command that handles everything from task to PR-ready state.
22+
23+
```bash
24+
/autotask "add user authentication with OAuth2"
25+
```
26+
27+
**What you do**: Describe the task, review the PR when ready, merge when satisfied
28+
**What AI does**: Everything else
29+
30+
## How `/autotask` Works
31+
32+
### Phase 1: Task Preparation
33+
34+
Analyzes task complexity:
35+
36+
- **Complex** (multi-step, unclear, major feature) → Run `/create-prompt` first
37+
- Ask clarifying questions with AskUserQuestion
38+
- Create structured prompt
39+
- Save to `.created-prompts/`
40+
- Get your confirmation before proceeding
41+
- **Straightforward** → Skip directly to execution
42+
43+
### Phase 2: Worktree Setup
44+
45+
Create isolated development environment:
46+
47+
```bash
48+
mkdir -p .gitworktrees
49+
git worktree add -b feature/task-name .gitworktrees/task-name main
50+
cd .gitworktrees/task-name
51+
/setup-environment # Install deps, copy env files, setup git hooks
52+
```
53+
54+
### Phase 3: Autonomous Execution
55+
56+
LLM intelligently chooses which agents to use based on the task:
57+
58+
- **Dixon** (debugger) - Root cause analysis for bugs
59+
- **Ada** (autonomous-developer) - Implementation work
60+
- **Phil** (ux-designer) - User-facing content review
61+
- **Rivera** (code-reviewer) - Architecture and security review
62+
- **Petra** (prompt-engineer) - Prompt optimization
63+
64+
**No forced patterns. No classification rules.** Just intelligent agent selection.
65+
66+
Automatically follows all `.cursor/rules/*.mdc` standards.
67+
68+
### Phase 4: Adaptive Validation & Review
69+
70+
**The key insight**: Review intensity should match task complexity and risk.
71+
72+
**Step 1: Git hooks handle the basics**
73+
- Your existing husky/pre-commit hooks run automatically
74+
- Linting, formatting, type checking, unit tests
75+
- Auto-fix what can be fixed
76+
77+
**Step 2: Conditional agent review based on complexity**
78+
79+
**Minimal Review** (trivial changes):
80+
- Git hooks pass = good enough
81+
- No additional review needed
82+
83+
**Targeted Review** (medium complexity):
84+
- Git hooks + one relevant agent
85+
- UI changes → Phil reviews UX
86+
- Bug fixes → Dixon spot-checks for edge cases
87+
- Refactoring → Rivera validates architecture
88+
89+
**Comprehensive Review** (high risk/complexity):
90+
- Git hooks + multiple agents
91+
- Security changes → Full Rivera security review
92+
- Major features → Rivera + Phil + Dixon
93+
- Breaking changes → Extra scrutiny
94+
95+
**Smart Principles**:
96+
- Don't review what hooks already validated
97+
- Focus on what automation can't catch (design decisions, security logic, UX)
98+
- Skip review entirely for trivial changes that pass hooks
99+
100+
### Phase 5: Create PR
101+
102+
```bash
103+
# Commit with proper message format
104+
git add .
105+
git commit -m "feat: Add OAuth2 authentication
106+
107+
- Implement OAuth2 flow with token refresh
108+
- Add email/password fallback
109+
- Session management middleware
110+
- Test coverage: 97%
111+
112+
🤖 Generated with Claude Code
113+
"
114+
115+
# Push to origin
116+
git push -u origin feature/task-name
117+
118+
# Create PR
119+
gh pr create \
120+
--title "Add OAuth2 authentication" \
121+
--body "Summary of changes..."
122+
```
123+
124+
### Phase 6: Bot Feedback Loop
125+
126+
**This is the key innovation** - don't wait for you, autonomously handle bot feedback:
127+
128+
```bash
129+
echo "⏳ Waiting for bot reviews..."
130+
PR_NUMBER=$(gh pr view --json number -q .number)
131+
132+
# Initial wait for bots to run
133+
sleep 120
134+
135+
# Loop until all bot feedback addressed
136+
while true; do
137+
echo "📝 Checking for bot comments..."
138+
139+
# Get unresolved bot comments
140+
COMMENTS=$(gh api \
141+
repos/{owner}/{repo}/pulls/$PR_NUMBER/comments \
142+
--jq '.[] | select(.user.type == "Bot") | select(.resolved != true)')
143+
144+
if [ -z "$COMMENTS" ]; then
145+
echo "✅ All bot feedback addressed!"
146+
break
147+
fi
148+
149+
echo "🤖 Analyzing bot feedback..."
150+
151+
# Categorize each comment intelligently:
152+
# - CRITICAL: Security, bugs, breaking changes → Fix immediately
153+
# - VALID: Legitimate improvements → Apply fix
154+
# - CONTEXT-MISSING: Bot lacks project context → Mark WONTFIX with explanation
155+
# - FALSE-POSITIVE: Bot is wrong → Mark WONTFIX with reasoning
156+
157+
# If fixes made, push and re-wait
158+
if git diff --quiet; then
159+
break # No changes needed
160+
else
161+
git add .
162+
git commit -m "Address bot feedback"
163+
git push
164+
165+
echo "⏳ Waiting for bots to re-review..."
166+
sleep 90
167+
fi
168+
done
169+
```
170+
171+
### Phase 7: Done - Handoff to You
172+
173+
```
174+
✅ Development complete
175+
✅ All validations passed
176+
✅ PR created and bot feedback addressed
177+
✅ Ready for your review
178+
179+
PR: https://github.com/user/repo/pull/123
180+
181+
When you're ready:
182+
- Review the changes
183+
- Merge when satisfied
184+
- Worktree cleanup happens after merge
185+
```
186+
187+
**You control the merge. Always.**
188+
189+
## Complete Example
190+
191+
```bash
192+
$ /autotask "add user authentication with OAuth2"
193+
194+
📋 Analyzing task complexity...
195+
🤔 This looks complex. Creating structured prompt first.
196+
197+
[Uses /create-prompt]
198+
✓ Saved to .created-prompts/Add-User-Authentication-OAuth2.md
199+
200+
Execute this prompt? (y/n) y
201+
202+
🚀 Creating worktree...
203+
✓ .gitworktrees/add-user-auth created
204+
✓ Environment setup complete
205+
206+
🤖 Executing task...
207+
- Dixon analyzing existing auth patterns
208+
- Ada implementing OAuth2 flow
209+
- Ada writing comprehensive tests
210+
- Phil reviewing user-facing error messages
211+
212+
🔍 Adaptive validation & review
213+
- Git hooks: ✓ (lint, format, type-check, tests)
214+
- Security review: ✓ Rivera found + fixed rate limiting issue
215+
- UX review: ✓ Phil improved error messages
216+
- Test coverage: 97%
217+
218+
🔄 Creating PR...
219+
✓ Committed with proper message format
220+
✓ Pushed to feature/add-user-auth
221+
✓ PR created: #456
222+
223+
⏳ Waiting for bot reviews...
224+
225+
📝 Bot comments received (2m 31s later):
226+
🤖 CodeRabbit: 3 suggestions
227+
✓ CRITICAL: Missing rate limiting on OAuth endpoint → Fixed
228+
✓ VALID: Extract token expiry constant → Applied
229+
✓ FALSE-POSITIVE: "Don't store tokens in memory"
230+
→ WONTFIX: Server-side session, explained in comment
231+
232+
📤 Pushing fixes...
233+
⏳ Waiting for bot re-review...
234+
235+
✅ All bot feedback addressed
236+
🎉 PR ready for your review!
237+
238+
View: https://github.com/you/repo/pull/456
239+
240+
Your involvement: Wrote task description, will review and merge PR
241+
```
242+
243+
## Agent Selection Strategy
244+
245+
Let the LLM intelligently choose. Common patterns:
246+
247+
**Bug Fixes**:
248+
249+
- Dixon analyzes root cause (not just symptoms)
250+
- Ada implements fix
251+
- Ada adds regression test
252+
253+
**New Features**:
254+
255+
- Ada reads all cursor rules
256+
- Ada implements feature
257+
- Phil reviews if user-facing
258+
- Ada writes comprehensive tests
259+
260+
**Refactoring**:
261+
262+
- Ada creates safety net (tests for current behavior)
263+
- Ada refactors incrementally
264+
- Rivera reviews for architectural issues
265+
- Dixon checks for subtle bugs
266+
267+
**Research/POCs**:
268+
269+
- Explore agent investigates options
270+
- Ada implements proof-of-concept
271+
- Document findings and recommendations
272+
273+
## Key Principles
274+
275+
1. **Single worktree per task**: Clean isolation for parallel development
276+
2. **Adaptive review**: Review intensity matches task complexity and risk
277+
3. **Intelligent agent selection**: Right agent for the job, no forced patterns
278+
4. **Git hooks do validation**: Leverage your existing infrastructure
279+
5. **Intelligent bot handling**: Distinguish valuable feedback from noise
280+
6. **PR-centric workflow**: Everything leads to a mergeable pull request
281+
7. **You control merge**: AI gets it ready, you decide when to ship
282+
283+
## What NOT To Do
284+
285+
- **Don't** create multiple parallel worktrees for one task - complexity disaster
286+
- **Don't** use forced classification logic - let LLM decide intelligently
287+
- **Don't** skip git hooks - they're already configured, use them
288+
- **Don't** do heavy review for trivial changes - scale effort with risk
289+
290+
## Metrics That Matter
291+
292+
**Speed**:
293+
294+
- Bot feedback cycles: Target 0-1 (minimize back-and-forth)
295+
296+
**Quality**:
297+
298+
- First-time merge rate: Target 95%
299+
- Bot feedback items: Target < 2 per PR
300+
- Post-merge bugs: Track and minimize
301+
302+
**Autonomy**:
303+
304+
- Human intervention: Only task description + merge decision
305+
- Agent utilization: Right agent for job, every time
306+
307+
## Next Steps
308+
309+
1.**Implement `/autotask` command** (`.claude/commands/autotask.md`)
310+
2.**Update `/setup-environment`** to use existing git hooks
311+
3. **Test with real tasks** (start simple, build confidence)
312+
4. **Iterate and improve** (measure metrics, optimize)
313+
314+
## The Philosophy
315+
316+
**Simple beats complex**: One worktree, clear flow, no magic
317+
318+
**Fast feedback**: Validate locally, catch early, fix immediately
319+
320+
**Intelligent automation**: Right agent, right time, right decision
321+
322+
**Human control**: AI prepares, human decides
323+
324+
This is autonomous development done right - fast, reliable, and always under your
325+
control.

0 commit comments

Comments
 (0)