con un clic
aim-writing-tests
当 AIM Agent 需要新增、修改、迁移或评审测试时使用,确保测试保护行为语义而不是当前实现形状。
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Menú
当 AIM Agent 需要新增、修改、迁移或评审测试时使用,确保测试保护行为语义而不是当前实现形状。
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Basado en la clasificación ocupacional SOC
Required entry skill when you are an AIM Developer working on an existing AIM Task and must read the task via AIM Server, validate it against the latest baseline, execute the worktree and PR lifecycle, report field facts, and complete the bound OpenCode session.
Strongly recommended when you need to clarify questions, converge directions and uncertainties, do design or orienting work, or answer open-ended questions before deciding how to proceed and producing a task spec, especially when key clarifications could change the route.
Coordinator decision entry for AIM Task Pool maintenance; form an approvable POST /tasks/batch operations plan from Manager output, latest baseline facts, current Tasks, and rejected Task feedback before applying atomic Task Pool writes.
当用户已经明确批准创建新的 AIM Task,且需要把稳定的用户意图整理成候选 Task Spec 并提交到 POST /tasks 时使用。
Use when judging how README claims compare to the latest origin/main baseline and the coordinator needs direction signals without task creation or execution decisions.
AIM Manager guidance for evaluating README goals against the latest baseline, defining iteration direction and Dimensions, and preparing Coordinator-consumable evaluation signals without creating tasks or executing work.
| name | aim-writing-tests |
| description | 当 AIM Agent 需要新增、修改、迁移或评审测试时使用,确保测试保护行为语义而不是当前实现形状。 |
这个 skill 用于约束 AIM Agent 如何写测试、修测试、迁移旧测试。
核心原则:测试应保护产品、API、CLI、UI、契约与持久化语义,而不是保护当前实现形状。
测试的价值来自它能稳定描述外部可观察行为,并在行为被破坏时失败。不要把测试写成对源码、私有协作、提示词措辞或 mock 编排细节的快照。
aim-test-driven-development,准备写 RED 测试前。dist、生成产物、包内容或发布产物,需要判断是否是合法 artifact guard 时。toContain 某段实现片段,除非这是明确的仓库策略、架构边界或生成产物 guard 测试。优先保护这些语义:
不要优先保护这些形状:
默认禁止这类测试:
const source = await readFile(new URL('../src/index.ts', import.meta.url), 'utf8')
expect(source).toContain('someInternalHelper(')
它通常只证明当前实现还长得一样,不能证明用户行为仍正确。
仅在下面场景可以使用源码或文本内容断言:
即使属于例外,也要让测试名说明 guard 目的,并把断言收敛到稳定规则,不要顺手检查实现碎片。
mock 应放在系统外部边界:
不要默认 mock 当前模块内部协作。若一个测试必须 mock 大量内部函数才能成立,先怀疑测试目标或代码边界不清,而不是继续堆 mock。
当正常 scope 内工作导致旧测试失败时,不要先机械修补脆弱断言。
按下面顺序处理:
迁移旧测试时,优先保留它原本想保护的用户价值或 contract,而不是逐字搬运旧断言。
测试内部禁止隐式执行这些准备:
ensure build dist测试不能偷偷构建产物来让自己通过。若测试依赖 dist 或生成产物,它必须是显式 artifact / package / release 风格测试,并满足至少一项:
TDD RED 测试也必须遵守这条规则。RED 的环境不能由测试内部隐藏重型准备制造;前置状态必须由被调用的验证命令提供。
合格:验证 CLI contract。
test('prints a useful error and exits non-zero for unknown command', async () => {
const result = await runCli(['unknown'])
expect(result.exitCode).toBe(1)
expect(result.stderr).toContain('Unknown command')
})
不合格:验证内部实现形状。
test('unknown command uses parseCommand helper', async () => {
expect(parseCommand).toHaveBeenCalledBefore(renderError)
})
合格:mock 外部 SDK 边界。
test('reports API timeout as retryable failure', async () => {
fakeSdk.fetchUser.mockRejectedValueOnce(new TimeoutError())
await expect(loadUser('u1')).rejects.toMatchObject({ retryable: true })
})
不合格:mock 内部协作并检查过量调用细节。
test('loadUser calls normalize then map then decorate', async () => {
expect(normalize).toHaveBeenCalledWith(rawUser)
expect(mapUser).toHaveBeenCalledWith(normalizedUser)
expect(decorateUser).toHaveBeenCalledWith(mappedUser)
})
dist 或生成产物的测试已明确是 artifact / package / release 风格。有任一项无法勾选,就不要声称这是稳定、可维护的测试保护。