en un clic
bug-fix-tdd
// Reproduce and fix bugs using TDD. Use when analyzing a bug report, writing a regression test, or applying a minimal fix. Covers test placement, mock patterns, and the red-green-refactor workflow for automated bug fixing.
// Reproduce and fix bugs using TDD. Use when analyzing a bug report, writing a regression test, or applying a minimal fix. Covers test placement, mock patterns, and the red-green-refactor workflow for automated bug fixing.
| name | bug-fix-tdd |
| description | Reproduce and fix bugs using TDD. Use when analyzing a bug report, writing a regression test, or applying a minimal fix. Covers test placement, mock patterns, and the red-green-refactor workflow for automated bug fixing. |
Reproduce bugs with a failing test, then apply the minimum fix. This skill is used by the automated bug-fix agent in CI but can also be invoked manually.
pnpm run test:nonInteractive -- <test-file-path>bug-analysis.md with findings (see format below)Constraints: Do NOT modify source files in Phase 1. Only create/edit test files and bug-analysis.md.
bug-analysis.mdpnpm run test:nonInteractive -- <test-file-path>pnpm run test:nonInteractivepnpm run lint and pnpm run type-checkpr-body.md and fix-title.txtConstraints: Do NOT run git, gh, or modify .env files.
If Phase 1 cannot reproduce the bug in a test (test passes after 3 attempts), Phase 2b runs instead of Phase 2.
bug-analysis.md and issue-body.md for contextpnpm run test:nonInteractivepnpm run lint and pnpm run type-checkpr-body.md and fix-title.txt — note in the PR body that no regression test was possibleConstraints: Same as Phase 2. Do NOT run git, gh, or modify .env files.
__tests__/ directories colocated with the source filedescribe('Bug #N', ...) block instead of creating a new file<component-name>.test.tsx or <hook-name>.test.tsrenderer/src/features/skills/components/card-skill.tsx → test at renderer/src/features/skills/components/__tests__/card-skill.test.tsximport { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
})
render(
<QueryClientProvider client={queryClient}>
<MyComponent prop="value" />
</QueryClientProvider>
)
await userEvent.click(screen.getByRole('button', { name: /save/i }))
await waitFor(() => {
expect(screen.getByText('Saved')).toBeVisible()
})
import { createTestRouter } from '@/common/test/create-test-router'
import { renderRoute } from '@/common/test/render-route'
const router = createTestRouter(MyPage, '/my-page')
renderRoute(router, { permissions: { canManageClients: true } })
await waitFor(() => {
expect(screen.getByRole('heading', { name: /my page/i })).toBeVisible()
})
import { renderHook, waitFor } from '@testing-library/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false } },
})
const Wrapper = ({ children }) =>
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
const { result } = renderHook(() => useMyHook(), { wrapper: Wrapper })
await waitFor(() => expect(result.current.isLoading).toBe(false))
expect(result.current.data).toEqual({ ... })
import { mockedGetApiV1BetaWorkloads } from '@mocks/fixtures/workloads/get'
mockedGetApiV1BetaWorkloads.override((data) => ({
...data,
workloads: [], // Force empty state
}))
import { HttpResponse } from 'msw'
mockedGetApiV1BetaWorkloads.overrideHandler(() =>
HttpResponse.json({ error: 'Server error' }, { status: 500 })
)
import { recordRequests } from '@/common/mocks/node'
const rec = recordRequests()
// ... trigger action ...
const request = rec.recordedRequests.find(
(r) => r.method === 'POST' && r.pathname === '/api/v1beta/workloads'
)
expect(request?.payload).toMatchObject({ name: 'my-server' })
## Bug Summary
<1-2 sentences describing the bug>
## Root Cause
<Technical explanation of why the bug occurs>
## Relevant Files
- `path/to/source.tsx` — <what it does>
- `path/to/related.ts` — <why it's relevant>
Test file: path/to/\_\_tests\_\_/component.test.tsx
## Proposed Fix
<Description of the minimum change needed>
## Files to Modify
- `path/to/file.tsx` — <what to change>
Important: The Test file: line must be on its own line starting with exactly Test file: followed by the path. This is parsed by the CI workflow.
## Summary
Fixes #<issue-number>.
- <1-2 bullet points describing the fix>
## Test
- Added regression test in `<test-file-path>`
- Test reproduces the bug (fails before fix, passes after)
---
_Automated fix by Claude Code TDD Agent_
Single line, conventional commit format:
fix(<scope>): <description> (#<issue-number>)
Example: fix(skills): prevent crash when metadata is undefined (#423)
recordRequests()Remediate security vulnerabilities found by Grype or pnpm audit. Use when a security scan fails, a CVE needs fixing, or you need to analyze, upgrade, override, or ignore a vulnerable dependency.
Deep links in ToolHive Studio. Use when implementing, debugging, or asking about deep link features (toolhive-gui:// protocol), adding new deep link intents, understanding the deep link architecture, IPC model, or platform/packaging support.
Spin up and interact with ToolHive Studio's containerized dev environment (Xvfb + noVNC + DinD). Use when running, testing, or debugging the app in isolation — locally, in a git worktree, or in GitHub Codespaces; when touching `.devcontainer/*`, `scripts/devcontainer-*.sh`, or the `devContainer:dev` npm script; or when debugging "blank white window", "Docker daemon failed to start", or "Missing X server" errors in the devcontainer. The container is fully isolated: no host pnpm install, no host Docker socket, no host X11/GPU — experiment freely without contaminating the host.
Start here for all API mocking in tests. Covers auto-generation, fixtures, and when to use other skills. Required reading before creating, refactoring, or modifying any test involving API calls.
Test that components send correct query parameters or request arguments. Use when testing filtering, sorting, pagination, or any read operation where request parameters matter. Use for test-scoped mock customization.
REQUIRED for editing any skill file. Ensures changes sync to Claude, Codex, and Cursor. Never edit .claude/skills/ files directly - always use this skill.