一键导入
write-tests
Plan and write test cases with high reasoning effort. Test iteration runs in a subagent to minimize confirmations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Plan and write test cases with high reasoning effort. Test iteration runs in a subagent to minimize confirmations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Conduct a decision-tree interview with the user to lock in requirements, motivation, scope, and non-goals before planning.
Stage 3 of three-stage planning pipeline. Produce a file-level implementation plan via detail-planner/detail-reviewer loop, then get user approval. Inputs are confirmed intent (<session-id>-intent.md) and outline (<session-id>-outline.md) from prior stages.
Edit source code for the current task. Delegates editing and lint/typecheck/self-repair to a subagent.
Explore the codebase to understand existing patterns, constraints, and relevant files before planning.
Investigate git history, docs/history.md, and GitHub issue/PR timeline since the relevant issue opened, to surface changes that may invalidate the issue's premises.
Orchestrate session close — Phase 2 issue close + Final Report. Replaces CLAUDE.md WF-CODE-12. Handles both ENFORCE_WORKTREE on (worktree path) and off (branch/main path).
| name | write-tests |
| description | Plan and write test cases with high reasoning effort. Test iteration runs in a subagent to minimize confirmations. |
| model | sonnet |
| user-invocable | false |
Write or update tests for the current task.
WT-1. Read skills/_shared/test-design.md for test case categories, naming conventions, and layer selection rules. Also read rules/test.md for timeout, E2E, and installer test patterns.
テスト対象ソースファイルがパーサ/正規表現/allowlist ファイル(sentinel-patterns.js,
bash-write-patterns.js, command-parser.js, scan-outbound.sh, .private-info-*list のいずれか)
の場合は、skills/_shared/test-design.md の Table-Driven Tests セクションのパターンを適用すること。
WT-2. Identify which source file(s) need tests.
WT-3. Enumerate call paths: For each source file from step WT-2, trace all integration
paths it participates in — what calls it, what it calls, and what format/contract
each boundary expects. For each boundary, list potential failure modes (wrong format,
missing field, wrong type, unexpected value). These become integration-path error
cases in the next step.
WT-4. List all planned test cases by category (include call-path error cases from step WT-3).
Then check via Bash:
bash -c 'cd "$AGENTS_CONFIG_DIR" && bash "$AGENTS_CONFIG_DIR/bin/confirm-off" CONFIRM_TESTS on'
OFF: print the planned cases and proceed to step WT-5 without approval wait.ON or ERROR: present the planned cases to the user — do not write code until approved (existing behavior).
WT-5. Determine the subagent's model:bash -c 'node "$AGENTS_CONFIG_DIR/bin/workflow/read-complexity-evaluation" --session "$SESSION_ID"'. If output is not NONE, use the stored verdict and signals directly (parse verdict=<v> and signals=<csv>); skip the fallback below.NONE (fail-open for sessions without persisted evaluation): read skills/_shared/judge-task-complexity.md to load the signal table. Evaluate all signals against the task context, source files from steps WT-2–WT-3, and the planned test cases from step WT-4. Do not short-circuit on the first match. Apply the routing rule: 1+ signals → opus; 0 signals → sonnet; ambiguous → opus.Model selected: [opus|sonnet] (signals: [comma-separated triggered signal IDs, or "none"])
WT-6. Launch a subagent (Agent tool, mode: "default", model: <model from step WT-5>) to autonomously:
WT-6a. Write the test file(s).
WT-6b. Run tests with timeout.
WT-6c. Fix failures and re-run until green.
WT-6d. Review test coverage against skills/_shared/test-design.md categories — fix gaps.
WT-6e. Re-run tests until green.
The subagent prompt MUST include these structured fields so verbose output stays in the subagent context:
task_complexity_signals: list of triggered signal IDs from step WT-5 (or "none")source_files: list of source file paths from step WT-2planned_cases: list of planned test cases from step WT-4
The subagent prompt MUST instruct: edit only test files, never modify source code.
The subagent prompt MUST also include: "NEVER present diffs for approval. NEVER wait for user confirmation. Edit and run autonomously until tests pass."WT-7. Present the final test file content to the user for review — gated by CONFIRM_TESTS gate (post-action review):
bash -c 'cd "$AGENTS_CONFIG_DIR" && bash "$AGENTS_CONFIG_DIR/bin/confirm-off" CONFIRM_TESTS on'
OFF: skip this step; proceed directly to Completion (no user wait).ON or ERROR: present the test file content.After completing this skill:
git add tests/
The commit gate detects staged tests/ changes as evidence of completion.If tests are genuinely not needed for this change:
echo "<<WORKFLOW_WRITE_TESTS_NOT_NEEDED: {reason}>>"