spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

mods: the README says how a mod's tests run and what they seeBrowse files
poteat authored on Sep 11, 2026 parent 6cdd796 · commit 9ebb685d8b83
1 changed file+43 -1compared with 6cdd796
Mmods/README.md
@@ -14,10 +14,52 @@
1414 Each folder is a complete plugin: `.claude-plugin/plugin.json`, a
1515 `hooks/hooks.json` naming the module, and TypeScript under `hooks/` typed
1616 against the declarations `/plugin-types` writes (`import type … from
17-'claude-code'`). To read one running from source:
17+'claude-code'`), kept here in `types/`. To read one running from source:
1818
1919 claude --plugin-dir mods/diff
2020
21+## Testing
22+
23+A mod's tests are in its `tests/` folder, and run with
24+
25+ claude plugin test mods/diff
26+
27+A test gets the engine's own `$` and a plugin's `on`. Each call on `$` is one
28+the engine makes, through every hook of the mod loaded as it ships. The hooks
29+the test registers with `on` sit beneath the mod, where the rest of the world
30+would be, and nothing is beneath them: a call they leave unanswered throws,
31+naming its event.
32+
33+```ts
34+import { expect, seat, test } from 'claude-code/testing'
35+
36+seat('builtin')
37+
38+test('outside a git repository /diff says so and opens nothing', async ($, on) => {
39+ const opened: string[] = []
40+ on('session.start', ($, e) => ({ cwd: e.cwd }))
41+ on('command.register', ($, e) => ({ value: { command: e.name } }))
42+ on('process.run', () => ({ value: { exitCode: 128, stdout: '', stderr: '' } }))
43+ on('ui.open', ($, e, next) => {
44+ opened.push(e.id)
45+ return next(e)
46+ })
47+
48+ await $.session.start({ surface: 'terminal', isInteractive: true, cwd: '/work' })
49+ const { text } = await $.command.run({
50+ command: 'diff',
51+ args: '',
52+ origin: { kind: 'composer' },
53+ })
54+
55+ expect(text).toContain('isn’t in a git repository')
56+ expect(opened).toEqual([])
57+})
58+```
59+
60+`tsc -p mods/tsconfig.json` typechecks every mod's hooks and tests against
61+`types/`.
62+
2163 Early access: hooks modules load only where function hooks are enabled, and
2264 the API these mods are written against may change between releases without
2365 notice. They are not listed in this repository's marketplace; the copies that