"Done" doesn't count; test results that were actually run and screenshots do.
Before handing in
- Run the project's test command. Only add a test when the existing tests genuinely can't cover the behavior of this change; for how to write it, see "Writing tests" below. Fixing a bug doesn't need a regression test every time.
- The change is user-visible (web page, UI): write a Playwright browser test that clicks through the changed flow in a real browser, fail on any console error, and save a screenshot of each step into the project. No browser installed:
npx playwright install chromium, or just use the local Chrome (channel: 'chrome'). If you have your own browser tools, you can use them directly too. - If any item fails, fix it first, then hand in.
- Write the hand-in in this format:
做了什么:一句话
测试:<命令> → 通过 N,失败 0
截图:<路径>
没验证到的:哪些、为什么;没有就写「无」
After being corrected
First fix this mistake. Then think: the next agent only looks at the file it opens, copies the nearest example, and takes the shortest path — will it make the same mistake again? If so, stop it before it happens.
While you're at it, skim the recent commits and AGENTS.md: mistakes of the same kind made before should be blocked together.
From strongest to weakest, don't go further down if an earlier one works:
- Leave it no place to happen: one thing has only one place responsible for it and one way to do it; delete old patterns the agent will copy; merge several lists that need manual syncing into one.
- Make it error the moment it happens: types, lint, tests, validation scripts all work. Write in the error message what to use instead.
- Make it visible at a glance: whether it looks good and feels right can't be judged by a machine, so attach screenshots at hand-in for a human to look at.
- Write it into AGENTS.md: reserve this only for things that need judgment. If the agent skips this kind of rule, nothing will error.
When you add a check, test it with the mistake actually made this time: put the mistake back, the check must error; change it back, it must pass. A check that has never errored is the same as no check.
Finally, record a line in the rules table in AGENTS.md:
| 规则 | 由什么拦住 |
|---|---|
| 交差前跑通测试,附截图 | `npm test` + 浏览器截图 |
If this rule is already in the table but nothing blocks it, that means it's a repeat offense; this time move it up one level toward the stronger end. If the mistake can no longer happen, delete that line.
Writing tests
Tests only guard behavior the user can feel: what's stored can be read back, clicking a button changes the page. The following three are garbage tests; fix them, or delete them if you can't:
- Fake test: the part that should be guarded is replaced by a test double (mock). For example, testing whether data can be stored but connecting to a fake database — it still passes when the real database is down.
- Tautological: the expected answer is copied from the code's current output; when the code is wrong, the answer is wrong along with it.
- Implementation-coupled: it checks variable names or how many times some internal function was called. The functionality hasn't changed, but it fails just because the code was rewritten.
Test: deliberately break the functionality it is meant to protect, and the test should fail; merely rename an internal variable, and it should still pass. If it cannot do that, it is a garbage test.