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,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.
|
|
@@ -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.
|