claude-web-test-harness: Agent for Claude Code

.claude/agents/test-writing.md

test-writing is an agent for Claude Code from 569270901/claude-web-test-harness. It costs 65 tokens per session (2,622 once invoked), scanned A, original, MIT.

A two-stage agent that turns confirmed test cases and user flows into test code and test data, then checks and repairs its own implementation. Test-driven development, or TDD, means using defined tests to verify that software behaves as expected.

In plain words
What is it for?
Use it to create or update automated tests and data files for a feature, run a lightweight compliance check, and document deviations or bugs.
Why use it?
It reduces the manual work of translating reviewed test plans into runnable checks. Its required approvals and compliance scan help catch missing or weakened assertions before separate review.

Agent for Claude Code

Written for Claude Code: installed under .claude/. Also seen: mentions CLAUDE.md.

This is 569270901/claude-web-test-harness's own configuration. It tells Claude Code how to work on claude-web-test-harness itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-web-test-harness configures →

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is python3 scripts/journal.py log --actor test-writing --action decide \.

Reuse

Borrowing it

Nothing to install: this file belongs to 569270901/claude-web-test-harness. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/569270901/claude-web-test-harness/main/.claude/agents/test-writing.md
Clone the repo
git clone --depth 1 https://github.com/569270901/claude-web-test-harness

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for test-writing

README.md
[![agentmods](https://agentmods.dev/badge/agents/569270901/claude-web-test-harness/test-writing/github.svg)](https://agentmods.dev/agents/569270901/claude-web-test-harness/test-writing)
Your own site
<a href="https://agentmods.dev/agents/569270901/claude-web-test-harness/test-writing"><img src="https://agentmods.dev/badge/agents/569270901/claude-web-test-harness/test-writing/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for test-writing

Your own site · 80×15
<a href="https://agentmods.dev/agents/569270901/claude-web-test-harness/test-writing"><img src="https://agentmods.dev/badge/agents/569270901/claude-web-test-harness/test-writing.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 65 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,622 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00065 $0.02622
Opus 5.5 $0.00026 $0.01049
Sonnet 5.5 $0.00013 $0.00524
Haiku 4.5 $0.00006 $0.00262

Measured 2d ago against content hash f34e860b4d05, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

test-writing scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/test-writing.md · 112 lines

How it starts

The opening of the file, as written. The whole thing — 112 lines — stays where its author put it; the contents beside it link to each section on GitHub.

你是本项目多 agent 编排的 test-writing agent,现在以独立 context 子 agent 运行。

隔离须知(必读)

  • 你不共享 orchestrator 的对话记忆。cases.md / flow.md / page_map / 知识库你自己读。
  • 你不能派发其他子 agent——这意味着你不再自己调 review。你的职责到「写完代码 + compliance 轻扫 + 自跑自修 + 写 impl.md」为止;review 由 orchestrator 在你返回后单独派发 (前置轻闸=你跑 compliance scan,后置重闸=orchestrator 派 review)。
  • 你的最终消息是简短摘要:改了哪些文件、测试 pass/fail 数、自修轮次、发现的 bug。完整内容 写进 impl.md / ops_review.md。
  • ❌ 禁止"假挂起":你是一次性调用,不存在"后台任务跑完后有人叫醒你继续"这回事,没有任何推送通知会把你接回来。 跑 pytest 要么前台阻塞等结果(单次命令有时长上限,长回归按文件/标记拆块跑),要么后台跑时 在同一轮工具调用里自己轮询到结束(如 while ps -p <pid> >/dev/null; do sleep 10; done), 拿到结果再决定下一步。绝不能说"我先返回,等它跑完再继续"就结束消息——那不是暂停,是卡死。
  • 跑之前先确认没有别的 pytest 在跑(ps aux | grep -v grep | grep pytest):并发跑会抢登录态 / 验证码窗口 / 测试数据,制造假失败。

成本效益分诊(目标是提效,不是凑覆盖率)

  • exec: auto 不等于必须跑通:动手前或动手中发现实际成本远超预期(UI 反复失败、selector 找不到 稳定锚点、前置数据极难构造),可以中途放弃、改判 manual,不必因为设计阶段标了 auto 就死磕。
  • 放弃必须写清楚"卡在哪":哪一步失败、试了几次、疑似原因(selector 漂移 / 数据造不出 / 交互太复杂)。 写进 impl.md 的「转手测」清单,把这些用例的 exec 改成 manual 并注明理由,交还用户。
  • impl.md 不需要为"覆盖率不够"道歉,只需要说清楚:自动化覆盖了什么、转手测的是什么、为什么转。
  • ❌ 但不许为了跑通而弱化断言、或换掉稳定 selector 去迁就不稳定的 UI——那种情况就该转手测。

执行期不打断用户

跑到一半发现"实测行为和已确认的 flow.md / cases.md 不一致"时,不要中途停下来问用户: 按合理默认继续(以实测为准写断言并标注,或按已确认文档写、失败就挂 xfail),把疑点记进 ops_review.md / impl.md 对应用例的 note,整个任务跑完后一次性汇报。只有阻断性问题 (环境不可用、登录失效、需要用户提供凭据)才立即上报。报"产品缺陷"前先交叉验证——"我没找到" 不等于"它不存在"。

入口前置检查(不满足就拒绝执行,写 status=blocked)

  1. cases.md 存在且 status: confirmed(阶段1)/ ops_review.md 存在且 status: confirmed(阶段2)
  2. 只读 exec: auto 的行——manual / blocked 的行在本次任务里当作不存在(用户在 GATE 1 标的例外),它们既不进脚本也不进覆盖率分母
  3. cases.md 中 exec: auto 的那些行的 page_ref 都能在 page_map 找到
  4. 测试环境可访问(见 CLAUDE.md)

启动后第一件事

  1. 读 artifacts/README.md
  2. 读 artifacts/agents/test-writing.md —— 实现风格、自修流程、失败归因决策表、红线
  3. 读 CLAUDE.md、rule.md、相关 page_map / 知识库

工作流(两阶段——orchestrator 派发 prompt 会指明本次是哪个阶段)

阶段1 = 编码(cases.md + flow.md 均 confirmed 后):

  1. 以 confirmed flow.md 为行为基准(文案字面值/操作流以它为准),结合 cases.md + 地图 写/改测试代码(tests/**/test_*.py)与测试数据(data/*.yaml),优先复用项目既有的 数据驱动 / page object 层;异步交互(上传、多步翻页)走 utils/interaction.py 按地图动力学字段等证据, 一条用例要核对多处时用 utils/soft_check.py 收集后统一报错,禁止固定 sleep 赌时间
  2. 轻量自检(compliance scan):无删/弱化断言、无 expected="0"/"-"/空、无通配 selector、 文件在 tests/ 下、注释中文(项目若有 scripts/check_compliance.py 就跑它)
  3. 产出 artifacts/<task_id>/ops_review.md = 偏差清单(不是全量对照单):只列 ①实现与 confirmed flow.md 的出入 ②sync.md 报的「实测 vs flow.md 偏差」③flow.md 标 ⚠️待实测 项的实测取值。frontmatter 必带 deviation_count。偏差=0 时也要写(空清单, deviation_count: 0),orchestrator 据此自动流转不打扰用户
  4. 到此为止返回,不跑测试

Read the full file on GitHub · 112 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago Changed · +32 lines f34e860b4d05
  2. 1mo ago Changed · +4 lines 0321bff0c145
  3. 1mo ago First seen · 76 lines · 65 tokens per session scan A 78a206a60a6b

Subscribe to this mod's changes

test-writing is an agent published in the GitHub repository 569270901/claude-web-test-harness (44 stars, last pushed 2d ago), licensed MIT. It adds 65 tokens to every session and 2,622 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.