project-test-loop
Automated TDD test-fix-refactor cycle until tests pass. Use when looping on failing tests, running a TDD cycle, or driving RED/GREEN/REFACTOR until green.
What this skill does
# /project:test-loop
## When to Use This Skill
| Use this skill when... | Use project-continue instead when... |
|---|---|
| Driving a RED -> GREEN -> REFACTOR loop until tests pass | Resuming general project work where tests are not the bottleneck |
| Iterating on failing tests with auto fix-and-retry behavior | Use project-distill instead when capturing patterns from a finished session |
| Bounding TDD iterations with `--max-cycles` to avoid runaway loops | Use project-discovery instead when the test command itself is unknown |
Run automated TDD cycle: test โ fix โ refactor.
**Note**: Configure project-specific test/build commands in `CLAUDE.md` or `.claude/rules/` for automatic detection.
**Steps**:
1. **Detect test command** (if not already configured):
- Check `package.json` for `scripts.test` (Node.js)
- Check for `pytest` or `python -m unittest` (Python)
- Check for `cargo test` (Rust)
- Check for `go test ./...` (Go)
- Check `Makefile` for test target
- If not found, ask user how to run tests
2. **Run test suite**:
```bash
# Run detected test command
[test_command]
```
3. **Analyze results**:
**If tests FAIL**:
- Parse failure output
- Identify failing tests:
* Which tests failed?
* What assertions failed?
* What was expected vs actual?
- Identify root cause:
* Bug in implementation?
* Missing implementation?
* Incorrect test?
- Make minimal fix:
* Fix only what's needed to pass the failing test
* Don't add extra functionality
* Don't fix tests (fix code instead)
- Re-run tests to confirm fix
- Loop back to step 2
**If tests PASS**:
- Check for refactoring opportunities:
* Code duplication?
* Unclear naming?
* Long functions?
* Complex logic that can be simplified?
* Magic numbers/strings to extract?
- If refactoring identified:
* Refactor while keeping tests green
* Re-run tests after each refactoring
* Ensure tests still pass
- If no refactoring needed:
* Report success
* Stop loop
4. **Repeat until**:
- All tests pass AND
- No obvious refactoring opportunities
**OR stop if**:
- User intervention needed
- Blocked by external dependency
- Unclear how to fix failure
5. **Report results**:
```
๐งช Test Loop Results:
Cycles: [N] iterations
Fixes Applied:
- [Fix 1]: [Brief description]
- [Fix 2]: [Brief description]
Refactorings Performed:
- [Refactor 1]: [Brief description]
- [Refactor 2]: [Brief description]
Current Status:
โ
All tests pass
โ
Code refactored
๐ Ready for commit
OR
โ ๏ธ Blocked: [Reason]
๐ Next steps: [Recommendation]
```
**TDD Cycle Details**:
### RED Phase (If starting new feature)
1. Write failing test describing desired behavior
2. Run tests โ Should FAIL (expected)
3. This command picks up from here
### GREEN Phase (This command handles)
1. Run tests
2. If fail โ Make minimal fix
3. Re-run tests โ Should PASS
4. Loop until all pass
### REFACTOR Phase (This command handles)
1. Tests pass
2. Look for improvements
3. Refactor
4. Re-run tests โ Should STILL PASS
5. Loop until no improvements
**Common Failure Patterns**:
**Pattern: Missing Implementation**
- **Symptom**: `undefined is not a function`, `NameError`, etc.
- **Fix**: Implement the missing function/class/method
- **Minimal**: Just the signature, return dummy value
**Pattern: Wrong Return Value**
- **Symptom**: `Expected X but got Y`
- **Fix**: Update implementation to return correct value
- **Minimal**: Don't add extra logic, just fix the return
**Pattern: Missing Edge Case**
- **Symptom**: Test fails for specific input
- **Fix**: Handle the edge case
- **Minimal**: Add condition for this case only
**Pattern: Integration Issue**
- **Symptom**: Test fails when components interact
- **Fix**: Fix the integration point
- **Minimal**: Fix just the integration, not entire components
**Refactoring Opportunities**:
**Look for**:
- Duplicated code โ Extract to function
- Magic numbers โ Extract to constants
- Long functions โ Break into smaller functions
- Complex conditionals โ Extract to well-named functions
- Unclear names โ Rename to be descriptive
- Comments explaining code โ Refactor code to be self-explanatory
**Don't**:
- Change behavior
- Add new functionality
- Skip test runs
- Make tests pass by changing tests
**Auto-Stop Conditions**:
Stop and report if:
- All tests pass + no refactoring needed (SUCCESS)
- Same test fails 3 times in a row (STUCK)
- Error in test command itself (TEST SETUP ISSUE)
- External dependency unavailable (BLOCKED)
- Unclear how to fix (NEEDS USER INPUT)
**Integration with Blueprint Development**:
This command applies project-specific skills:
- **Testing strategies**: Knows how to structure tests
- **Implementation guides**: Knows how to implement fixes
- **Quality standards**: Knows what to refactor
- **Architecture patterns**: Knows where code should go
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.