/test-first-bugs
This skill should be used when the user reports a bug, describes unexpected behavior, says something is "broken", "not working", "failing", mentions an "error", "issue", or "problem" in code, or asks to "fix" something. Enforces test-driven bug fixing workflow.
$ npx -y skills add jamditis/claude-skills-journalism --skill test-first-bugs --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/test-first-bugs
Context preview
The summary Claude sees to decide when to auto-load this skill.
This skill should be used when the user reports a bug, describes unexpected behavior, says something is "broken", "not working", "failing", mentions an "error", "issue", or "problem" in code, or asks to "fix" something. Enforces test-driven bug fixing workflow.
SKILL.md
test-first-bugs.SKILL.mdname: test-first-bugs
description: This skill should be used when the user reports a bug, describes unexpected behavior, says something is "broken", "not working", "failing", mentions an "error", "issue", or "problem" in code, or asks to "fix" something. Enforces test-driven bug fixing workflow.
Test-first bug fixing
Enforce a disciplined bug-fixing workflow that prevents regression and parallelizes fix attempts.
Core workflow
When a bug is reported, follow these steps in order:
Phase 1: Reproduce and document
1. **Understand the bug** — Gather details about expected vs actual behavior 2. **Identify the test location** — Determine where tests live in the project (check for `tests/`, `__tests__/`, `spec/`, `*.test.*`, `*.spec.*` patterns) 3. **Write a failing test** — Create a test that demonstrates the bug
Phase 2: Fix with subagents
4. **Launch fix subagents** — Use the Task tool with `subagent_type=general-purpose` to attempt fixes 5. **Run the test** — Verify the fix by running the specific test 6. **Iterate if needed** — If test still fails, launch additional subagents with new approaches
Phase 3: Verify and complete
7. **Run full test suite** — Ensure no regressions were introduced 8. **Report success** — Confirm the bug is fixed with passing test as proof
Writing the failing test
Test naming convention
Name the test to describe the bug:
# Python (pytest)
def test_user_login_fails_when_email_has_uppercase():
...
# Python (unittest)
def test_should_handle_empty_input_without_crashing(self):
...// JavaScript (Jest/Vitest)
it('should not crash when input array is empty', () => { ... });
test('handles special characters in username', () => { ... });// TypeScript
describe('UserService', () => {
it('returns null when user not found instead of throwing', () => { ... });
});Test structure
Every bug reproduction test follows this pattern:
def test_bug_description():
# 1. ARRANGE - Set up the conditions that trigger the bug
input_data = create_problematic_input()
# 2. ACT - Perform the action that causes the bug
result = function_under_test(input_data)
# 3. ASSERT - Verify the expected (correct) behavior
assert result == expected_value # This should FAIL initiallyFinding the right test file
Check the project structure for existing test patterns:
# Find test files
find . -name "*.test.*" -o -name "*.spec.*" -o -name "test_*.py" | head -20
# Find test directories
ls -la tests/ __tests__/ spec/ test/ 2>/dev/null
# Check package.json for test command
grep -A5 '"test"' package.json
Launching fix subagents
Use the Task tool to parallelize fix attempts:
Task tool parameters:
- subagent_type: "general-purpose"
- description: "Fix [bug description]"
- prompt: Include:
1. The bug description
2. The failing test location and contents
3. Suspected cause (if known)
4. Constraint: "Run the test to verify your fix works"
Parallel fix strategies
Launch multiple subagents with different approaches:
1. **Direct fix agent** — Focus on the immediate code causing the bug 2. **Root cause agent** — Investigate deeper architectural issues 3. **Edge case agent** — Look for similar bugs in related code
When projects lack tests
If the project has no test infrastructure:
1. **Set up minimal test framework** first 2. **Create the test file** in a sensible location 3. **Document the test setup** for future use
Quick test setup commands
# Python
pip install pytest
mkdir -p tests && touch tests/__init__.py
# JavaScript/TypeScript
npm install --save-dev jest
# or
npm install --save-dev vitest
# Go
# Tests are built-in, create *_test.go files
Verifying the fix
After subagent reports completion:
# Run the specific test
pytest tests/test_module.py::test_bug_description -v
npm test -- --grep "bug description"
go test -run TestBugDescription -v
# Run full suite to check for regressions
pytest
npm test
go test ./...
Example workflow
**User reports:** "The login function crashes when email has spaces"
**Phase 1 — Write failing test:**
# tests/test_auth.py
def test_login_handles_email_with_spaces():
"""Bug: Login crashes when email contains spaces"""
auth = AuthService()
# This should return an error, not crash
result = auth.login("user @example.com", "password")
assert result.success == False
assert "invalid email" in result.error.lower()**Run test to confirm it fails:**
pytest tests/test_auth.py::test_login_handles_email_with_spaces -v
# Expected: FAILED (demonstrates the bug)
**Phase 2 — Launch subagent:**
Task tool:
- subagent_type: "general-purpose"
- description: "Fix email space crash"
- prompt: "Fix the login crash when email contains spaces.
Bug: AuthService.login() crashes instead of returning error when email has spaces.
Failing test: tests/test_auth.py::test_login_handles_email_with_spaces
After fixing, run: pytest tests/test_auth.py::test_login_handles_email_with_spaces -v
The test must pass to confirm the fix."
**Phase 3 — Verify:**
# Specific test passes
pytest tests/test_auth.py::test_login_handles_email_with_spaces -v
# PASSED
# No regressions
pytest tests/test_auth.py -v
# All tests pass
Integration with hooks
The `bug-report-detector` hook in this plugin automatically: 1. Detects when a user reports a bug 2. Reminds Claude to follow the test-first workflow 3. Blocks Edit/Write tools until a test file has been created or modified
Additional resources
Reference files
- **`references/test-frameworks.md`** — Framework-specific test patterns
- **`references/common-bugs.md`** — Common bug patterns and test strategies
Example files
- **`examples/python-bug-test.py`** — Python pytest example
- **`examples/js-bug-test.js`** — JavaScript Jest example
Scr
Read more
name: test-first-bugs description: This skill should be used when the user reports a bug, describes unexpected behavior, says something is "broken", "not working", "failing", mentions an "error", "issue", or "problem" in code, or asks to "fix" something. Enforces test-driven bug fixing workflow.
Test-first bug fixing
Enforce a disciplined bug-fixing workflow that prevents regression and parallelizes fix attempts.
Core workflow
When a bug is reported, follow these steps in order:
Phase 1: Reproduce and document
1. **Understand the bug** — Gather details about expected vs actual behavior 2. **Identify the test location** — Determine where tests live in the project (check for `tests/`, `__tests__/`, `spec/`, `*.test.*`, `*.spec.*` patterns) 3. **Write a failing test** — Create a test that demonstrates the bug
Phase 2: Fix with subagents
4. **Launch fix subagents** — Use the Task tool with `subagent_type=general-purpose` to attempt fixes 5. **Run the test** — Verify the fix by running the specific test 6. **Iterate if needed** — If test still fails, launch additional subagents with new approaches
Phase 3: Verify and complete
7. **Run full test suite** — Ensure no regressions were introduced 8. **Report success** — Confirm the bug is fixed with passing test as proof
Writing the failing test
Test naming convention
Name the test to describe the bug:
# Python (pytest)
def test_user_login_fails_when_email_has_uppercase():
...
# Python (unittest)
def test_should_handle_empty_input_without_crashing(self):
...// JavaScript (Jest/Vitest)
it('should not crash when input array is empty', () => { ... });
test('handles special characters in username', () => { ... });// TypeScript
describe('UserService', () => {
it('returns null when user not found instead of throwing', () => { ... });
});Test structure
Every bug reproduction test follows this pattern:
def test_bug_description():
# 1. ARRANGE - Set up the conditions that trigger the bug
input_data = create_problematic_input()
# 2. ACT - Perform the action that causes the bug
result = function_under_test(input_data)
# 3. ASSERT - Verify the expected (correct) behavior
assert result == expected_value # This should FAIL initiallyFinding the right test file
Check the project structure for existing test patterns:
# Find test files find . -name "*.test.*" -o -name "*.spec.*" -o -name "test_*.py" | head -20 # Find test directories ls -la tests/ __tests__/ spec/ test/ 2>/dev/null # Check package.json for test command grep -A5 '"test"' package.json
Launching fix subagents
Use the Task tool to parallelize fix attempts:
Task tool parameters: - subagent_type: "general-purpose" - description: "Fix [bug description]" - prompt: Include: 1. The bug description 2. The failing test location and contents 3. Suspected cause (if known) 4. Constraint: "Run the test to verify your fix works"
Parallel fix strategies
Launch multiple subagents with different approaches:
1. **Direct fix agent** — Focus on the immediate code causing the bug 2. **Root cause agent** — Investigate deeper architectural issues 3. **Edge case agent** — Look for similar bugs in related code
When projects lack tests
If the project has no test infrastructure:
1. **Set up minimal test framework** first 2. **Create the test file** in a sensible location 3. **Document the test setup** for future use
Quick test setup commands
# Python pip install pytest mkdir -p tests && touch tests/__init__.py # JavaScript/TypeScript npm install --save-dev jest # or npm install --save-dev vitest # Go # Tests are built-in, create *_test.go files
Verifying the fix
After subagent reports completion:
# Run the specific test pytest tests/test_module.py::test_bug_description -v npm test -- --grep "bug description" go test -run TestBugDescription -v # Run full suite to check for regressions pytest npm test go test ./...
Example workflow
**User reports:** "The login function crashes when email has spaces"
**Phase 1 — Write failing test:**
# tests/test_auth.py
def test_login_handles_email_with_spaces():
"""Bug: Login crashes when email contains spaces"""
auth = AuthService()
# This should return an error, not crash
result = auth.login("user @example.com", "password")
assert result.success == False
assert "invalid email" in result.error.lower()**Run test to confirm it fails:**
pytest tests/test_auth.py::test_login_handles_email_with_spaces -v # Expected: FAILED (demonstrates the bug)
**Phase 2 — Launch subagent:**
Task tool: - subagent_type: "general-purpose" - description: "Fix email space crash" - prompt: "Fix the login crash when email contains spaces. Bug: AuthService.login() crashes instead of returning error when email has spaces. Failing test: tests/test_auth.py::test_login_handles_email_with_spaces After fixing, run: pytest tests/test_auth.py::test_login_handles_email_with_spaces -v The test must pass to confirm the fix."
**Phase 3 — Verify:**
# Specific test passes pytest tests/test_auth.py::test_login_handles_email_with_spaces -v # PASSED # No regressions pytest tests/test_auth.py -v # All tests pass
Integration with hooks
The `bug-report-detector` hook in this plugin automatically: 1. Detects when a user reports a bug 2. Reminds Claude to follow the test-first workflow 3. Blocks Edit/Write tools until a test file has been created or modified
Additional resources
Reference files
- **`references/test-frameworks.md`** — Framework-specific test patterns
- **`references/common-bugs.md`** — Common bug patterns and test strategies
Example files
- **`examples/python-bug-test.py`** — Python pytest example
- **`examples/js-bug-test.js`** — JavaScript Jest example
Scr
A collection of Agent Skills for journalists, researchers, academics, media professionals, and communications practitioners. The same repository serves Claude Code and Codex while keeping Claude-only commands, agents, and hooks clearly labeled.
Repo: jamditis/claude-skills-journalism
Other skills on claude-skills-journalism.
- /accessibility-compliance
Web accessibility patterns for news sites, journalism tools, and academic platforms. Use when building accessible interfaces, auditing existing sites for WCAG compliance, writing alt text for news images, creating accessible data visualizations, or ensuring content reaches all
Open skill - /claude-md-updater
Use this skill when the user asks to update CLAUDE.md, save a lesson, or persist something from the current session: phrases like "update claude.md", "what should we remember", "save this lesson", or "add to context". Scans the conversation for hard-won lessons, new file paths,
Open skill - /electron-dev
Electron desktop application development with React, TypeScript, and Vite. Use when building desktop apps, implementing IPC communication, managing windows/tray, handling PTY terminals, integrating WebRTC/audio, or packaging with electron-builder. Covers patterns from AudioBash,
Open skill - /mobile-debugging
Remote JavaScript console access and debugging on mobile devices. Use when debugging web pages on phones/tablets, accessing console errors without desktop DevTools, testing responsive designs on real devices, or diagnosing mobile-specific issues. Covers locally hosted Eruda and
Open skill - /one-way-door
Use this skill when creating new files that represent architectural decisions — data models, infrastructure configs, auth boundaries, API contracts, CI/CD pipelines, or event systems. Flags irreversible decisions and forces a discussion about trade-offs before committing.
Open skill - /python-pipeline
Python data processing pipelines with modular architecture. Use when building content processing workflows, implementing dispatcher patterns, integrating Google Sheets/Drive APIs, or creating batch processing systems. Covers patterns from rosen-scraper, image-analyzer, and
Open skill

