Investigates bugs AND creates actionable TDD fix plans. Creates Linear issues in Todo state. Use when you know you want to fix something - user reports errors, deployment failures, wrong data, or UI issues. Can be chained from investigate skill. Discovers MCPs from CLAUDE.md for debugging (logs, etc.).
Investigate bugs and create TDD fix plans in PLANS.md. Creates Linear issues in Todo state.
Before starting any investigation, verify git status:
git branch --show-current
git status --porcelain
main branch. Tell the user: "Not on main branch. Please switch to main before planning: git checkout main"git fetch origin && git status -uno — STOP if behind.Check if PLANS.md already exists at the project root:
Status: COMPLETE: OK, overwrite with new fix plan.Call mcp__linear__list_teams. If unavailable, STOP and tell the user: "Linear MCP is not connected. Run /mcp to reconnect, then re-run this skill."
Read CLAUDE.md at the project root (if it exists) to understand:
Discover team name: Look for LINEAR INTEGRATION section in CLAUDE.md. If not found, use mcp__linear__list_teams to discover the team name dynamically. Store the discovered team name for use throughout the skill.
Categorize the reported issue into one of these types:
| Category | Description | Key Investigation Areas |
|---|---|---|
| API Error | Backend route failures, 500s, bad responses | Route handlers, middleware, external API calls, error handling |
| Auth Issue | Login failures, session problems, unauthorized access | Auth configuration, session management, middleware, token handling |
| Deployment Failure | Build errors, runtime crashes on Railway | Build logs, environment variables, dependency issues |
| Frontend Bug | UI rendering issues, broken interactions, wrong data display | React components, state management, data fetching, hydration |
| Data Issue | Wrong data, missing data, data corruption | Database queries, API transformations, caching, race conditions |
| Performance | Slow responses, timeouts, memory issues | Query performance, bundle size, API response times |
| Integration | Third-party service failures (AI APIs, payment, etc.) | API keys, request/response formats, rate limits, error handling |
Search the codebase for relevant code using dedicated tools (NOT Bash):
What to find:
If the bug involves deployment or runtime errors, use Railway MCP to check logs:
Search Linear for related issues:
mcp__linear__list_issues to find existing issues about this bugIf the bug involves production crashes, errors, or runtime issues, search Sentry for related issues. Use ToolSearch to load Sentry tools before calling them.
mcp__sentry__find_organizations then mcp__sentry__find_projects to get slugsmcp__sentry__search_issues with natural language (e.g., "unresolved crashes from last week")mcp__sentry__get_issue_details for full stack traces and metadatamcp__sentry__analyze_issue_with_seer for AI-powered analysismcp__sentry__get_issue_tag_values for environment/release breakdownIf Sentry issues are found:
**Sentry:** fieldWhen possible, try to reproduce:
# Check if tests exist and if they catch the issue
npm test 2>&1 | tail -50
# Check for TypeScript errors
npx tsc --noEmit 2>&1 | tail -50
# Check for lint errors
npm run lint 2>&1 | tail -50
Read references/plans-template.md for the complete template.
Source field: Bug report: [Summary of $ARGUMENTS]
Include: Context Gathered (Codebase Analysis + MCP Context + Investigation), Tasks, Post-Implementation Checklist, Plan Summary. Omit: Triage Results subsection.
The Investigation subsection under Context Gathered must include: bug report, classification (type/severity/affected area), root cause, evidence (file paths with line numbers — no code blocks), and impact.
Create a Linear issue in the discovered team with status "Todo":
First, get the team statuses to find the "Todo" state ID:
mcp__linear__list_issue_statuses for team [discovered team name]
Get available labels:
mcp__linear__list_issue_labels for team [discovered team name]
Create the issue:
mcp__linear__create_issue with:
- team: [Discovered team name]
- title: "[Bug Type] Brief description of the fix needed"
- description: |
## Bug Report
[Summary of the issue]
## Sentry Issue (if applicable)
[Sentry issue URL] — [event count] events, [user count] users, release [version]
**Action:** Resolve this Sentry issue after fix is merged and released.
## Root Cause
[What was found during investigation]
## Fix Plan
See PLANS.md for detailed TDD fix plan.
## Files Affected
- `path/to/file.ts`
- `path/to/another-file.ts`
## Acceptance Criteria
- [ ] Failing test written and passes after fix
- [ ] All existing tests pass
- [ ] No TypeScript errors
- [ ] Deployed successfully
- [ ] Sentry issue resolved (if applicable)
- status: "Todo"
- Apply relevant labels (bug, etc.)
Omit the "Sentry Issue" section if the bug did not originate from Sentry.
Update PLANS.md with the created issue key (FOO-xxx).
| Situation | Action |
|---|---|
| Cannot reproduce the bug | Document what was tried, create issue with "needs-reproduction" label |
| Root cause unclear | Document hypotheses ranked by likelihood, create issue with investigation notes |
| Multiple bugs found | Create separate PLANS.md sections and Linear issues for each |
| Bug is in a dependency | Document the dependency issue, check for updates/workarounds, note in issue |
| Railway MCP unavailable | Skip deployment log analysis, note in findings |
| Linear MCP unavailable | Document the issue details in PLANS.md only, tell user to create manually |
| CLAUDE.md not found | Proceed with standard Next.js conventions |
| Existing fix in progress | Check the existing Linear issue and PLANS.md entry, update rather than duplicate |
| Bug is actually a feature request | Reclassify and suggest using add-to-backlog skill instead |
rm, no git reset --hard, no database mutations).fix/FOO-xxx-brief-description.if (!session.x) check after the existing !session.y check") are fine.MIGRATIONS.md.This skill is specifically for:
This skill is NOT for:
Follow the termination procedure in references/plans-template.md: output the Plan Summary, then create branch, commit (no Co-Authored-By tags), and push.
If chained from investigate skill, reference the investigation findings and note any additional evidence found during planning.
Do not ask follow-up questions. Do not offer to implement. Output the summary and stop.