ai-agent-rules 0.11.0__py3-none-any.whl
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.
Potentially problematic release.
This version of ai-agent-rules might be problematic. Click here for more details.
- ai_agent_rules-0.11.0.dist-info/METADATA +390 -0
- ai_agent_rules-0.11.0.dist-info/RECORD +42 -0
- ai_agent_rules-0.11.0.dist-info/WHEEL +5 -0
- ai_agent_rules-0.11.0.dist-info/entry_points.txt +3 -0
- ai_agent_rules-0.11.0.dist-info/licenses/LICENSE +22 -0
- ai_agent_rules-0.11.0.dist-info/top_level.txt +1 -0
- ai_rules/__init__.py +8 -0
- ai_rules/agents/__init__.py +1 -0
- ai_rules/agents/base.py +68 -0
- ai_rules/agents/claude.py +121 -0
- ai_rules/agents/goose.py +44 -0
- ai_rules/agents/shared.py +35 -0
- ai_rules/bootstrap/__init__.py +75 -0
- ai_rules/bootstrap/config.py +261 -0
- ai_rules/bootstrap/installer.py +249 -0
- ai_rules/bootstrap/updater.py +221 -0
- ai_rules/bootstrap/version.py +52 -0
- ai_rules/cli.py +2292 -0
- ai_rules/completions.py +194 -0
- ai_rules/config/AGENTS.md +249 -0
- ai_rules/config/chat_agent_hints.md +1 -0
- ai_rules/config/claude/agents/code-reviewer.md +121 -0
- ai_rules/config/claude/commands/annotate-changelog.md +191 -0
- ai_rules/config/claude/commands/comment-cleanup.md +161 -0
- ai_rules/config/claude/commands/continue-crash.md +38 -0
- ai_rules/config/claude/commands/dev-docs.md +169 -0
- ai_rules/config/claude/commands/pr-creator.md +247 -0
- ai_rules/config/claude/commands/test-cleanup.md +244 -0
- ai_rules/config/claude/commands/update-docs.md +324 -0
- ai_rules/config/claude/hooks/subagentStop.py +92 -0
- ai_rules/config/claude/mcps.json +1 -0
- ai_rules/config/claude/settings.json +116 -0
- ai_rules/config/claude/skills/doc-writer/SKILL.md +293 -0
- ai_rules/config/claude/skills/doc-writer/resources/templates.md +495 -0
- ai_rules/config/claude/skills/prompt-engineer/SKILL.md +272 -0
- ai_rules/config/claude/skills/prompt-engineer/resources/prompt_engineering_guide_2025.md +855 -0
- ai_rules/config/claude/skills/prompt-engineer/resources/templates.md +232 -0
- ai_rules/config/goose/config.yaml +55 -0
- ai_rules/config.py +635 -0
- ai_rules/display.py +40 -0
- ai_rules/mcp.py +370 -0
- ai_rules/symlinks.py +207 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Annotates auto-generated changelog entries with detailed descriptions
|
|
3
|
+
allowed-tools: AskUserQuestion, Bash, Edit, Glob, Grep, Read, TodoWrite
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
- Changelog file: !`find . -maxdepth 1 -name "CHANGELOG*" -type f | head -1`
|
|
10
|
+
- Recent commits: !`git log --oneline -20 2>/dev/null || echo "NO_COMMITS"`
|
|
11
|
+
- Git repo root: !`git rev-parse --show-toplevel 2>/dev/null || pwd`
|
|
12
|
+
|
|
13
|
+
# Annotate Changelog
|
|
14
|
+
|
|
15
|
+
**Usage:**
|
|
16
|
+
- `/annotate-changelog` - Add detailed descriptions to terse auto-generated changelog entries
|
|
17
|
+
|
|
18
|
+
Enhances auto-generated changelogs (from semantic-release, conventional commits, etc.) by adding user-facing descriptions beneath terse commit messages. Gathers context from git diffs, commit messages, and PR descriptions to explain what changed and why it matters.
|
|
19
|
+
|
|
20
|
+
## Workflow
|
|
21
|
+
|
|
22
|
+
### Phase 1: Parse Changelog
|
|
23
|
+
|
|
24
|
+
1. **Read CHANGELOG.md** (from Context above)
|
|
25
|
+
2. **Identify entries needing annotation:**
|
|
26
|
+
- Look for terse commit messages ("Cc perms", "Still flaky", "Llms are dumb")
|
|
27
|
+
- Short descriptions without explanation of impact
|
|
28
|
+
- Entries with just commit SHA links but no detail
|
|
29
|
+
3. **Extract commit information:**
|
|
30
|
+
- Parse version sections (e.g., `## [0.10.3] - 2024-12-05`)
|
|
31
|
+
- Find commit SHAs in links (e.g., `[9dd366c]`)
|
|
32
|
+
- Note existing structure (bullets, sections like "### Added")
|
|
33
|
+
|
|
34
|
+
### Phase 2: Gather Context
|
|
35
|
+
|
|
36
|
+
For each entry needing annotation:
|
|
37
|
+
|
|
38
|
+
1. **Get full commit message:**
|
|
39
|
+
```bash
|
|
40
|
+
git log -1 --format="%B" <sha>
|
|
41
|
+
```
|
|
42
|
+
The full body often has more detail than the subject line.
|
|
43
|
+
|
|
44
|
+
2. **Get commit diff summary:**
|
|
45
|
+
```bash
|
|
46
|
+
git show --stat <sha>
|
|
47
|
+
```
|
|
48
|
+
Shows which files changed, gives technical context.
|
|
49
|
+
|
|
50
|
+
3. **Search for related PR:**
|
|
51
|
+
```bash
|
|
52
|
+
gh pr list --search "<sha>" --state merged --json number,title
|
|
53
|
+
```
|
|
54
|
+
Find if this commit was part of a pull request.
|
|
55
|
+
|
|
56
|
+
4. **If PR found, get description:**
|
|
57
|
+
```bash
|
|
58
|
+
gh pr view <pr_number> --json body --jq .body
|
|
59
|
+
```
|
|
60
|
+
PR descriptions often have better user-facing explanations.
|
|
61
|
+
|
|
62
|
+
5. **If context is insufficient** (all sources are terse or unclear):
|
|
63
|
+
- Use AskUserQuestion tool
|
|
64
|
+
- Show the commit SHA and message
|
|
65
|
+
- Ask: "What was the user-facing change in this commit?"
|
|
66
|
+
|
|
67
|
+
### Phase 3: Generate Annotations
|
|
68
|
+
|
|
69
|
+
For each entry:
|
|
70
|
+
|
|
71
|
+
1. **Analyze context gathered:**
|
|
72
|
+
- What files changed? (from diff)
|
|
73
|
+
- What's the user-facing impact?
|
|
74
|
+
- Why did this change happen? (bug fix, new feature, breaking change)
|
|
75
|
+
|
|
76
|
+
2. **Write annotation:**
|
|
77
|
+
- Focus on user-facing impact, not implementation details
|
|
78
|
+
- Explain WHAT changed for users, not HOW it was implemented
|
|
79
|
+
- Keep it concise (1-2 sentences)
|
|
80
|
+
- Match existing changelog tone/style
|
|
81
|
+
|
|
82
|
+
3. **Format:**
|
|
83
|
+
```markdown
|
|
84
|
+
- Terse commit message ([commit_sha])
|
|
85
|
+
> Detailed annotation explaining user-facing impact
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Phase 4: Update Changelog
|
|
89
|
+
|
|
90
|
+
1. **Preserve structure:**
|
|
91
|
+
- Keep version headers intact
|
|
92
|
+
- Maintain section organization (Added, Fixed, etc.)
|
|
93
|
+
- Keep commit SHA links as-is
|
|
94
|
+
- Don't remove or replace original entries
|
|
95
|
+
|
|
96
|
+
2. **Add annotations:**
|
|
97
|
+
- Insert description as blockquote below entry
|
|
98
|
+
- Use `>` for blockquote formatting
|
|
99
|
+
- Maintain consistent indentation
|
|
100
|
+
|
|
101
|
+
3. **Present changes:**
|
|
102
|
+
- Show diff before applying
|
|
103
|
+
- Explain how many entries were annotated
|
|
104
|
+
- Give user chance to review
|
|
105
|
+
|
|
106
|
+
4. **Apply edits:**
|
|
107
|
+
- Use Edit tool to update CHANGELOG.md
|
|
108
|
+
- Make one edit per entry or batch similar entries
|
|
109
|
+
|
|
110
|
+
## Example Transformation
|
|
111
|
+
|
|
112
|
+
**Before:**
|
|
113
|
+
```markdown
|
|
114
|
+
## [0.10.3] - 2024-12-05
|
|
115
|
+
|
|
116
|
+
### Bug Fixes
|
|
117
|
+
|
|
118
|
+
- Cc perms ([9dd366c])
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**After:**
|
|
122
|
+
```markdown
|
|
123
|
+
## [0.10.3] - 2024-12-05
|
|
124
|
+
|
|
125
|
+
### Bug Fixes
|
|
126
|
+
|
|
127
|
+
- Cc perms ([9dd366c])
|
|
128
|
+
> Fixed Claude Code permissions in settings.json to allow the doc-writer skill
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Before:**
|
|
132
|
+
```markdown
|
|
133
|
+
### Added
|
|
134
|
+
|
|
135
|
+
- Doc-writer skill for claude code ([e293e4c])
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**After:**
|
|
139
|
+
```markdown
|
|
140
|
+
### Added
|
|
141
|
+
|
|
142
|
+
- Doc-writer skill for claude code ([e293e4c])
|
|
143
|
+
> Added new Claude Code skill that provides guidance for writing compact, effective technical documentation including README, ARCHITECTURE, and API docs
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Key Principles
|
|
147
|
+
|
|
148
|
+
**Focus on user impact:**
|
|
149
|
+
- "Added X feature that lets users do Y"
|
|
150
|
+
- "Fixed bug where Z would fail"
|
|
151
|
+
- NOT: "Updated function foo() to call bar()"
|
|
152
|
+
|
|
153
|
+
**Be concise:**
|
|
154
|
+
- 1-2 sentences max
|
|
155
|
+
- Don't repeat obvious information from commit message
|
|
156
|
+
- Add value, don't just restate
|
|
157
|
+
|
|
158
|
+
**Preserve changelog structure:**
|
|
159
|
+
- Don't change version numbers, dates, or commit links
|
|
160
|
+
- Don't reorganize sections
|
|
161
|
+
- Don't remove entries (even if trivial)
|
|
162
|
+
|
|
163
|
+
**Match style:**
|
|
164
|
+
- Use same tone as existing entries
|
|
165
|
+
- Follow Keep a Changelog format if present
|
|
166
|
+
- Consistent formatting (blockquotes for annotations)
|
|
167
|
+
|
|
168
|
+
## Critical Requirements
|
|
169
|
+
|
|
170
|
+
**Context gathering:**
|
|
171
|
+
- MUST try git diffs first, then commit messages, then PR descriptions
|
|
172
|
+
- MUST use AskUserQuestion if all sources are unclear
|
|
173
|
+
- DON'T fabricate or guess at changes
|
|
174
|
+
|
|
175
|
+
**Annotations:**
|
|
176
|
+
- MUST focus on user-facing impact
|
|
177
|
+
- MUST be concise (1-2 sentences)
|
|
178
|
+
- MUST NOT repeat implementation details already in diff
|
|
179
|
+
|
|
180
|
+
**Structure preservation:**
|
|
181
|
+
- MUST keep all original entries intact
|
|
182
|
+
- MUST preserve commit SHA links
|
|
183
|
+
- MUST maintain version structure and dates
|
|
184
|
+
- MUST use blockquote format (`>`) for annotations
|
|
185
|
+
|
|
186
|
+
**Approval:**
|
|
187
|
+
- MUST show diff before applying changes
|
|
188
|
+
- MUST explain how many entries were annotated
|
|
189
|
+
- DON'T apply changes without user seeing what will change
|
|
190
|
+
|
|
191
|
+
Your goal is to make auto-generated changelogs more useful by adding context about what changed from a user's perspective, while preserving the automated structure and commit traceability.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Remove unnecessary code comments that explain WHAT instead of WHY
|
|
3
|
+
allowed-tools: AskUserQuestion, Bash, Edit, Glob, Grep, Read, TodoWrite, Write
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
- Project root: !`git rev-parse --show-toplevel 2>/dev/null || pwd`
|
|
10
|
+
- Primary languages: !`find . -type f \( -name "*.js" -o -name "*.ts" -o -name "*.py" -o -name "*.go" -o -name "*.rb" -o -name "*.rs" \) 2>/dev/null | sed 's/.*\.//' | sort | uniq -c | sort -nr | head -5`
|
|
11
|
+
- Test files count: !`find . -type f \( -name "*test*" -o -name "*spec*" \) 2>/dev/null | wc -l`
|
|
12
|
+
- Total comment lines: !`grep -r "^\s*\(//\|#\|/\*\)" --include="*.js" --include="*.ts" --include="*.py" --include="*.go" 2>/dev/null | wc -l`
|
|
13
|
+
- Build/Test command: !`[ -f package.json ] && echo "npm" || [ -f Makefile ] && echo "make" || [ -f pyproject.toml ] && echo "pytest" || echo "unknown"`
|
|
14
|
+
|
|
15
|
+
# Comment Cleanup
|
|
16
|
+
|
|
17
|
+
Perform comprehensive cleanup of unnecessary code comments across the codebase, removing comments that explain WHAT the code does (when self-evident) rather than WHY certain decisions were made.
|
|
18
|
+
|
|
19
|
+
## Decision Framework
|
|
20
|
+
|
|
21
|
+
For each comment encountered, apply this evaluation in order:
|
|
22
|
+
|
|
23
|
+
1. **Is it a preserved type?** (Shebang, linter directive, TODO/FIXME, docstring) → **KEEP**
|
|
24
|
+
2. **Does it explain WHY?** (Rationale, workaround, warning, performance note) → **KEEP**
|
|
25
|
+
3. **Does it explain WHAT?** (Organizational, obvious, implementation detail) → **REMOVE**
|
|
26
|
+
4. **Would removing make code harder to maintain?** → **KEEP**
|
|
27
|
+
|
|
28
|
+
## What to Remove
|
|
29
|
+
|
|
30
|
+
**Organizational comments**: Section dividers
|
|
31
|
+
```python
|
|
32
|
+
# --- User Management Functions ---
|
|
33
|
+
# Database Operations
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Obvious comments**: Restating the code
|
|
37
|
+
```javascript
|
|
38
|
+
// Create config
|
|
39
|
+
const config = createConfig();
|
|
40
|
+
// Check if path exists
|
|
41
|
+
if (!pathExists(path)) return false;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Implementation detail comments**: Explaining how when it's clear
|
|
45
|
+
```go
|
|
46
|
+
// Try exact match first
|
|
47
|
+
if val, ok := map[key]; ok { return val }
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Trivial test comments**: Stating the obvious
|
|
51
|
+
```python
|
|
52
|
+
# Should be parsed as integer
|
|
53
|
+
assert isinstance(result, int)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## What to Preserve
|
|
57
|
+
|
|
58
|
+
**WHY comments**: Explaining decisions, workarounds, warnings
|
|
59
|
+
```javascript
|
|
60
|
+
// Use deep copy to prevent mutation of shared state object
|
|
61
|
+
const result = deepCopy(baseObject);
|
|
62
|
+
|
|
63
|
+
// Workaround for IE11 - doesn't support fetch API
|
|
64
|
+
if (!window.fetch) return xhrRequest(url);
|
|
65
|
+
|
|
66
|
+
// PERF: Cache compiled regex to avoid recompilation on every call
|
|
67
|
+
const cachedPattern = /^[a-z]+$/i;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Documentation comments**: Function/class docs (docstrings, JSDoc, JavaDoc, etc.)
|
|
71
|
+
|
|
72
|
+
**Directives**: Shebangs (`#!/usr/bin/env`), linter configs (`eslint-disable`, `noqa`, `@ts-ignore`, `#pragma`)
|
|
73
|
+
|
|
74
|
+
**Action items**: TODO, FIXME, HACK, NOTE with context
|
|
75
|
+
|
|
76
|
+
## Systematic Process
|
|
77
|
+
|
|
78
|
+
### Step 1: Prioritized Search Strategy
|
|
79
|
+
|
|
80
|
+
Use the language information from Context above to focus your search. Map comment patterns by language:
|
|
81
|
+
- **JavaScript/TypeScript**: `//`, `/* */`, `/** */` (preserve JSDoc)
|
|
82
|
+
- **Python**: `#`, `"""`, `'''` (preserve docstrings)
|
|
83
|
+
- **Go**: `//`, `/* */`
|
|
84
|
+
- **Shell/Bash**: `#` (preserve shebangs)
|
|
85
|
+
- **Ruby**: `#`, `=begin`/`=end`
|
|
86
|
+
- **Rust**: `//`, `/* */`, `///` (preserve doc comments)
|
|
87
|
+
|
|
88
|
+
### Step 2: Execute Search
|
|
89
|
+
|
|
90
|
+
**Start with highest-density areas** (most trivial comments):
|
|
91
|
+
1. Test files (`*_test.*`, `test_*.py`, `*.spec.*`)
|
|
92
|
+
2. Implementation files in `src/`, `lib/`, `pkg/`
|
|
93
|
+
3. Configuration files
|
|
94
|
+
|
|
95
|
+
**Search commands** by language:
|
|
96
|
+
```bash
|
|
97
|
+
# JavaScript/TypeScript
|
|
98
|
+
rg "^\s*//" --type js --type ts src/ tests/
|
|
99
|
+
|
|
100
|
+
# Python
|
|
101
|
+
rg "^\s*#(?!\s*(?:!/|pragma|noqa|type:))" --type py
|
|
102
|
+
|
|
103
|
+
# Multiple languages
|
|
104
|
+
rg "^\s*(?://|#)" src/ tests/ --glob '!*.{md,txt}'
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Step 3: Review & Categorize
|
|
108
|
+
|
|
109
|
+
For each file with comments:
|
|
110
|
+
1. Apply decision framework to each comment
|
|
111
|
+
2. Mark comments for removal vs preservation
|
|
112
|
+
3. Look for patterns (e.g., all section dividers)
|
|
113
|
+
4. Consider batch removal for repeated trivial patterns
|
|
114
|
+
|
|
115
|
+
### Step 4: Execute Removals
|
|
116
|
+
|
|
117
|
+
- Use Edit tool for targeted comment removal
|
|
118
|
+
- Maintain code structure and intentional blank lines
|
|
119
|
+
- Process files systematically (test files first)
|
|
120
|
+
- Keep running count of removals
|
|
121
|
+
|
|
122
|
+
### Step 5: Validation
|
|
123
|
+
|
|
124
|
+
Run validation checks:
|
|
125
|
+
```bash
|
|
126
|
+
# Run tests
|
|
127
|
+
npm test # or pytest, go test, cargo test, etc.
|
|
128
|
+
|
|
129
|
+
# Run linter/formatter
|
|
130
|
+
npm run lint # or ruff check, golangci-lint, etc.
|
|
131
|
+
|
|
132
|
+
# Verify no trivial comments remain
|
|
133
|
+
rg "^\s*(?://|#)\s*(?:Create|Check|Set|Get|Return|Loop)" src/
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Success Criteria
|
|
137
|
+
|
|
138
|
+
✓ All trivial/obvious comments removed
|
|
139
|
+
✓ Code remains self-documenting through clear naming
|
|
140
|
+
✓ All tests pass without modification
|
|
141
|
+
✓ Linter checks pass
|
|
142
|
+
✓ Only WHY comments remain (if any)
|
|
143
|
+
✓ Test execution time unchanged
|
|
144
|
+
✓ Code coverage metrics maintained
|
|
145
|
+
|
|
146
|
+
## Common Pitfalls to Avoid
|
|
147
|
+
|
|
148
|
+
- **Don't remove error suppression**: `// @ts-ignore`, `// eslint-disable`, `# noqa`
|
|
149
|
+
- **Don't remove type hints**: `# type: ignore`, `/** @type {string} */`
|
|
150
|
+
- **Don't remove legal/license headers**: Usually at file top
|
|
151
|
+
- **Don't remove API documentation**: JSDoc, docstrings, doc comments
|
|
152
|
+
- **Do preserve context for workarounds**: Even if explaining WHAT, workarounds need WHY
|
|
153
|
+
|
|
154
|
+
## Reporting
|
|
155
|
+
|
|
156
|
+
After completion, provide summary:
|
|
157
|
+
- Total comments removed: X
|
|
158
|
+
- Files modified: Y
|
|
159
|
+
- Comment types preserved: [list]
|
|
160
|
+
- Test result: PASS/FAIL
|
|
161
|
+
- Next steps if issues found
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Continues after a session crash while working on a task
|
|
3
|
+
model: inherit
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Context
|
|
7
|
+
|
|
8
|
+
- Git status: !`git status --porcelain 2>/dev/null | head -20 || echo "NOT_IN_GIT"`
|
|
9
|
+
- Recent commits: !`git log --oneline -5 2>/dev/null || echo "NO_COMMITS"`
|
|
10
|
+
- Modified files: !`git diff --name-only 2>/dev/null | head -10 || echo "NONE"`
|
|
11
|
+
- Current branch: !`git branch --show-current 2>/dev/null || echo "UNKNOWN"`
|
|
12
|
+
- TODO files: !`ls -la PLAN__*.md TODO.md 2>/dev/null || echo "No TODO files found"`
|
|
13
|
+
|
|
14
|
+
# Continue After Crash
|
|
15
|
+
|
|
16
|
+
Our session crashed. Use the context above to recover and continue where we left off.
|
|
17
|
+
|
|
18
|
+
## Recovery Process
|
|
19
|
+
|
|
20
|
+
1. **Analyze context** from pre-executed commands above:
|
|
21
|
+
- Review git status to see uncommitted work
|
|
22
|
+
- Check recent commits to understand what was completed
|
|
23
|
+
- Look for TODO/PLAN files documenting the task
|
|
24
|
+
|
|
25
|
+
2. **Reconstruct and resume**:
|
|
26
|
+
- Identify the task from the evidence
|
|
27
|
+
- Create or update TODO list based on actual progress
|
|
28
|
+
- Fix any test failures before continuing
|
|
29
|
+
- Continue from the interruption point
|
|
30
|
+
|
|
31
|
+
## Important
|
|
32
|
+
|
|
33
|
+
- Base reconstruction only on the evidence provided in Context
|
|
34
|
+
- If context is unclear from the data above, ask for clarification
|
|
35
|
+
- Don't duplicate completed work - verify what's done in git history
|
|
36
|
+
- Maintain the original task direction and intent
|
|
37
|
+
|
|
38
|
+
Resume work from where it was interrupted.
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Creates or updates PLAN.md based on session - auto-detects create vs update mode
|
|
3
|
+
allowed-tools: AskUserQuestion, Bash, Edit, Glob, Grep, Read, TodoWrite, Write
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
- Project: !`git rev-parse --show-toplevel 2>/dev/null || echo "NOT_IN_GIT_REPO"`
|
|
10
|
+
- PLAN files: !`sh -c 'PROJECT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null); if [ -z "$PROJECT_ROOT" ]; then echo "NOT_IN_GIT_REPO"; exit 0; fi; cd "$PROJECT_ROOT" && for f in PLAN__*.md; do [ -f "$f" ] && echo "$f" && found=1; done; if [ -z "$found" ]; then [ -f PLAN.md ] && echo "LEGACY_PLAN" || echo "NO_PLAN_FILES"; fi' 2>/dev/null | sed 's/PLAN__//;s/\.md$//' | paste -sd ',' -`
|
|
11
|
+
- Directory: !`pwd`
|
|
12
|
+
- Last commit: !`git log -1 --format="%h %ai %s" 2>/dev/null || echo "NO_COMMITS"`
|
|
13
|
+
|
|
14
|
+
# Create or Update Development Documentation
|
|
15
|
+
|
|
16
|
+
Automatically creates task-specific PLAN files (`PLAN__<TASK>.md`) or updates existing ones by analyzing session activity to track implementation progress. Multiple agents can work simultaneously, each with their own per-task plan file.
|
|
17
|
+
|
|
18
|
+
## Task-Specific PLAN Files
|
|
19
|
+
|
|
20
|
+
**Purpose:** Single source of truth for plans and progress across sessions, tracking multi-phase work with status indicators
|
|
21
|
+
|
|
22
|
+
**Naming Convention:**
|
|
23
|
+
- Format: `PLAN__<TASK>.md` (always `PLAN__` with two underscores)
|
|
24
|
+
- Task identifier: 1-2 words, uppercase letters only, single underscores between words
|
|
25
|
+
- Valid: ✓ `AUTH_FLOW`, ✓ `API_MIGRATION`, ✓ `SLACK_FORMATTING`
|
|
26
|
+
- Invalid: ✗ `auth_flow` (lowercase), ✗ `AUTH__FLOW` (double underscore), ✗ `TOO_MANY_WORDS` (>2 words)
|
|
27
|
+
|
|
28
|
+
## CRITICAL: File Location
|
|
29
|
+
|
|
30
|
+
**ALWAYS write PLAN files to the git repository root, NEVER to ~/.claude/plans/**
|
|
31
|
+
|
|
32
|
+
- Target path: `{git_root}/PLAN__<TASK>.md` (e.g., `/Users/user/project/PLAN__AUTH_FLOW.md`)
|
|
33
|
+
- Claude Code has an internal plan mode that uses `~/.claude/plans/` - this is SEPARATE and UNRELATED
|
|
34
|
+
- If you see a path containing `~/.claude/plans/`, you are using the WRONG location
|
|
35
|
+
- The `/dev-docs` command manages repository-local documentation, not Claude Code internals
|
|
36
|
+
|
|
37
|
+
## Phase 1: Determine Mode
|
|
38
|
+
|
|
39
|
+
Use pre-executed context to determine mode:
|
|
40
|
+
|
|
41
|
+
**Check "PLAN files" from Context:**
|
|
42
|
+
- `NO_PLAN_FILES` → **Create mode**: Extract plan from ExitPlanMode, generate task name
|
|
43
|
+
- `LEGACY_PLAN` → **Legacy migration**: Rename PLAN.md to PLAN__<TASK>.md, continue as update
|
|
44
|
+
- Single task (e.g., `AUTH_FLOW`) → **Update mode**: Work with that specific file
|
|
45
|
+
- Multiple tasks (e.g., `AUTH_FLOW,API_MIGRATION`) → **Disambiguate**: Determine which task or create new
|
|
46
|
+
|
|
47
|
+
**Legacy Migration:**
|
|
48
|
+
1. Read `PLAN.md`, extract main task theme
|
|
49
|
+
2. Generate task name (1-2 uppercase words with underscores)
|
|
50
|
+
3. Rename: `mv PLAN.md PLAN__<TASK>.md`
|
|
51
|
+
4. Continue as update mode
|
|
52
|
+
|
|
53
|
+
**Disambiguate (multiple PLAN files):**
|
|
54
|
+
1. List available tasks
|
|
55
|
+
2. Search recent ExitPlanMode/Write/Edit/TodoWrite for context clues
|
|
56
|
+
3. If clear match → proceed with that task
|
|
57
|
+
4. If ambiguous → ask user which task to update or create new
|
|
58
|
+
|
|
59
|
+
## Phase 2: Extract Plan & Evidence
|
|
60
|
+
|
|
61
|
+
### For Create Mode
|
|
62
|
+
|
|
63
|
+
⚠️ **ANTI-RECENCY BIAS WARNING**: Recent work dominates attention. The FIRST ExitPlanMode typically has the complete vision. Later calls often refine/narrow focus. You MUST document ALL work (completed, current, AND future).
|
|
64
|
+
|
|
65
|
+
**Extract plans:**
|
|
66
|
+
1. Find ALL ExitPlanMode calls: `"name":"ExitPlanMode","input":{"plan":"..."}`
|
|
67
|
+
2. Extract each in chronological order
|
|
68
|
+
3. **CRITICAL**: Read FIRST call for complete vision
|
|
69
|
+
4. **PRESERVE original structure** - if phases existed, use phases; if flat list, keep flat
|
|
70
|
+
5. **DO NOT invent structure** not in original
|
|
71
|
+
6. Synthesize complete plan ensuring ALL original items captured
|
|
72
|
+
7. Generate task name from main theme (1-2 uppercase words)
|
|
73
|
+
|
|
74
|
+
**Search for implementation evidence:**
|
|
75
|
+
1. Review activity after last ExitPlanMode
|
|
76
|
+
2. Find: Write/Edit/NotebookEdit/Bash/TodoWrite calls, completion phrases, confirmations
|
|
77
|
+
3. Map tasks to evidence via file paths and keywords
|
|
78
|
+
|
|
79
|
+
**Assign statuses:**
|
|
80
|
+
- Strong evidence (multiple indicators) → [DONE]
|
|
81
|
+
- Medium evidence (single indicator) → [IN PROGRESS]
|
|
82
|
+
- Weak/no evidence → [TODO]
|
|
83
|
+
|
|
84
|
+
### For Update Mode
|
|
85
|
+
|
|
86
|
+
1. Read `PLAN__<TASK>.md`, parse task hierarchy with statuses
|
|
87
|
+
2. Search recent activity for implementation evidence
|
|
88
|
+
3. Match tasks to evidence, assign status updates
|
|
89
|
+
4. Check for plan evolution: ExitPlanMode newer than PLAN file
|
|
90
|
+
5. Present findings if any tasks have evidence (skip if all TODO)
|
|
91
|
+
|
|
92
|
+
## Phase 3: Write or Update File
|
|
93
|
+
|
|
94
|
+
### Create Mode - Generate File
|
|
95
|
+
|
|
96
|
+
Structure (preserve original organization from ExitPlanMode):
|
|
97
|
+
- **Overview**: 1-2 paragraph summary
|
|
98
|
+
- **Scope**: Features, components, files, integrations
|
|
99
|
+
- **Purpose**: Problem, value, requirements, context
|
|
100
|
+
- **Implementation Details**: Hierarchical tasks with `[STATUS] description`
|
|
101
|
+
- Include file paths/names
|
|
102
|
+
- Nest with 3-space indentation
|
|
103
|
+
- Order: setup → implementation → testing
|
|
104
|
+
- Apply evidence-based statuses
|
|
105
|
+
|
|
106
|
+
Write to `{git_root}/PLAN__<TASK>.md` (NOT ~/.claude/plans/) and **validate**:
|
|
107
|
+
- Compare structure to FIRST ExitPlanMode call
|
|
108
|
+
- If original had phases, ensure all phases documented
|
|
109
|
+
- If original was flat list, ensure no invented phases
|
|
110
|
+
- Count items: original N items should match generated
|
|
111
|
+
- Future work documented as [TODO], not omitted
|
|
112
|
+
- Task name format valid (1-2 uppercase words, single underscores)
|
|
113
|
+
|
|
114
|
+
Report: file path, task count, structure type
|
|
115
|
+
|
|
116
|
+
### Update Mode - Modify Existing
|
|
117
|
+
|
|
118
|
+
Update `PLAN__<TASK>.md`:
|
|
119
|
+
- For each status change, use Edit tool
|
|
120
|
+
- Match exact old_string with indentation and status
|
|
121
|
+
- Replace with new status
|
|
122
|
+
- Preserve hierarchy and formatting
|
|
123
|
+
|
|
124
|
+
Handle plan evolution if detected:
|
|
125
|
+
- Add new areas to existing structure
|
|
126
|
+
- Insert new tasks under relevant parents
|
|
127
|
+
- Mark deprecated as `[CANCELLED - plan changed]`
|
|
128
|
+
- Update Scope/Purpose if changed
|
|
129
|
+
- Append to Plan Updates section with timestamp
|
|
130
|
+
|
|
131
|
+
Report: file path, X tasks completed, Y in progress, Z changes made
|
|
132
|
+
|
|
133
|
+
## Status Transitions & Evidence Strength
|
|
134
|
+
|
|
135
|
+
**Evidence Strength:**
|
|
136
|
+
- Strong: Multiple indicators → [DONE]
|
|
137
|
+
- Medium: Single indicator → [IN PROGRESS]
|
|
138
|
+
- Weak/None: Mention only → [TODO]
|
|
139
|
+
|
|
140
|
+
**Valid Status Labels:**
|
|
141
|
+
- [TODO] → Not started
|
|
142
|
+
- [IN PROGRESS] → Started not finished
|
|
143
|
+
- [DONE] → Completed
|
|
144
|
+
- [BLOCKED] → Cannot proceed (include reason)
|
|
145
|
+
- [CANCELLED - plan changed] → No longer relevant
|
|
146
|
+
|
|
147
|
+
## Critical Requirements
|
|
148
|
+
|
|
149
|
+
**All Modes:**
|
|
150
|
+
- Analyze session activity for evidence (tool calls + completion phrases)
|
|
151
|
+
- Match ALL tasks to evidence, assign statuses intelligently
|
|
152
|
+
- Include evidence-free tasks as [TODO] - never skip planned work
|
|
153
|
+
- Use 3-space indentation, preserve hierarchy
|
|
154
|
+
- Inform user of mode and target file
|
|
155
|
+
|
|
156
|
+
**Create Mode:**
|
|
157
|
+
- **PREVENT RECENCY BIAS**: Prioritize FIRST ExitPlanMode for complete vision
|
|
158
|
+
- **PRESERVE STRUCTURE**: Match original organization exactly
|
|
159
|
+
- Document entire plan regardless of implementation progress
|
|
160
|
+
- Support both complex multi-phase AND simple flat lists
|
|
161
|
+
- Generate valid task name, create `PLAN__<TASK>.md` in git root (NEVER in ~/.claude/plans/)
|
|
162
|
+
|
|
163
|
+
**Update Mode:**
|
|
164
|
+
- Use Edit tool with exact matching
|
|
165
|
+
- Handle evolution: add new, mark deprecated as cancelled
|
|
166
|
+
|
|
167
|
+
**Legacy Migration:**
|
|
168
|
+
- Detect `PLAN.md`, generate task name from content
|
|
169
|
+
- Rename using Bash `mv`, inform user of migration
|