ai-agent-rules 0.15.2__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.
- ai_agent_rules-0.15.2.dist-info/METADATA +451 -0
- ai_agent_rules-0.15.2.dist-info/RECORD +52 -0
- ai_agent_rules-0.15.2.dist-info/WHEEL +5 -0
- ai_agent_rules-0.15.2.dist-info/entry_points.txt +3 -0
- ai_agent_rules-0.15.2.dist-info/licenses/LICENSE +22 -0
- ai_agent_rules-0.15.2.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 +123 -0
- ai_rules/agents/cursor.py +70 -0
- ai_rules/agents/goose.py +47 -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 +279 -0
- ai_rules/bootstrap/updater.py +344 -0
- ai_rules/bootstrap/version.py +52 -0
- ai_rules/cli.py +2434 -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/CLAUDE.md +1 -0
- ai_rules/config/claude/agents/code-reviewer.md +121 -0
- ai_rules/config/claude/commands/agents-md.md +422 -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 +119 -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/cursor/keybindings.json +14 -0
- ai_rules/config/cursor/settings.json +81 -0
- ai_rules/config/goose/.goosehints +1 -0
- ai_rules/config/goose/config.yaml +55 -0
- ai_rules/config/profiles/default.yaml +6 -0
- ai_rules/config/profiles/work.yaml +11 -0
- ai_rules/config.py +644 -0
- ai_rules/display.py +40 -0
- ai_rules/mcp.py +369 -0
- ai_rules/profiles.py +187 -0
- ai_rules/symlinks.py +207 -0
- ai_rules/utils.py +35 -0
|
@@ -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
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Creates GitHub pull requests with comprehensive descriptions by analyzing git history and code changes
|
|
3
|
+
allowed-tools: AskUserQuestion, Bash, Glob, Grep, Read, TodoWrite
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Context
|
|
8
|
+
|
|
9
|
+
- Project: !`git rev-parse --show-toplevel 2>/dev/null || echo "NOT_IN_GIT_REPO"`
|
|
10
|
+
- Current branch: !`git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "NO_BRANCH"`
|
|
11
|
+
- Base branch: !`git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main"`
|
|
12
|
+
- Uncommitted changes: !`git status --porcelain 2>/dev/null | wc -l | xargs`
|
|
13
|
+
- Remote status: !`git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null || echo "NOT_PUSHED"`
|
|
14
|
+
- Commits ahead: !`git rev-list --count @{u}..HEAD 2>/dev/null || echo "0"`
|
|
15
|
+
|
|
16
|
+
# Create GitHub Pull Request
|
|
17
|
+
|
|
18
|
+
**Usage:**
|
|
19
|
+
- `/pr-creator` - Create regular pull request
|
|
20
|
+
- `/pr-creator draft` - Create draft pull request
|
|
21
|
+
|
|
22
|
+
You are an expert software engineer creating high-quality PR descriptions that facilitate efficient code review. All feature changes are already committed to the local feature branch.
|
|
23
|
+
|
|
24
|
+
## Pre-flight Checks
|
|
25
|
+
|
|
26
|
+
**Validate environment:**
|
|
27
|
+
1. Check "Project" - if "NOT_IN_GIT_REPO", stop and inform user
|
|
28
|
+
2. Check "Current branch" - if "NO_BRANCH", stop and inform user
|
|
29
|
+
3. Check "Uncommitted changes" - if > 0, warn user and ask to continue
|
|
30
|
+
|
|
31
|
+
## Stage 1: Analyze & Generate Draft
|
|
32
|
+
|
|
33
|
+
### Step 1: Determine PR Type & Detect Draft Mode
|
|
34
|
+
|
|
35
|
+
**Check command argument:**
|
|
36
|
+
- If `$1` equals "draft" → set flag to create draft PR
|
|
37
|
+
- Default (empty or other value) → create regular PR
|
|
38
|
+
|
|
39
|
+
**Analyze commits to classify PR type:**
|
|
40
|
+
```bash
|
|
41
|
+
git log origin/{base-branch}..HEAD --format="%s"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Match commit patterns to type:
|
|
45
|
+
- **Feature**: "feat:", "add", "implement", "create", new functionality
|
|
46
|
+
- **Fix**: "fix:", "bug", "resolve", "patch", corrects issues
|
|
47
|
+
- **Refactor**: "refactor:", "restructure", "clean up", improves without behavior change
|
|
48
|
+
- **Docs**: "docs:", changes primarily to *.md or documentation
|
|
49
|
+
- **Test**: "test:", additions/improvements to test files
|
|
50
|
+
- **Chore**: "chore:", maintenance, dependency updates, config changes
|
|
51
|
+
|
|
52
|
+
### Step 2: Gather Comprehensive Information
|
|
53
|
+
|
|
54
|
+
**Inspect changes:**
|
|
55
|
+
```bash
|
|
56
|
+
# All commits not in base branch
|
|
57
|
+
git log origin/{base-branch}..HEAD
|
|
58
|
+
|
|
59
|
+
# Complete scope of changes
|
|
60
|
+
git diff origin/{base-branch}...HEAD --stat
|
|
61
|
+
|
|
62
|
+
# Detailed code changes
|
|
63
|
+
git diff origin/{base-branch}...HEAD
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Look for:**
|
|
67
|
+
- GitHub issue references in commits or code comments
|
|
68
|
+
- Breaking changes or API modifications
|
|
69
|
+
- New dependencies or configuration changes
|
|
70
|
+
- Security-relevant changes (auth, validation, data handling)
|
|
71
|
+
- Performance implications (algorithms, database queries, caching)
|
|
72
|
+
|
|
73
|
+
### Step 3: Assess Complexity
|
|
74
|
+
|
|
75
|
+
**Calculate complexity indicators:**
|
|
76
|
+
```bash
|
|
77
|
+
# Lines changed
|
|
78
|
+
git diff origin/{base-branch}...HEAD --shortstat
|
|
79
|
+
|
|
80
|
+
# Files modified
|
|
81
|
+
git diff origin/{base-branch}...HEAD --name-only | wc -l
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Complexity guidance:**
|
|
85
|
+
- Lines >500 → Suggest splitting into smaller PRs
|
|
86
|
+
- Files >10 → Add file navigation guide to description
|
|
87
|
+
- Multiple unrelated concerns → Recommend separate PRs
|
|
88
|
+
|
|
89
|
+
### Step 4: Generate Draft Description
|
|
90
|
+
|
|
91
|
+
**Structure based on PR type:**
|
|
92
|
+
|
|
93
|
+
**Opening paragraph** (1-2 sentences):
|
|
94
|
+
- Start with "This PR [enables/adds/fixes/updates/refactors]..."
|
|
95
|
+
- State what changed and the value/benefit delivered
|
|
96
|
+
- Focus on user-facing or technical value
|
|
97
|
+
|
|
98
|
+
**Context paragraph** (2-4 sentences):
|
|
99
|
+
- Explain the problem or "before this change" state
|
|
100
|
+
- Help reviewers understand WHY this change was needed
|
|
101
|
+
- Provide relevant background informing implementation decisions
|
|
102
|
+
|
|
103
|
+
**Implementation details** (3-5 bulleted items):
|
|
104
|
+
- Use plain bullets (-)
|
|
105
|
+
- Include concrete names: functions, classes, fields, patterns, files
|
|
106
|
+
- Focus on HOW the solution was implemented
|
|
107
|
+
- One line per bullet, specific and technical
|
|
108
|
+
- Highlight key technical decisions or approaches
|
|
109
|
+
|
|
110
|
+
**Review-friendly additions** (when applicable):
|
|
111
|
+
- **Breaking Changes**: Clearly flag if API changes break compatibility
|
|
112
|
+
- **Testing Instructions**: Steps to manually verify (for complex features)
|
|
113
|
+
- **Security Notes**: Call out security-relevant changes
|
|
114
|
+
- **Performance Impact**: Note if this affects performance significantly
|
|
115
|
+
|
|
116
|
+
**Issue references** (if found):
|
|
117
|
+
```
|
|
118
|
+
Fixes #123
|
|
119
|
+
Relates to #456
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Step 5: Present Draft & STOP
|
|
123
|
+
|
|
124
|
+
Present the draft description to user and **STOP**. You must wait for explicit approval.
|
|
125
|
+
|
|
126
|
+
When presenting:
|
|
127
|
+
- Indicate if this will be draft PR or regular PR
|
|
128
|
+
- Show complexity assessment if lines >300 or files >7
|
|
129
|
+
- Ask if user wants to proceed or revise description
|
|
130
|
+
|
|
131
|
+
## Stage 2: Create Pull Request
|
|
132
|
+
|
|
133
|
+
**Only proceed after receiving explicit user approval.**
|
|
134
|
+
|
|
135
|
+
### Verification Steps
|
|
136
|
+
|
|
137
|
+
1. **Check for PLAN files** that shouldn't be pushed:
|
|
138
|
+
```bash
|
|
139
|
+
# Check if PLAN files in commits
|
|
140
|
+
git log origin/{base}..HEAD --name-only --pretty=format: | grep -q "^PLAN"
|
|
141
|
+
|
|
142
|
+
# Check if PLAN files currently tracked
|
|
143
|
+
git ls-files | grep -q "^PLAN"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
If PLAN files found:
|
|
147
|
+
- STOP immediately with clear error
|
|
148
|
+
- Explain these are development docs (from /dev-docs) that shouldn't be in PRs
|
|
149
|
+
- Provide remediation:
|
|
150
|
+
- Option 1: Remove PLAN files and amend/rebase commits
|
|
151
|
+
- Option 2: Create clean branch without PLAN files
|
|
152
|
+
- Remind to exclude PLAN files before committing
|
|
153
|
+
|
|
154
|
+
2. **Ensure branch pushed to remote:**
|
|
155
|
+
```bash
|
|
156
|
+
# Check "Remote status" from Context
|
|
157
|
+
# If "NOT_PUSHED":
|
|
158
|
+
git push -u origin HEAD
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Create PR
|
|
162
|
+
|
|
163
|
+
**Extract title** from opening paragraph (concise, 50-70 chars)
|
|
164
|
+
|
|
165
|
+
**Create PR** using appropriate command:
|
|
166
|
+
|
|
167
|
+
Regular PR:
|
|
168
|
+
```bash
|
|
169
|
+
gh pr create --title "Brief PR title" --base {base-branch} --body "$(cat <<'EOF'
|
|
170
|
+
[Full approved PR description]
|
|
171
|
+
EOF
|
|
172
|
+
)"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Draft PR:
|
|
176
|
+
```bash
|
|
177
|
+
gh pr create --title "Brief PR title" --base {base-branch} --draft --body "$(cat <<'EOF'
|
|
178
|
+
[Full approved PR description]
|
|
179
|
+
EOF
|
|
180
|
+
)"
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Display PR URL** to user upon success
|
|
184
|
+
|
|
185
|
+
## PR Description Guidelines
|
|
186
|
+
|
|
187
|
+
**Formatting:**
|
|
188
|
+
- Use plain prose (no bold/headers in body)
|
|
189
|
+
- Use plain bullets (-) for implementation details
|
|
190
|
+
- One line per bullet
|
|
191
|
+
- Total length: 8-15 lines (complex PRs may be 15-20 with review sections)
|
|
192
|
+
- Issue references at bottom, separated by blank line
|
|
193
|
+
- Use GitHub autolink: `Fixes #123` or `Relates to #123`
|
|
194
|
+
|
|
195
|
+
**Tone & Style:**
|
|
196
|
+
- Professional but conversational
|
|
197
|
+
- Focus on "why" and "how" over "what"
|
|
198
|
+
- Use specific technical terms and names
|
|
199
|
+
- Avoid marketing language or superlatives
|
|
200
|
+
- Write for engineer reviewers needing context quickly
|
|
201
|
+
|
|
202
|
+
**Content:**
|
|
203
|
+
- Base all content on actual git history and code inspection
|
|
204
|
+
- Never guess or fabricate information
|
|
205
|
+
- Include concrete technical details (function/class names, patterns)
|
|
206
|
+
- Explain reasoning behind implementation choices
|
|
207
|
+
- Reference relevant issues when applicable
|
|
208
|
+
|
|
209
|
+
**Review Optimization:**
|
|
210
|
+
- Flag breaking changes prominently
|
|
211
|
+
- Add testing instructions for complex features
|
|
212
|
+
- Highlight security-relevant changes
|
|
213
|
+
- Note performance implications
|
|
214
|
+
- Suggest navigation for large PRs
|
|
215
|
+
|
|
216
|
+
## Critical Requirements
|
|
217
|
+
|
|
218
|
+
**Approval Gate:**
|
|
219
|
+
- NEVER skip user approval of draft description
|
|
220
|
+
- ALWAYS present draft and wait for explicit confirmation
|
|
221
|
+
- Accept and incorporate revision requests
|
|
222
|
+
- Only proceed to PR creation after clear approval
|
|
223
|
+
|
|
224
|
+
**Accuracy:**
|
|
225
|
+
- Inspect actual commits using git commands
|
|
226
|
+
- Review real code changes via git diff
|
|
227
|
+
- Do not rely solely on commit messages
|
|
228
|
+
- Verify issue references exist in code or commits
|
|
229
|
+
|
|
230
|
+
**Structure:**
|
|
231
|
+
- Follow 3-section format (opening, context, implementation)
|
|
232
|
+
- Maintain 8-15 line length guideline (up to 20 for complex PRs)
|
|
233
|
+
- Use proper formatting for issue references
|
|
234
|
+
- Add review-friendly sections when applicable
|
|
235
|
+
|
|
236
|
+
**Branch Management:**
|
|
237
|
+
- Verify branch pushed to remote before creating PR
|
|
238
|
+
- Use `git push -u origin HEAD` if needed
|
|
239
|
+
- Confirm base branch correct (from Context)
|
|
240
|
+
- Block PRs containing PLAN files
|
|
241
|
+
|
|
242
|
+
**Formatting:**
|
|
243
|
+
- Always use HEREDOC in `gh pr create --body` to preserve formatting
|
|
244
|
+
- Ensure proper line breaks and bullet formatting
|
|
245
|
+
- Include blank line before issue references
|
|
246
|
+
|
|
247
|
+
Your goal is to create PR descriptions that make code review efficient and thorough, providing reviewers with all context needed to understand and evaluate the changes quickly.
|