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.
Files changed (52) hide show
  1. ai_agent_rules-0.15.2.dist-info/METADATA +451 -0
  2. ai_agent_rules-0.15.2.dist-info/RECORD +52 -0
  3. ai_agent_rules-0.15.2.dist-info/WHEEL +5 -0
  4. ai_agent_rules-0.15.2.dist-info/entry_points.txt +3 -0
  5. ai_agent_rules-0.15.2.dist-info/licenses/LICENSE +22 -0
  6. ai_agent_rules-0.15.2.dist-info/top_level.txt +1 -0
  7. ai_rules/__init__.py +8 -0
  8. ai_rules/agents/__init__.py +1 -0
  9. ai_rules/agents/base.py +68 -0
  10. ai_rules/agents/claude.py +123 -0
  11. ai_rules/agents/cursor.py +70 -0
  12. ai_rules/agents/goose.py +47 -0
  13. ai_rules/agents/shared.py +35 -0
  14. ai_rules/bootstrap/__init__.py +75 -0
  15. ai_rules/bootstrap/config.py +261 -0
  16. ai_rules/bootstrap/installer.py +279 -0
  17. ai_rules/bootstrap/updater.py +344 -0
  18. ai_rules/bootstrap/version.py +52 -0
  19. ai_rules/cli.py +2434 -0
  20. ai_rules/completions.py +194 -0
  21. ai_rules/config/AGENTS.md +249 -0
  22. ai_rules/config/chat_agent_hints.md +1 -0
  23. ai_rules/config/claude/CLAUDE.md +1 -0
  24. ai_rules/config/claude/agents/code-reviewer.md +121 -0
  25. ai_rules/config/claude/commands/agents-md.md +422 -0
  26. ai_rules/config/claude/commands/annotate-changelog.md +191 -0
  27. ai_rules/config/claude/commands/comment-cleanup.md +161 -0
  28. ai_rules/config/claude/commands/continue-crash.md +38 -0
  29. ai_rules/config/claude/commands/dev-docs.md +169 -0
  30. ai_rules/config/claude/commands/pr-creator.md +247 -0
  31. ai_rules/config/claude/commands/test-cleanup.md +244 -0
  32. ai_rules/config/claude/commands/update-docs.md +324 -0
  33. ai_rules/config/claude/hooks/subagentStop.py +92 -0
  34. ai_rules/config/claude/mcps.json +1 -0
  35. ai_rules/config/claude/settings.json +119 -0
  36. ai_rules/config/claude/skills/doc-writer/SKILL.md +293 -0
  37. ai_rules/config/claude/skills/doc-writer/resources/templates.md +495 -0
  38. ai_rules/config/claude/skills/prompt-engineer/SKILL.md +272 -0
  39. ai_rules/config/claude/skills/prompt-engineer/resources/prompt_engineering_guide_2025.md +855 -0
  40. ai_rules/config/claude/skills/prompt-engineer/resources/templates.md +232 -0
  41. ai_rules/config/cursor/keybindings.json +14 -0
  42. ai_rules/config/cursor/settings.json +81 -0
  43. ai_rules/config/goose/.goosehints +1 -0
  44. ai_rules/config/goose/config.yaml +55 -0
  45. ai_rules/config/profiles/default.yaml +6 -0
  46. ai_rules/config/profiles/work.yaml +11 -0
  47. ai_rules/config.py +644 -0
  48. ai_rules/display.py +40 -0
  49. ai_rules/mcp.py +369 -0
  50. ai_rules/profiles.py +187 -0
  51. ai_rules/symlinks.py +207 -0
  52. ai_rules/utils.py +35 -0
@@ -0,0 +1,244 @@
1
+ ---
2
+ description: Audit and optimize test suite by removing trivial tests and consolidating valuable ones
3
+ allowed-tools: AskUserQuestion, Bash, Edit, Glob, Grep, Read, TodoWrite, Write
4
+ model: inherit
5
+ ---
6
+
7
+ ## Context
8
+
9
+ - Project root: !`git rev-parse --show-toplevel 2>/dev/null || pwd`
10
+ - Test framework: !`[ -f package.json ] && grep -E '"(test|jest|mocha|vitest)"' package.json | head -1 || [ -f pytest.ini ] && echo "pytest" || [ -f go.mod ] && echo "go test" || echo "unknown"`
11
+ - Test file count: !`find . -type f \( -name "*test*" -o -name "*spec*" \) 2>/dev/null | wc -l`
12
+ - Test execution time: !`[ -f package.json ] && npm test -- --listTests 2>/dev/null | wc -l || echo "N/A"`
13
+ - Coverage config: !`[ -f .coveragerc ] && echo "Python coverage" || [ -f jest.config.js ] && echo "Jest coverage" || [ -f .nycrc ] && echo "NYC coverage" || echo "No coverage config"`
14
+ - Recent test failures: !`git log --grep="test\|fix" --oneline -10 2>/dev/null | head -5`
15
+
16
+ # Test Suite Optimization
17
+
18
+ Perform comprehensive audit of all tests in the codebase to identify opportunities for consolidation, refactoring, or removal. Focus on maximizing test value while minimizing maintenance burden.
19
+
20
+ ## Test Value Framework
21
+
22
+ Classify each test using this hierarchy:
23
+
24
+ **1. Critical (MUST KEEP)**
25
+ - Business logic with multiple code paths
26
+ - Security boundaries (authentication, authorization, input validation)
27
+ - Data integrity checks (transactions, constraints)
28
+ - User-facing functionality that directly impacts users
29
+ - Integration points with external systems
30
+ - Financial calculations or regulatory compliance logic
31
+
32
+ **2. Valuable (KEEP)**
33
+ - Error handling for external dependencies
34
+ - Edge cases with production impact history
35
+ - State transitions in complex workflows
36
+ - API contract validation
37
+ - Performance regression detection
38
+ - Cross-cutting concerns (logging, monitoring)
39
+
40
+ **3. Questionable (EVALUATE)**
41
+ - Simple getters/setters with no logic
42
+ - Framework functionality already tested by framework
43
+ - Tests with >80% mocking (testing mocks, not code)
44
+ - Overly coupled to implementation details
45
+ - Duplicate coverage of same behavior
46
+
47
+ **4. Trivial (REMOVE)**
48
+ - Testing language features (e.g., "JavaScript can add numbers")
49
+ - Testing third-party libraries (e.g., "axios makes HTTP requests")
50
+ - Tests that never fail (always pass regardless of implementation)
51
+ - Generated tests with no assertions
52
+ - Tests verifying constants or configuration values
53
+
54
+ ## Systematic Audit Process
55
+
56
+ ### Phase 1: Inventory
57
+
58
+ **Review metrics from Context above:**
59
+ - Test framework, file count, and coverage config are pre-loaded
60
+ - Measure execution time using the detected test framework
61
+ - Run coverage report if coverage config exists
62
+
63
+ **Categorize tests:**
64
+ - Unit tests (test individual functions/classes)
65
+ - Integration tests (test multiple components together)
66
+ - E2E tests (test full user workflows)
67
+ - Performance tests
68
+ - Contract/API tests
69
+
70
+ ### Phase 2: Analysis
71
+
72
+ Apply decision framework to each test. For every test, ask:
73
+
74
+ **1. What business rule does this validate?**
75
+ - If answer is "none" or unclear → REMOVE
76
+
77
+ **2. Has this test ever caught a real bug?**
78
+ - Check git history for test failures in CI
79
+ - If always passes → QUESTIONABLE
80
+
81
+ **3. Does this test document important behavior?**
82
+ - Would removing it make system behavior unclear? → KEEP
83
+ - Is it redundant with other tests? → CONSOLIDATE
84
+
85
+ **4. Would removing this test increase risk?**
86
+ - High risk area (payments, auth, data loss) → KEEP
87
+ - Low risk area (UI formatting, logs) → EVALUATE
88
+
89
+ **Identify patterns:**
90
+ - Repeated test setup → Consolidate into shared fixtures
91
+ - Multiple tests for same behavior → Merge into single comprehensive test
92
+ - Tests with zero assertions → Remove
93
+ - Tests that mock everything → Reconsider if testing anything real
94
+
95
+ ### Phase 3: Optimization Actions
96
+
97
+ **For REMOVE candidates:**
98
+ 1. Verify test provides no unique value
99
+ 2. Confirm other tests cover the behavior (if any)
100
+ 3. Delete test and unused fixtures/helpers
101
+ 4. Run full test suite to confirm no gaps
102
+
103
+ **For CONSOLIDATE candidates:**
104
+ 1. Identify overlapping test coverage
105
+ 2. Create single comprehensive test covering all cases
106
+ 3. Remove individual redundant tests
107
+ 4. Verify consolidated test provides same coverage
108
+
109
+ **For REFACTOR candidates:**
110
+ 1. Extract repeated setup to shared fixtures
111
+ 2. Replace implementation testing with behavior testing
112
+ 3. Reduce mocking to essential external dependencies only
113
+ 4. Simplify assertions to focus on outcomes, not internals
114
+
115
+ **For KEEP candidates:**
116
+ 1. Verify test is maintainable and clear
117
+ 2. Ensure test runs quickly (flag slow tests >1s)
118
+ 3. Check test has clear failure messages
119
+ 4. Document why test is important if non-obvious
120
+
121
+ ### Phase 4: Execute Changes
122
+
123
+ **Process systematically:**
124
+ 1. Start with obvious REMOVE candidates (fastest wins)
125
+ 2. Consolidate related tests (reduce duplication)
126
+ 3. Refactor questionable tests (improve quality)
127
+ 4. Run tests after each batch of changes
128
+ 5. Monitor coverage to ensure no gaps introduced
129
+
130
+ **Track progress:**
131
+ - Count tests before/after
132
+ - Measure execution time improvement
133
+ - Verify coverage maintained or improved
134
+ - Document any intentional coverage gaps
135
+
136
+ ### Phase 5: Validation
137
+
138
+ **Run comprehensive checks:**
139
+ ```bash
140
+ # Full test suite
141
+ npm test
142
+
143
+ # Coverage report
144
+ npm run coverage
145
+
146
+ # Linter (might catch unused imports/fixtures)
147
+ npm run lint
148
+
149
+ # Type checking (if applicable)
150
+ npm run type-check
151
+ ```
152
+
153
+ **Verify metrics:**
154
+ - Test count reduced by removing trivial tests
155
+ - Execution time improved (target: 20-30% faster)
156
+ - Coverage of critical paths maintained (≥80% for business logic)
157
+ - No new test failures introduced
158
+
159
+ ## Decision Criteria Examples
160
+
161
+ **Remove:**
162
+ ```python
163
+ # Testing Python language feature
164
+ def test_list_append():
165
+ lst = []
166
+ lst.append(1)
167
+ assert len(lst) == 1 # Python lists work!
168
+
169
+ # Testing framework functionality
170
+ def test_mock_called():
171
+ mock = Mock()
172
+ mock()
173
+ assert mock.called # Mocks work!
174
+ ```
175
+
176
+ **Keep:**
177
+ ```python
178
+ # Testing business logic
179
+ def test_discount_calculation_with_coupon():
180
+ cart = Cart(items=[Item(price=100)])
181
+ cart.apply_coupon("SAVE20")
182
+ assert cart.total() == 80 # Business rule: 20% discount
183
+
184
+ # Testing security boundary
185
+ def test_unauthorized_access_denied():
186
+ response = api.delete("/user/123", auth=None)
187
+ assert response.status == 403 # Security: require auth
188
+ ```
189
+
190
+ **Consolidate:**
191
+ ```python
192
+ # Before: 3 separate tests
193
+ def test_user_creation_with_valid_email(): ...
194
+ def test_user_creation_with_name(): ...
195
+ def test_user_creation_stores_timestamp(): ...
196
+
197
+ # After: 1 comprehensive test
198
+ def test_user_creation_with_all_fields():
199
+ user = create_user(email="test@example.com", name="Test")
200
+ assert user.email == "test@example.com"
201
+ assert user.name == "Test"
202
+ assert user.created_at is not None
203
+ ```
204
+
205
+ ## Common Pitfalls to Avoid
206
+
207
+ - **Don't remove tests that caught bugs in the past**: Check git history
208
+ - **Don't reduce coverage of critical paths**: Maintain ≥80% for business logic
209
+ - **Don't remove tests just because they're slow**: Optimize instead
210
+ - **Don't delete edge case tests**: They often prevent regression
211
+ - **Don't remove integration tests in favor of unit tests**: Both have value
212
+
213
+ ## Success Metrics
214
+
215
+ After optimization, verify:
216
+ ✓ Test suite runs 20-30% faster
217
+ ✓ Zero trivial tests remain (language features, framework tests)
218
+ ✓ Critical path coverage maintained (≥80%)
219
+ ✓ All remaining tests have clear purpose
220
+ ✓ Test failures provide actionable error messages
221
+ ✓ Reduced maintenance burden (fewer brittle tests)
222
+
223
+ ## Reporting
224
+
225
+ Provide summary after completion:
226
+ ```
227
+ Test Optimization Complete
228
+
229
+ Metrics:
230
+ - Tests removed: X (Y% reduction)
231
+ - Tests consolidated: Z groups
232
+ - Execution time: Before Xs → After Ys (Z% improvement)
233
+ - Coverage: Maintained at N%
234
+
235
+ Categories removed:
236
+ - Trivial tests: X
237
+ - Framework tests: Y
238
+ - Implementation-only tests: Z
239
+
240
+ All tests passing: ✓
241
+ Coverage maintained: ✓
242
+ ```
243
+
244
+ Your goal is to create a lean, valuable test suite that focuses on critical business logic and system integration while removing tests that provide no real protection against bugs.
@@ -0,0 +1,324 @@
1
+ ---
2
+ description: Automatically updates project documentation by analyzing recent commits and detecting changes
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
+ - Current branch: !`git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "NO_BRANCH"`
11
+ - Recent commits: !`git log --oneline -10 2>/dev/null || echo "NO_COMMITS"`
12
+ - Documentation files: !`find . -maxdepth 3 -type f \( -name "README*" -o -name "ARCHITECTURE*" -o -name "CONTRIBUTING*" \) 2>/dev/null | head -10`
13
+ - Last commit message: !`git log -1 --format="%s" 2>/dev/null || echo "NO_COMMITS"`
14
+
15
+ # Update Project Documentation
16
+
17
+ **Usage:**
18
+ - `/update-docs` - Analyze recent commits and update all relevant documentation
19
+
20
+ Automatically updates project documentation after code changes by intelligently analyzing recent commits, detecting what changed, and updating relevant documentation files while preserving existing style and structure.
21
+
22
+ ## Five-Phase Methodology
23
+
24
+ ### Phase 1: Change Analysis & Scope Detection
25
+
26
+ **Explore recent commit history:**
27
+ 1. Review "Recent commits" from Context above
28
+ 2. Identify the most recent logical grouping of related changes
29
+
30
+ **Commit Grouping Heuristics:**
31
+
32
+ Use these indicators to determine which commits form a cohesive logical unit:
33
+
34
+ **Related commits (include in same group):**
35
+ - Commit messages with same feature prefix (e.g., "add auth flow", "fix auth bug", "test auth")
36
+ - High file overlap (>50% of changed files appear in multiple commits)
37
+ - Temporal proximity (commits within same day or few hours)
38
+ - Sequential references to same feature, issue number, or component
39
+
40
+ **Separate logical units (stop grouping):**
41
+ - Different feature/component prefixes in messages
42
+ - No file overlap between commits
43
+ - Large time gaps (days or weeks apart)
44
+ - Clearly distinct functional areas
45
+
46
+ **Example decision:**
47
+ ```
48
+ Commits:
49
+ 1. "add config set-default-profile command" (1h ago, modified: cli.py, config.py)
50
+ 2. "add config file persistence" (50min ago, modified: config.py, README.md)
51
+ 3. "add tests for default profile" (45min ago, modified: test_config.py)
52
+ 4. "fix typo in help text" (40min ago, modified: cli.py)
53
+ 5. "update dependencies" (2 days ago, modified: requirements.txt)
54
+
55
+ → Group commits 1-4 as "default profile feature"
56
+ → Exclude commit 5 (different feature, time gap)
57
+ ```
58
+
59
+ **Analyze combined changes:**
60
+
61
+ Once scope determined, get full diff for the commit group:
62
+ ```bash
63
+ # For single commit
64
+ git show <commit-hash>
65
+
66
+ # For multiple commits (e.g., last 4)
67
+ git log -4 --format="%h %s"
68
+ git diff HEAD~4..HEAD
69
+ ```
70
+
71
+ **Detect change patterns using this table:**
72
+
73
+ | Pattern in Code | Feature Type | Documentation Impact |
74
+ |-----------------|--------------|---------------------|
75
+ | `@click.command()`, `@app.command()` | CLI command | CLI reference, examples |
76
+ | `argparse.add_argument()`, `add_parser()` | CLI argument | CLI reference, usage |
77
+ | `@app.route()`, `@router.get()` | API endpoint | API reference, integration guide |
78
+ | `FastAPI()`, `APIRouter()` | API changes | API docs, OpenAPI spec |
79
+ | Function signature changed | Breaking change | Migration guide, changelog |
80
+ | New YAML/TOML/JSON keys in schema | Configuration | Config reference, examples |
81
+ | `deprecated`, `@deprecated` | Deprecation | Deprecation notice, migration path |
82
+ | New class in public API | New feature | API reference, examples |
83
+ | Removed public function/class | Breaking change | Migration guide, what to use instead |
84
+
85
+ **Parse commit messages for type:**
86
+ - `feat:`, "add", "implement", "create" → New feature
87
+ - `fix:`, "bug", "resolve", "patch" → Bug fix
88
+ - `refactor:`, "restructure", "clean up" → Refactoring
89
+ - `breaking:`, "BREAKING CHANGE:" → Breaking change
90
+ - `docs:` → Documentation only (skip updating docs for docs changes)
91
+
92
+ ### Phase 2: Documentation Discovery
93
+
94
+ **Auto-discover documentation files:**
95
+
96
+ Search for documentation using these patterns (prioritized):
97
+
98
+ 1. **Root-level user docs** (highest priority):
99
+ - `README.md`, `README.rst`, `README.txt`
100
+ - `GETTING_STARTED.md`, `QUICKSTART.md`
101
+
102
+ 2. **Root-level developer docs**:
103
+ - `ARCHITECTURE.md`, `DESIGN.md`
104
+ - `CONTRIBUTING.md`, `DEVELOPMENT.md`
105
+ - `CHANGELOG.md`, `CHANGES.md`
106
+
107
+ 3. **Documentation directories**:
108
+ - `docs/*.md`, `doc/*.md`
109
+ - `docs/api/*.md`, `docs/cli/*.md`
110
+ - `.github/*.md`
111
+
112
+ 4. **Project-specific** (if they exist):
113
+ - `PLAN*.md` (but check if used for development planning)
114
+ - Any files mentioned in commit messages
115
+
116
+ **Check Context above for "Documentation files"** - these are pre-discovered.
117
+
118
+ **Prioritize by documentation type:**
119
+ 1. User-facing (README, getting started) - most critical
120
+ 2. CLI/API reference sections - document interfaces
121
+ 3. Developer docs (ARCHITECTURE, CONTRIBUTING) - technical details
122
+ 4. Examples and tutorials - illustrate usage
123
+
124
+ ### Phase 3: Impact Analysis
125
+
126
+ **Map detected changes to documentation sections:**
127
+
128
+ Use this decision table to determine what needs updating:
129
+
130
+ | Change Type | README | ARCHITECTURE | CONTRIBUTING | docs/ | Priority |
131
+ |-------------|--------|--------------|--------------|-------|----------|
132
+ | New CLI command | CLI reference, Quick start | - | - | CLI guide | CRITICAL |
133
+ | New CLI argument | CLI reference, Usage | - | - | CLI guide | CRITICAL |
134
+ | New API endpoint | API overview | API architecture | - | API reference | CRITICAL |
135
+ | Breaking change | Upgrade notes, Breaking changes section | System changes | - | Migration guide | CRITICAL |
136
+ | New config option | Configuration section | Config system | - | Config reference | IMPORTANT |
137
+ | Deprecated feature | Deprecation notice | - | - | Migration guide | IMPORTANT |
138
+ | Performance improvement | Changelog, Performance section | Implementation | - | - | IMPORTANT |
139
+ | Bug fix (behavior change) | Changelog | - | - | - | IMPORTANT |
140
+ | Bug fix (no behavior change) | Changelog only | - | - | - | SKIP |
141
+ | Internal refactor | - | - | - | - | SKIP |
142
+
143
+ **Build update plan:**
144
+ 1. List all documentation files needing updates
145
+ 2. For each file, identify specific sections to modify
146
+ 3. Prioritize by CRITICAL → IMPORTANT → SKIP
147
+
148
+ ### Phase 4: Style-Preserving Documentation Updates
149
+
150
+ **Before making any changes:**
151
+
152
+ For each documentation file to update:
153
+
154
+ 1. **Analyze existing style** (read first 500 lines):
155
+ - Tone: Formal/technical vs casual/accessible
156
+ - Structure: Heading levels (# ## ###), section organization
157
+ - Formatting: Code block language tags, list style (-, *, 1.), table usage
158
+ - Example patterns: Inline examples vs separate files, comment style in code blocks
159
+
160
+ 2. **Identify update strategy**:
161
+ - **Insert**: Add new section for new feature (preserve structure)
162
+ - **Update**: Modify existing section (match formatting)
163
+ - **Append**: Add to list (match list style: -, *, or numbered)
164
+ - **Replace**: Outdated info (preserve tone and format)
165
+
166
+ **Make minimal invasive edits:**
167
+
168
+ For each update, use the Edit tool to:
169
+ - Insert new content into existing sections (don't restructure)
170
+ - Update examples to match new behavior (preserve example format)
171
+ - Preserve cross-references and internal links
172
+ - Match existing writing style, tone, and voice
173
+ - Keep same heading hierarchy and conventions
174
+
175
+ **Examples of style matching:**
176
+
177
+ ```markdown
178
+ # Existing style (casual, emoji, short sentences)
179
+ ## Commands
180
+
181
+ Use these commands:
182
+ - 🚀 `app start` - Start the app
183
+ - 🛑 `app stop` - Stop it
184
+
185
+ # Match this style when adding:
186
+ - ⚙️ `app config` - Configure settings
187
+ ```
188
+
189
+ ```markdown
190
+ # Existing style (formal, technical, detailed)
191
+ ### Command Reference
192
+
193
+ #### start
194
+ Initializes the application server and begins listening for incoming requests on the configured port (default: 8080).
195
+
196
+ # Match this style when adding:
197
+ #### configure
198
+ Modifies application configuration settings, persisting changes to the local configuration file (~/.app/config.toml). Accepts key-value pairs via command-line arguments.
199
+ ```
200
+
201
+ **What NOT to do:**
202
+ - Don't add features not requested or clearly necessary
203
+ - Don't restructure existing documentation
204
+ - Don't change the tone (formal → casual or vice versa)
205
+ - Don't add verbose descriptions if existing docs are concise
206
+ - Don't remove existing content unless it's deprecated/wrong
207
+
208
+ ### Phase 5: Verification & Summary
209
+
210
+ **Verify completeness:**
211
+
212
+ After all updates, check:
213
+ - [ ] All significant changes from Phase 1 are documented
214
+ - [ ] Deprecated features removed or marked as deprecated
215
+ - [ ] All examples updated to match new behavior
216
+ - [ ] Cross-references still valid (no broken links to removed sections)
217
+ - [ ] Consistent style maintained throughout each file
218
+ - [ ] No orphaned sections (sections referencing removed features)
219
+
220
+ **Generate summary report:**
221
+
222
+ Provide user with:
223
+ ```
224
+ Documentation Updated - Summary
225
+
226
+ Scope Analyzed:
227
+ - Commits: <N> commits from <oldest> to <newest>
228
+ - Feature: <brief description of logical grouping>
229
+ - Changes detected: <list of key changes>
230
+
231
+ Files Updated:
232
+ - <file1>: <what was updated>
233
+ - <file2>: <what was updated>
234
+
235
+ Verification:
236
+ ✓ All new features documented
237
+ ✓ Examples updated
238
+ ✓ Style preserved
239
+ ✓ Cross-references valid
240
+
241
+ Review changes: git diff
242
+ ```
243
+
244
+ ## Prioritization Framework
245
+
246
+ Use this framework to decide what to document:
247
+
248
+ **Critical (Must Document)**:
249
+ - New user-facing features (CLI commands, API endpoints)
250
+ - Breaking changes requiring migration
251
+ - Security-related changes (authentication, authorization, data handling)
252
+ - Changed behavior for existing features
253
+ - New required configuration
254
+
255
+ **Important (Should Document)**:
256
+ - New optional configuration
257
+ - Performance improvements with visible user impact
258
+ - Behavior-changing bug fixes (even if fixing a bug)
259
+ - New developer-facing features (build tools, dev commands)
260
+ - Enhanced error messages that users will see
261
+
262
+ **Skip (Don't Document)**:
263
+ - Internal refactoring with no external impact
264
+ - Test additions or modifications
265
+ - Code style or formatting changes
266
+ - Dependency updates (unless they cause breaking changes)
267
+ - Trivial bug fixes (typos, off-by-one with no behavior change)
268
+ - Documentation-only changes (don't update docs for docs commits)
269
+
270
+ ## Critical Requirements
271
+
272
+ **Change Detection:**
273
+ - Explore recent commits to identify logical grouping (not just HEAD)
274
+ - Use commit message patterns, file overlap, and timestamps
275
+ - Make autonomous decision about scope
276
+ - Analyze combined diff for the identified group
277
+
278
+ **Documentation Discovery:**
279
+ - Auto-discover using intelligent patterns (README*, ARCHITECTURE*, docs/)
280
+ - Check pre-executed Context for available files
281
+ - Prioritize user-facing docs > API/CLI reference > developer docs
282
+
283
+ **Style Preservation:**
284
+ - **ALWAYS** analyze existing style before updating
285
+ - **MUST** match tone (formal vs casual)
286
+ - **MUST** preserve formatting (code blocks, lists, tables)
287
+ - **MUST** maintain heading hierarchy
288
+ - Make minimal invasive changes only
289
+
290
+ **Update Strategy:**
291
+ - Use Edit tool with exact string matching
292
+ - Insert into existing sections (don't restructure)
293
+ - Update examples in-place (preserve format)
294
+ - Remove deprecated content explicitly
295
+
296
+ **Accuracy:**
297
+ - Base all updates on actual code changes (git diff)
298
+ - Don't guess or fabricate features
299
+ - Include concrete technical details (function names, command syntax)
300
+ - Verify examples match actual implementation
301
+
302
+ **Completeness:**
303
+ - Document all CRITICAL changes (user-facing features, breaking changes)
304
+ - Document IMPORTANT changes (config, behavior changes)
305
+ - Skip internal changes with no external impact
306
+ - Generate verification summary for user
307
+
308
+ **DO:**
309
+ - Analyze commit history to find logical groupings
310
+ - Detect changes using pattern matching table
311
+ - Preserve existing documentation style and tone
312
+ - Make minimal edits (insert into existing structure)
313
+ - Update all examples affected by changes
314
+ - Report what was changed in final summary
315
+
316
+ **DO NOT:**
317
+ - Rigidly analyze only HEAD commit (explore recent history)
318
+ - Restructure existing documentation
319
+ - Change tone or writing style
320
+ - Add features or improvements beyond what changed
321
+ - Skip documenting breaking changes or new user features
322
+ - Remove content without confirming it's deprecated
323
+
324
+ Your goal is to keep documentation accurate and up-to-date with code changes while respecting project conventions and minimizing disruption to existing docs structure.
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env python3
2
+ """SubagentStop Hook - Block premature exits and ensure task completion."""
3
+
4
+ import json
5
+ import sys
6
+
7
+ from pathlib import Path
8
+
9
+
10
+ def main() -> None:
11
+ try:
12
+ event_data = json.loads(sys.stdin.read())
13
+ transcript_path = event_data.get("transcript_path", "")
14
+ except Exception as e:
15
+ print(f"Error loading event data: {e}", file=sys.stderr)
16
+ print(json.dumps({"decision": "approve"}))
17
+ return
18
+
19
+ if not transcript_path:
20
+ print(json.dumps({"decision": "approve"}))
21
+ return
22
+
23
+ transcript_file = Path(transcript_path).expanduser()
24
+ if not transcript_file.exists():
25
+ print(json.dumps({"decision": "approve"}))
26
+ return
27
+
28
+ pending_todos = []
29
+ all_assistant_text = ""
30
+
31
+ with open(transcript_file) as f:
32
+ for line in f:
33
+ try:
34
+ msg = json.loads(line)
35
+
36
+ if "message" in msg:
37
+ msg = msg["message"]
38
+
39
+ if msg.get("role") == "assistant":
40
+ content = msg.get("content", [])
41
+ if isinstance(content, list):
42
+ for item in content:
43
+ if (
44
+ item.get("type") == "tool_use"
45
+ and item.get("name") == "TodoWrite"
46
+ ):
47
+ todos = item.get("input", {}).get("todos", [])
48
+ pending_todos = [
49
+ t["content"]
50
+ for t in todos
51
+ if t.get("status") == "pending"
52
+ ]
53
+ elif item.get("type") == "text":
54
+ all_assistant_text += item.get("text", "") + " "
55
+ except Exception as e:
56
+ print(f"Error parsing message: {e}", file=sys.stderr)
57
+ continue
58
+
59
+ last_assistant_text = all_assistant_text[-2000:]
60
+
61
+ if pending_todos:
62
+ reason = f"INCOMPLETE: {len(pending_todos)} pending tasks:\n"
63
+ reason += "\n".join(f"- {todo}" for todo in pending_todos)
64
+ reason += "\n\nContinue working autonomously until ALL tasks complete."
65
+ print(json.dumps({"decision": "block", "reason": reason}), file=sys.stderr)
66
+ return
67
+
68
+ check_patterns = [
69
+ "would you like me to",
70
+ "should i continue",
71
+ "shall i proceed",
72
+ "let me check with",
73
+ ]
74
+
75
+ text_lower = last_assistant_text.lower()
76
+ if any(pattern in text_lower for pattern in check_patterns):
77
+ print(
78
+ json.dumps(
79
+ {
80
+ "decision": "block",
81
+ "reason": "INCOMPLETE: Do NOT ask for permission. Continue working autonomously.",
82
+ }
83
+ ),
84
+ file=sys.stderr,
85
+ )
86
+ return
87
+
88
+ print(json.dumps({"decision": "approve"}))
89
+
90
+
91
+ if __name__ == "__main__":
92
+ main()
@@ -0,0 +1 @@
1
+ {}