| name | test-fix-loop |
| description | Automated test-driven fix loop โ run tests, analyze failures, investigate root causes, fix code, and re-run until all tests pass with configurable max iterations |
| allowed-tools | ["Read","Edit","Write","Glob","Grep","Agent","Bash(npm test:*)","Bash(npx:*)","Bash(bun test:*)","Bash(bun run:*)","Bash(pytest:*)","Bash(python3 -m pytest:*)","Bash(go test:*)","Bash(cargo test:*)","Bash(jest:*)","Bash(vitest:*)","Bash(make test:*)","Bash(make:*)","Bash(tsc:*)","Bash(git diff:*)","Bash(git status:*)","Bash(ls:*)","Bash(wc:*)"] |
| arguments | ["target"] |
| argument-hint | [test command, file pattern, or 'investigate' for analysis-only mode] |
| user-invocable | true |
| when_to_use | Use when the user wants to run tests and fix failures in a loop, debug test failures, investigate root causes,
or achieve passing tests through iterative fixes.
Examples: 'run tests and fix', 'test fix loop', 'make tests pass', 'fix failing tests', 'investigate failure',
'ํ
์คํธ ๋๋ฆฌ๊ณ ๊ณ ์ณ์ค', 'ํ
์คํธ ํต๊ณผ์์ผ', '์คํจ ์์ธ ๋ถ์', 'ํ
์คํธ ๋ฃจํ', '๋๋ฒ๊ทธ'
|
Test Fix Loop
Overview
ํ
์คํธ๋ฅผ ์คํํ๊ณ , ์คํจ๋ฅผ ๋ถ์ํ๊ณ , ์ฝ๋๋ฅผ ์์ ํ๊ณ , ๋ค์ ์คํํ๋ ๋ฃจํ๋ฅผ ์๋ํํ๋ค. ์์ธ ๋ถ์(investigate) ๋ชจ๋๋ ํฌํจํ๋ค.
Inputs
$target: ๋ค์ ์ค ํ๋
- ํ
์คํธ ๋ช
๋ น์ด (์:
npm test, pytest tests/api/)
- ํ์ผ ํจํด (์:
tests/auth/*.test.ts)
investigate โ ์์ ์์ด ์์ธ ๋ถ์๋ง
Process
Step 1: ํ
์คํธ ํ๋ ์์ํฌ ๊ฐ์ง
$target์ด ๋ช
๋ น์ด๊ฐ ์๋๋ฉด ์๋ ๊ฐ์งํ๋ค. ์์ธ ๊ฐ์ง ๊ท์น๊ณผ ์คํจ ๋ถ๋ฅ๋ references/tfl-workflow-guide.md๋ฅผ ์ฐธ์กฐํ๋ค.
| ํ์ผ | ํ๋ ์์ํฌ | ๊ธฐ๋ณธ ๋ช
๋ น์ด |
|---|
package.json (scripts.test) | npm/bun | npm test / bun test |
vitest.config.* | Vitest | npx vitest run |
jest.config.* | Jest | npx jest |
pyproject.toml [tool.pytest] | pytest | python3 -m pytest |
go.mod | Go test | go test ./... |
Cargo.toml | Cargo | cargo test |
Makefile (test target) | Make | make test |
Step 2: ํ
์คํธ ์คํ
Bash๋ก ํ
์คํธ๋ฅผ ์คํํ๊ณ ์ ์ฒด ์ถ๋ ฅ์ ์บก์ฒํ๋ค.
Step 3: ์คํจ ํ์ฑ
์ถ๋ ฅ์์ ์คํจ ์ ๋ณด๋ฅผ ์ถ์ถํ๋ค:
| ๋ถ๋ฅ | ํจํด |
|---|
| Compilation error | SyntaxError, TypeError, cannot find module, build ์คํจ |
| Assertion failure | AssertionError, expect(...).toBe(...), assertEqual ์คํจ |
| Runtime exception | ReferenceError, NullPointerException, segfault |
| Timeout | timeout, exceeded, SIGTERM |
์คํจํ ํ
์คํธ ์ด๋ฆ, ํ์ผ ์์น, ์๋ฌ ๋ฉ์์ง, ์คํ ํธ๋ ์ด์ค๋ฅผ ๊ตฌ์กฐํํ๋ค.
Step 4: ์์ธ ์กฐ์ฌ
- ์คํจํ ํ
์คํธ ํ์ผ์ Read๋ก ์ฝ๋๋ค.
- ์คํ ํธ๋ ์ด์ค์ ์์ค ์ฝ๋๋ฅผ ์ถ์ ํ๋ค.
- Grep์ผ๋ก ๊ด๋ จ ํจ์/๋ชจ๋์ ์ฐพ๋๋ค.
- ๋ณต์กํ ๊ฒฝ์ฐ Agent(subagent_type: "Explore")๋ก ์ฌ์ธต ์กฐ์ฌํ๋ค.
Investigation ๋ชจ๋ ($target = investigate): ์ด ๋จ๊ณ์์ ๋ฉ์ถ๊ณ ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ํ๋ค.
- ์คํจ ํธ๋ฆฌ (์ด๋ค ํ
์คํธ๊ฐ ์ ์คํจํ๋์ง)
- ํธ์ถ ์ฒด์ธ ๋ถ์
- ๊ฐ์ค ์์ (๊ฐ์ฅ ๊ฐ๋ฅ์ฑ ๋์ ์์ธ๋ถํฐ)
- ์ ์ ์์ ์ (์ ์ฉํ์ง ์์)
Step 5: ์ต์ ์์ ์ ์ฉ
- ํ๋ก๋์
์ฝ๋๋ฅผ ์์ ํ๋ค (ํ
์คํธ ์ฝ๋๊ฐ ์๋).
- ํ
์คํธ ์์ฒด๊ฐ ์๋ชป๋ ๊ฒฝ์ฐ์๋ง ํ
์คํธ๋ฅผ ์์ ํ๋ค.
- ํ ๋ฒ์ ํ๋์ ๊ด์ฌ์ฌ(concern)๋ง ์์ ํ๋ค.
- ์์ ๋ฒ์๋ฅผ ์ต์๋ก ์ ์งํ๋ค.
Step 6: ์ฌ์คํ
- ์คํจํ๋ ํ
์คํธ๋ง ๋จผ์ ์คํ (๋น ๋ฅธ ํผ๋๋ฐฑ).
- ํต๊ณผํ๋ฉด ์ ์ฒด ํ
์คํธ ์ค์ํธ ์คํ (ํ๊ท ํ์ธ).
Step 7: ๋ฃจํ
- ์ ๋ถ ํต๊ณผํ ๋๊น์ง Step 2~6์ ๋ฐ๋ณตํ๋ค.
- ๊ธฐ๋ณธ ์ต๋ ๋ฐ๋ณต: 5ํ.
- ๊ฐ์ ํ
์คํธ๊ฐ ๊ฐ์ ์๋ฌ๋ก 3ํ ์ฐ์ ์คํจํ๋ฉด ๋ฃจํ๋ฅผ ์ค๋จํ๊ณ ๋ณด๊ณ ํ๋ค.
Step 8: ๊ฒฐ๊ณผ ๋ณด๊ณ
- ์ด ๋ฐ๋ณต ํ์
- ์์ ํ ํ์ผ ๋ชฉ๋ก
- ๊ฐ ๋ฐ๋ณต์์ ์์ ํ ๋ด์ฉ ์์ฝ
- ์ต์ข
ํ
์คํธ ๊ฒฐ๊ณผ (ํต๊ณผ/์์ฌ ์คํจ)
Loop Rules
- ์ต์ ์์ : ํ ๋ฐ๋ณต์์ ํ ๊ด์ฌ์ฌ๋ง ์์
- ํ๋ก๋์
์ฝ๋ ์ฐ์ : ํ
์คํธ๋ณด๋ค ์์ค ์ฝ๋ ์์ ์ ์ฐ์
- ๋ฒ์ ์ ํ: ์คํจ์ ๊ด๋ จ ์๋ ์ฝ๋๋ฅผ ์์ ํ์ง ์์
- ๋ฐ๋ณต ์ถ์ : ๊ฐ ๋ฐ๋ณต์ ๋ณ๊ฒฝ์ฌํญ์ ๊ธฐ๋กํ์ฌ ๋กค๋ฐฑ ๊ฐ๋ฅํ๊ฒ
- ์ค๋จ ์กฐ๊ฑด:
- ์ต๋ ๋ฐ๋ณต ์ด๊ณผ
- ๊ฐ์ ์๋ฌ 3ํ ์ฐ์ ๋ฐ๋ณต
- ๊ทผ๋ณธ์ ์ค๊ณ ๋ฌธ์ ๋ฐ๊ฒฌ (์๋ ๊ฐ์
ํ์)
- ์ธ๋ถ ์์กด์ฑ ๋ฌธ์ (๋คํธ์ํฌ, DB, ์๋น์ค)