skilledagent 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/AGENTS.MD +44 -0
- package/.agents/AGENTS_README.md +125 -0
- package/.agents/CONTEXT.md +19 -0
- package/.agents/skills/ask-matt/SKILL.md +76 -0
- package/.agents/skills/claude-handoff/SKILL.md +18 -0
- package/.agents/skills/code-review/SKILL.md +89 -0
- package/.agents/skills/codebase-design/DEEPENING.md +37 -0
- package/.agents/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
- package/.agents/skills/codebase-design/SKILL.md +114 -0
- package/.agents/skills/design-an-interface/SKILL.md +94 -0
- package/.agents/skills/diagnosing-bugs/SKILL.md +134 -0
- package/.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +41 -0
- package/.agents/skills/domain-modeling/ADR-FORMAT.md +47 -0
- package/.agents/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
- package/.agents/skills/domain-modeling/SKILL.md +74 -0
- package/.agents/skills/edit-article/SKILL.md +15 -0
- package/.agents/skills/git-guardrails-claude-code/SKILL.md +95 -0
- package/.agents/skills/git-guardrails-claude-code/scripts/block-dangerous-git.sh +25 -0
- package/.agents/skills/grill-me/SKILL.md +7 -0
- package/.agents/skills/grill-with-docs/SKILL.md +7 -0
- package/.agents/skills/grilling/SKILL.md +12 -0
- package/.agents/skills/handoff/SKILL.md +16 -0
- package/.agents/skills/implement/SKILL.md +15 -0
- package/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
- package/.agents/skills/improve-codebase-architecture/SKILL.md +66 -0
- package/.agents/skills/loop-me/SKILL.md +32 -0
- package/.agents/skills/migrate-to-shoehorn/SKILL.md +118 -0
- package/.agents/skills/obsidian-vault/SKILL.md +59 -0
- package/.agents/skills/prototype/LOGIC.md +79 -0
- package/.agents/skills/prototype/SKILL.md +26 -0
- package/.agents/skills/prototype/UI.md +112 -0
- package/.agents/skills/qa/SKILL.md +130 -0
- package/.agents/skills/request-refactor-plan/SKILL.md +68 -0
- package/.agents/skills/research/SKILL.md +12 -0
- package/.agents/skills/resolving-merge-conflicts/SKILL.md +14 -0
- package/.agents/skills/scaffold-exercises/SKILL.md +106 -0
- package/.agents/skills/setup-matt-pocock-skills/SKILL.md +116 -0
- package/.agents/skills/setup-matt-pocock-skills/domain.md +51 -0
- package/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +45 -0
- package/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +46 -0
- package/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +30 -0
- package/.agents/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
- package/.agents/skills/setup-pre-commit/SKILL.md +91 -0
- package/.agents/skills/setup-ts-deep-modules/SKILL.md +102 -0
- package/.agents/skills/setup-ts-deep-modules/dependency-cruiser.config.cjs +95 -0
- package/.agents/skills/tdd/SKILL.md +36 -0
- package/.agents/skills/tdd/mocking.md +59 -0
- package/.agents/skills/tdd/tests.md +77 -0
- package/.agents/skills/teach/GLOSSARY-FORMAT.md +35 -0
- package/.agents/skills/teach/LEARNING-RECORD-FORMAT.md +46 -0
- package/.agents/skills/teach/MISSION-FORMAT.md +31 -0
- package/.agents/skills/teach/RESOURCES-FORMAT.md +32 -0
- package/.agents/skills/teach/SKILL.md +140 -0
- package/.agents/skills/to-spec/SKILL.md +75 -0
- package/.agents/skills/to-tickets/SKILL.md +107 -0
- package/.agents/skills/triage/AGENT-BRIEF.md +207 -0
- package/.agents/skills/triage/OUT-OF-SCOPE.md +105 -0
- package/.agents/skills/triage/SKILL.md +112 -0
- package/.agents/skills/ubiquitous-language/SKILL.md +93 -0
- package/.agents/skills/wayfinder/SKILL.md +127 -0
- package/.agents/skills/wizard/SKILL.md +45 -0
- package/.agents/skills/wizard/template.sh +211 -0
- package/.agents/skills/writing-beats/SKILL.md +67 -0
- package/.agents/skills/writing-fragments/SKILL.md +79 -0
- package/.agents/skills/writing-great-skills/GLOSSARY.md +201 -0
- package/.agents/skills/writing-great-skills/SKILL.md +83 -0
- package/.agents/skills/writing-shape/SKILL.md +79 -0
- package/.agents/skills-lock.json +233 -0
- package/.agents/workflows/kickoff.md +211 -0
- package/README.md +63 -0
- package/bin/cli.js +24 -0
- package/package.json +28 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-pre-commit
|
|
3
|
+
description: Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Setup Pre-Commit Hooks
|
|
7
|
+
|
|
8
|
+
## What This Sets Up
|
|
9
|
+
|
|
10
|
+
- **Husky** pre-commit hook
|
|
11
|
+
- **lint-staged** running Prettier on all staged files
|
|
12
|
+
- **Prettier** config (if missing)
|
|
13
|
+
- **typecheck** and **test** scripts in the pre-commit hook
|
|
14
|
+
|
|
15
|
+
## Steps
|
|
16
|
+
|
|
17
|
+
### 1. Detect package manager
|
|
18
|
+
|
|
19
|
+
Check for `package-lock.json` (npm), `pnpm-lock.yaml` (pnpm), `yarn.lock` (yarn), `bun.lockb` (bun). Use whichever is present. Default to npm if unclear.
|
|
20
|
+
|
|
21
|
+
### 2. Install dependencies
|
|
22
|
+
|
|
23
|
+
Install as devDependencies:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
husky lint-staged prettier
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 3. Initialize Husky
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx husky init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This creates `.husky/` dir and adds `prepare: "husky"` to package.json.
|
|
36
|
+
|
|
37
|
+
### 4. Create `.husky/pre-commit`
|
|
38
|
+
|
|
39
|
+
Write this file (no shebang needed for Husky v9+):
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
npx lint-staged
|
|
43
|
+
npm run typecheck
|
|
44
|
+
npm run test
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Adapt**: Replace `npm` with detected package manager. If repo has no `typecheck` or `test` script in package.json, omit those lines and tell the user.
|
|
48
|
+
|
|
49
|
+
### 5. Create `.lintstagedrc`
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"*": "prettier --ignore-unknown --write"
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 6. Create `.prettierrc` (if missing)
|
|
58
|
+
|
|
59
|
+
Only create if no Prettier config exists. Use these defaults:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"useTabs": false,
|
|
64
|
+
"tabWidth": 2,
|
|
65
|
+
"printWidth": 80,
|
|
66
|
+
"singleQuote": false,
|
|
67
|
+
"trailingComma": "es5",
|
|
68
|
+
"semi": true,
|
|
69
|
+
"arrowParens": "always"
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 7. Verify
|
|
74
|
+
|
|
75
|
+
- [ ] `.husky/pre-commit` exists and is executable
|
|
76
|
+
- [ ] `.lintstagedrc` exists
|
|
77
|
+
- [ ] `prepare` script in package.json is `"husky"`
|
|
78
|
+
- [ ] `prettier` config exists
|
|
79
|
+
- [ ] Run `npx lint-staged` to verify it works
|
|
80
|
+
|
|
81
|
+
### 8. Commit
|
|
82
|
+
|
|
83
|
+
Stage all changed/created files and commit with message: `Add pre-commit hooks (husky + lint-staged + prettier)`
|
|
84
|
+
|
|
85
|
+
This will run through the new pre-commit hooks — a good smoke test that everything works.
|
|
86
|
+
|
|
87
|
+
## Notes
|
|
88
|
+
|
|
89
|
+
- Husky v9+ doesn't need shebangs in hook files
|
|
90
|
+
- `prettier --ignore-unknown` skips files Prettier can't parse (images, etc.)
|
|
91
|
+
- The pre-commit runs lint-staged first (fast, staged-only), then full typecheck and tests
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-ts-deep-modules
|
|
3
|
+
description: Wire dependency-cruiser into a TypeScript repo so each package is a deep module — implementation hidden in subfolders, reachable only through its entry-point files. User-invoked.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Setup TS Deep Modules
|
|
8
|
+
|
|
9
|
+
Make every package in this repo a **deep module**: a lot of behaviour behind a small interface. A package's public surface is its **entry points** — the files at the package root — and everything in its subfolders is hidden. This skill installs [dependency-cruiser](https://github.com/sverweij/dependency-cruiser) and the rules that make the entry points the only way in, then proves the rules bite.
|
|
10
|
+
|
|
11
|
+
For the vocabulary (deep module, interface, seam, depth), run the `/codebase-design` skill — use its language throughout.
|
|
12
|
+
|
|
13
|
+
## The shape this enforces
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
src/packages/
|
|
17
|
+
<name>/
|
|
18
|
+
index.ts ← an entry point (public). Import this from outside.
|
|
19
|
+
client.ts ← another entry point. Packages may expose SEVERAL.
|
|
20
|
+
lib/ ← implementation: hidden from outside, free to import each other.
|
|
21
|
+
tests/ ← co-located tests + fixtures (a subfolder, so private).
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The public surface is the package's **root files** — not one designated `index.ts`. By convention implementation lives in `lib/` and tests in `tests/`, giving every package the same two-folder shape. The rule itself is general, though: *anything* in *any* subfolder is private, so you never extend the config to add a folder.
|
|
25
|
+
|
|
26
|
+
Four rules, all `error`:
|
|
27
|
+
|
|
28
|
+
1. **Entry-point boundary** — code outside a package (app code or another package) may import only that package's entry points (its root files), never anything in its subfolders.
|
|
29
|
+
2. **Intra-package freedom** — a package's own files import each other freely.
|
|
30
|
+
3. **Tests through the entry points** — files under `<pkg>/tests/` may import any package's entry points and their own `tests/` fixtures, but never any package's subfolder internals (not even their own). Integration tests across packages are fine; deep imports are not.
|
|
31
|
+
4. **No cycles** — no dependency cycles.
|
|
32
|
+
|
|
33
|
+
**Entry points, not a barrel.** Because the public surface is *every* root file, a package can expose several small entry points (`index.ts`, `client.ts`, `server.ts`) instead of funnelling everything through one giant `index.ts`. Barrel files that re-export a whole subtree are discouraged — keep entry points small and hide implementation in subfolders.
|
|
34
|
+
|
|
35
|
+
Layering (which packages may depend on which) is a *different* concern and is left as a commented stub in the config for this repo to fill in.
|
|
36
|
+
|
|
37
|
+
## Steps
|
|
38
|
+
|
|
39
|
+
### 1. Detect the environment
|
|
40
|
+
|
|
41
|
+
- **Package manager** — `pnpm-lock.yaml` → pnpm, `yarn.lock` → yarn, `bun.lockb` → bun, else npm. Use it for every command below (`pnpm`/`yarn`/`npm run`/`bunx`).
|
|
42
|
+
- **Packages root** — if `src/` exists use `src/packages`, else `packages`. Confirm the choice with the user if the repo already has a different obvious convention.
|
|
43
|
+
- **Existing config** — check for a `.dependency-cruiser.*` file. If one exists, do **not** overwrite it: merge the four rules and the options in, and tell the user what you added.
|
|
44
|
+
|
|
45
|
+
**Done when:** package manager, packages root, and existing-config status are all known.
|
|
46
|
+
|
|
47
|
+
### 2. Install dependency-cruiser
|
|
48
|
+
|
|
49
|
+
Install `dependency-cruiser` as a devDependency with the detected package manager.
|
|
50
|
+
|
|
51
|
+
**Done when:** `dependency-cruiser` is in `devDependencies`.
|
|
52
|
+
|
|
53
|
+
### 3. Write the config
|
|
54
|
+
|
|
55
|
+
Copy [`dependency-cruiser.config.cjs`](./dependency-cruiser.config.cjs) to the repo root as `.dependency-cruiser.cjs`. Set `PACKAGES_ROOT` to the root detected in step 1. The rules are path-depth based and extension-agnostic, so nothing else needs adapting.
|
|
56
|
+
|
|
57
|
+
**Done when:** `.dependency-cruiser.cjs` exists with the correct `PACKAGES_ROOT`, and the four forbidden rules are present.
|
|
58
|
+
|
|
59
|
+
### 4. Wire it into the checks
|
|
60
|
+
|
|
61
|
+
- Add a `lint:boundaries` script: `depcruise <packages-root>` (or `depcruise src`).
|
|
62
|
+
- Fold it into the repo's umbrella check command — the one that already runs typecheck (e.g. a `check` / `ci` / `validate` script). Do **not** touch `tsconfig` or add path aliases.
|
|
63
|
+
- If there is no umbrella script, add `lint:boundaries` and tell the user to include it in CI.
|
|
64
|
+
|
|
65
|
+
**Done when:** `lint:boundaries` exists and runs as part of the same command as typecheck.
|
|
66
|
+
|
|
67
|
+
### 5. Scaffold the example package
|
|
68
|
+
|
|
69
|
+
Create a committed `<packages-root>/example/` as a copy-me template:
|
|
70
|
+
|
|
71
|
+
- `index.ts` — an entry point. Export one function that delegates to an internal file (so the package is visibly *deep*, not a pass-through).
|
|
72
|
+
- `lib/impl.ts` — an internal file in a **subfolder**, imported by `index.ts`, not reachable from outside.
|
|
73
|
+
- `tests/example.test.ts` — imports **only** `../index` (an entry point), and asserts against the public function.
|
|
74
|
+
|
|
75
|
+
Tell the user this is a starter template to copy or delete.
|
|
76
|
+
|
|
77
|
+
**Done when:** the example package exists, exposes its behaviour through a root entry point, and hides `impl` in a subfolder.
|
|
78
|
+
|
|
79
|
+
### 6. Prove the rules bite
|
|
80
|
+
|
|
81
|
+
This is the completion criterion for the whole skill — a config that doesn't fail on a violation is worthless.
|
|
82
|
+
|
|
83
|
+
1. Run `lint:boundaries`. It must **pass** on the clean example.
|
|
84
|
+
2. Temporarily add a deep import to `tests/example.test.ts` (e.g. `import { thing } from "../lib/impl"`). Run `lint:boundaries` again — it must **fail** with `tests-through-entrypoints`.
|
|
85
|
+
3. Revert the deep import. Run once more — it must **pass**.
|
|
86
|
+
|
|
87
|
+
**Done when:** you have observed a pass, then a fail on the deep import, then a pass again. If step 2 does not fail, the rules are not wired correctly — fix before finishing.
|
|
88
|
+
|
|
89
|
+
### 7. Document the convention
|
|
90
|
+
|
|
91
|
+
Write a `README.md` **in the packages folder** (`<packages-root>/README.md`) — next to the packages it governs — covering: the `src/packages/<name>/` layout (entry points at the root, `lib/` for implementation, `tests/` for tests), "import only through a package's entry points (its root files)", and how to run `lint:boundaries`. **Discourage barrel files** explicitly — expose several small entry points instead of re-exporting a whole subtree through one index. Keep it to the copy-me snippet plus the four rules in one paragraph each.
|
|
92
|
+
|
|
93
|
+
Then add a **context pointer** to it from the repo's agent-instructions file — `CLAUDE.md` if present, else `AGENTS.md` (create `AGENTS.md` if neither exists). One line is enough, e.g. `Packages are deep modules — see [src/packages/README.md](./src/packages/README.md) before adding or importing one.` This is what makes an agent discover the boundary rule instead of tripping over it.
|
|
94
|
+
|
|
95
|
+
**Done when:** `<packages-root>/README.md` exists and discourages barrels, and the repo's `CLAUDE.md`/`AGENTS.md` links to it.
|
|
96
|
+
|
|
97
|
+
## Notes
|
|
98
|
+
|
|
99
|
+
- The config's `$1` back-references (dependency-cruiser's group matching) are what let a package reach its own internals while outsiders can't — don't flatten them into separate per-package rules.
|
|
100
|
+
- Public vs private is decided by **depth**: a package's root files are entry points; anything in a subfolder is private. The conventional subfolders are `lib/` (implementation) and `tests/`, but the rule doesn't hardcode them — any subfolder is private, so a new folder never needs a config change. Adding an entry point is just adding a root file — no barrel.
|
|
101
|
+
- Packages are **flat**: one tier of immediate children under the root. A package's internals may nest as deep as you like; a package may not contain another package.
|
|
102
|
+
- Use `.cjs` (not `.js`) so the config's `module.exports` works even in `"type": "module"` repos.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Deep-module enforcement for dependency-cruiser.
|
|
3
|
+
//
|
|
4
|
+
// Each package under the packages root is a DEEP MODULE: a lot of behaviour
|
|
5
|
+
// behind a small interface. A package's PUBLIC SURFACE is its ENTRY POINTS —
|
|
6
|
+
// the files at the package root. Implementation lives in SUBFOLDERS and is
|
|
7
|
+
// private — by convention `lib/` for implementation and `tests/` for tests,
|
|
8
|
+
// though any subfolder is private. A package may expose several small entry
|
|
9
|
+
// points (index.ts, client.ts, server.ts, …) — prefer that over one giant
|
|
10
|
+
// barrel index.
|
|
11
|
+
//
|
|
12
|
+
// The only thing you should ever need to edit here is PACKAGES_ROOT.
|
|
13
|
+
|
|
14
|
+
/** Where packages live. One immediate child dir per package (flat, no nesting). */
|
|
15
|
+
const PACKAGES_ROOT = "src/packages";
|
|
16
|
+
|
|
17
|
+
// --- derived patterns (no need to edit) -------------------------------------
|
|
18
|
+
const R = PACKAGES_ROOT;
|
|
19
|
+
/**
|
|
20
|
+
* A package's private internals: anything nested inside a package subfolder.
|
|
21
|
+
* The package's root files are its entry points and are NOT matched here —
|
|
22
|
+
* they stay importable from outside.
|
|
23
|
+
*/
|
|
24
|
+
const PACKAGE_INTERNALS = `^${R}/[^/]+/[^/]+/`;
|
|
25
|
+
|
|
26
|
+
/** @type {import('dependency-cruiser').IConfiguration} */
|
|
27
|
+
module.exports = {
|
|
28
|
+
forbidden: [
|
|
29
|
+
{
|
|
30
|
+
name: "entrypoint-boundary-from-app",
|
|
31
|
+
comment:
|
|
32
|
+
"App/root code may import a package's entry points (its root files), but nothing inside its subfolders.",
|
|
33
|
+
severity: "error",
|
|
34
|
+
from: { pathNot: `^${R}/` }, // importer is NOT inside any package
|
|
35
|
+
to: { path: PACKAGE_INTERNALS },
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "entrypoint-boundary-across-packages",
|
|
39
|
+
comment:
|
|
40
|
+
"A package's own files import each other freely, but may reach OTHER packages only through their entry points — never their internals.",
|
|
41
|
+
severity: "error",
|
|
42
|
+
// importer is inside a package ($1), but is not a test file
|
|
43
|
+
from: { path: `^${R}/([^/]+)/`, pathNot: `^${R}/[^/]+/tests/` },
|
|
44
|
+
to: {
|
|
45
|
+
path: PACKAGE_INTERNALS,
|
|
46
|
+
pathNot: `^${R}/$1/`, // same package → intra-package freedom
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "tests-through-entrypoints",
|
|
51
|
+
comment:
|
|
52
|
+
"A package's tests exercise it through its entry points like everyone else: they may import any package's entry points and their own tests/ fixtures, but never any package's internals — not even their own.",
|
|
53
|
+
severity: "error",
|
|
54
|
+
from: { path: `^${R}/([^/]+)/tests/` }, // a test file, in package $1
|
|
55
|
+
to: {
|
|
56
|
+
path: PACKAGE_INTERNALS,
|
|
57
|
+
pathNot: `^${R}/$1/tests/`, // own tests/ fixtures → allowed
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "tests-folder-is-private",
|
|
62
|
+
comment:
|
|
63
|
+
"A package's tests/ folder is reachable only from tests — nothing else may import fixtures.",
|
|
64
|
+
severity: "error",
|
|
65
|
+
from: { pathNot: `^${R}/[^/]+/tests/` }, // importer is not itself a test
|
|
66
|
+
to: { path: `^${R}/[^/]+/tests/` },
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "no-circular",
|
|
70
|
+
comment: "No dependency cycles. Scope to `^${R}/` if you want to allow cycles outside packages.",
|
|
71
|
+
severity: "error",
|
|
72
|
+
from: {},
|
|
73
|
+
to: { circular: true },
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
// --- Layering (optional, off by default) ----------------------------------
|
|
77
|
+
// Interface-hiding controls HOW you import (through the entry points).
|
|
78
|
+
// Layering controls WHICH packages may depend on which. Add your own rules
|
|
79
|
+
// here, e.g.:
|
|
80
|
+
//
|
|
81
|
+
// {
|
|
82
|
+
// name: "ui-may-not-depend-on-billing",
|
|
83
|
+
// severity: "error",
|
|
84
|
+
// from: { path: `^${R}/ui/` },
|
|
85
|
+
// to: { path: `^${R}/billing/` },
|
|
86
|
+
// },
|
|
87
|
+
],
|
|
88
|
+
options: {
|
|
89
|
+
doNotFollow: { path: "node_modules" },
|
|
90
|
+
tsConfig: { fileName: "tsconfig.json" },
|
|
91
|
+
enhancedResolveOptions: {
|
|
92
|
+
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tdd
|
|
3
|
+
description: Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Test-Driven Development
|
|
7
|
+
|
|
8
|
+
TDD is the red → green loop. This skill is the reference that makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies on every cycle — consult them before and during the loop, not after.
|
|
9
|
+
|
|
10
|
+
When exploring the codebase, read `CONTEXT.md` (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.
|
|
11
|
+
|
|
12
|
+
## What a good test is
|
|
13
|
+
|
|
14
|
+
Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification — "user can checkout with valid cart" tells you exactly what capability exists — and survives refactors because it doesn't care about internal structure.
|
|
15
|
+
|
|
16
|
+
See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
|
|
17
|
+
|
|
18
|
+
## Seams — where tests go
|
|
19
|
+
|
|
20
|
+
A **seam** is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.
|
|
21
|
+
|
|
22
|
+
**Test only at pre-agreed seams.** Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. You can't test everything — agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.
|
|
23
|
+
|
|
24
|
+
Ask: "What's the public interface, and which seams should we test?"
|
|
25
|
+
|
|
26
|
+
## Anti-patterns
|
|
27
|
+
|
|
28
|
+
- **Implementation-coupled** — mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
|
|
29
|
+
- **Tautological** — the assertion recomputes the expected value the way the code does (`expect(add(a, b)).toBe(a + b)`, a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth — a known-good literal, a worked example, the spec.
|
|
30
|
+
- **Horizontal slicing** — writing all tests first, then all implementation. Bulk tests verify _imagined_ behavior: you test the _shape_ of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in **vertical slices** instead — one test → one implementation → repeat, each test a **tracer bullet** that responds to what the last cycle taught you.
|
|
31
|
+
|
|
32
|
+
## Rules of the loop
|
|
33
|
+
|
|
34
|
+
- **Red before green.** Write the failing test first, then only enough code to pass it. Don't anticipate future tests or add speculative features.
|
|
35
|
+
- **One slice at a time.** One seam, one test, one minimal implementation per cycle.
|
|
36
|
+
- **Refactoring is not part of the loop.** It belongs to the review stage (see the `code-review` skill), not the red → green implementation cycle.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# When to Mock
|
|
2
|
+
|
|
3
|
+
Mock at **system boundaries** only:
|
|
4
|
+
|
|
5
|
+
- External APIs (payment, email, etc.)
|
|
6
|
+
- Databases (sometimes - prefer test DB)
|
|
7
|
+
- Time/randomness
|
|
8
|
+
- File system (sometimes)
|
|
9
|
+
|
|
10
|
+
Don't mock:
|
|
11
|
+
|
|
12
|
+
- Your own classes/modules
|
|
13
|
+
- Internal collaborators
|
|
14
|
+
- Anything you control
|
|
15
|
+
|
|
16
|
+
## Designing for Mockability
|
|
17
|
+
|
|
18
|
+
At system boundaries, design interfaces that are easy to mock:
|
|
19
|
+
|
|
20
|
+
**1. Use dependency injection**
|
|
21
|
+
|
|
22
|
+
Pass external dependencies in rather than creating them internally:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// Easy to mock
|
|
26
|
+
function processPayment(order, paymentClient) {
|
|
27
|
+
return paymentClient.charge(order.total);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Hard to mock
|
|
31
|
+
function processPayment(order) {
|
|
32
|
+
const client = new StripeClient(process.env.STRIPE_KEY);
|
|
33
|
+
return client.charge(order.total);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**2. Prefer SDK-style interfaces over generic fetchers**
|
|
38
|
+
|
|
39
|
+
Create specific functions for each external operation instead of one generic function with conditional logic:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// GOOD: Each function is independently mockable
|
|
43
|
+
const api = {
|
|
44
|
+
getUser: (id) => fetch(`/users/${id}`),
|
|
45
|
+
getOrders: (userId) => fetch(`/users/${userId}/orders`),
|
|
46
|
+
createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// BAD: Mocking requires conditional logic inside the mock
|
|
50
|
+
const api = {
|
|
51
|
+
fetch: (endpoint, options) => fetch(endpoint, options),
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The SDK approach means:
|
|
56
|
+
- Each mock returns one specific shape
|
|
57
|
+
- No conditional logic in test setup
|
|
58
|
+
- Easier to see which endpoints a test exercises
|
|
59
|
+
- Type safety per endpoint
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Good and Bad Tests
|
|
2
|
+
|
|
3
|
+
## Good Tests
|
|
4
|
+
|
|
5
|
+
**Integration-style**: Test through real interfaces, not mocks of internal parts.
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// GOOD: Tests observable behavior
|
|
9
|
+
test("user can checkout with valid cart", async () => {
|
|
10
|
+
const cart = createCart();
|
|
11
|
+
cart.add(product);
|
|
12
|
+
const result = await checkout(cart, paymentMethod);
|
|
13
|
+
expect(result.status).toBe("confirmed");
|
|
14
|
+
});
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Characteristics:
|
|
18
|
+
|
|
19
|
+
- Tests behavior users/callers care about
|
|
20
|
+
- Uses public API only
|
|
21
|
+
- Survives internal refactors
|
|
22
|
+
- Describes WHAT, not HOW
|
|
23
|
+
- One logical assertion per test
|
|
24
|
+
|
|
25
|
+
## Bad Tests
|
|
26
|
+
|
|
27
|
+
**Implementation-detail tests**: Coupled to internal structure.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// BAD: Tests implementation details
|
|
31
|
+
test("checkout calls paymentService.process", async () => {
|
|
32
|
+
const mockPayment = jest.mock(paymentService);
|
|
33
|
+
await checkout(cart, payment);
|
|
34
|
+
expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Red flags:
|
|
39
|
+
|
|
40
|
+
- Mocking internal collaborators
|
|
41
|
+
- Testing private methods
|
|
42
|
+
- Asserting on call counts/order
|
|
43
|
+
- Test breaks when refactoring without behavior change
|
|
44
|
+
- Test name describes HOW not WHAT
|
|
45
|
+
- Verifying through external means instead of interface
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// BAD: Bypasses interface to verify
|
|
49
|
+
test("createUser saves to database", async () => {
|
|
50
|
+
await createUser({ name: "Alice" });
|
|
51
|
+
const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
|
|
52
|
+
expect(row).toBeDefined();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// GOOD: Verifies through interface
|
|
56
|
+
test("createUser makes user retrievable", async () => {
|
|
57
|
+
const user = await createUser({ name: "Alice" });
|
|
58
|
+
const retrieved = await getUser(user.id);
|
|
59
|
+
expect(retrieved.name).toBe("Alice");
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Tautological tests**: Expected value restates the implementation, so the test passes by construction.
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// BAD: Expected value is recomputed the way the code computes it
|
|
67
|
+
test("calculateTotal sums line items", () => {
|
|
68
|
+
const items = [{ price: 10 }, { price: 5 }];
|
|
69
|
+
const expected = items.reduce((sum, i) => sum + i.price, 0);
|
|
70
|
+
expect(calculateTotal(items)).toBe(expected);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// GOOD: Expected value is an independent, known literal
|
|
74
|
+
test("calculateTotal sums line items", () => {
|
|
75
|
+
expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15);
|
|
76
|
+
});
|
|
77
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# GLOSSARY.md Format
|
|
2
|
+
|
|
3
|
+
`GLOSSARY.md` is the canonical language for this teaching workspace. All explainers, exercises, and learning records should adhere to its terminology. Building it is itself part of learning: compressing a concept into a tight definition is evidence the user understands it.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
```md
|
|
8
|
+
# {Topic} Glossary
|
|
9
|
+
|
|
10
|
+
{One or two sentence description of the topic this glossary covers.}
|
|
11
|
+
|
|
12
|
+
## Terms
|
|
13
|
+
|
|
14
|
+
**Hypertrophy**:
|
|
15
|
+
Muscle growth driven by mechanical tension and metabolic stress over repeated training sessions.
|
|
16
|
+
_Avoid_: Bulking, getting big
|
|
17
|
+
|
|
18
|
+
**Progressive overload**:
|
|
19
|
+
Systematically increasing the demand on a muscle over time — via load, volume, or intensity.
|
|
20
|
+
_Avoid_: Pushing harder, levelling up
|
|
21
|
+
|
|
22
|
+
**RPE (Rate of Perceived Exertion)**:
|
|
23
|
+
A 1–10 self-rating of how hard a set felt, where 10 is failure and 8 means two reps left in the tank.
|
|
24
|
+
_Avoid_: Effort score, intensity rating
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Rules
|
|
28
|
+
|
|
29
|
+
- **Add a term only when the user understands it.** The glossary is a record of compressed knowledge, not a dictionary the user reads to learn. If the user has just been introduced to a concept, wait until they can use it correctly before promoting it here.
|
|
30
|
+
- **Be opinionated.** When several words exist for the same concept, pick the best one and list the rest as aliases to avoid. This is how language compresses.
|
|
31
|
+
- **Keep definitions tight.** One or two sentences. Define what the term IS, not what it does or how to do it.
|
|
32
|
+
- **Use the glossary's own terms inside definitions.** Once a term is in the glossary, prefer it everywhere — including inside other definitions. This is what makes complex terms easier to grasp later.
|
|
33
|
+
- **Group under subheadings** when natural clusters emerge (e.g. `## Anatomy`, `## Programming`). A flat list is fine when terms cohere.
|
|
34
|
+
- **Flag ambiguities explicitly.** If a term is used loosely in the wider field, note the resolution: "In this workspace, 'set' always means a working set — warm-ups are tracked separately."
|
|
35
|
+
- **Revise as understanding deepens.** A definition the user wrote in week one may be wrong by week six. Update in place; do not leave stale entries.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Learning Record Format
|
|
2
|
+
|
|
3
|
+
Learning records live in `./learning-records/` and use sequential numbering: `0001-slug.md`, `0002-slug.md`, etc. Create the directory lazily — only when the first record is written.
|
|
4
|
+
|
|
5
|
+
They are the teaching equivalent of ADRs: they capture non-obvious lessons, key insights, and stated prior knowledge that will steer future sessions. They are used to calculate the zone of proximal development.
|
|
6
|
+
|
|
7
|
+
## Template
|
|
8
|
+
|
|
9
|
+
```md
|
|
10
|
+
# {Short title of what was learned or established}
|
|
11
|
+
|
|
12
|
+
{1-3 sentences: what was learned (or what prior knowledge was established), and why it matters for future sessions.}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
That is the whole format. A learning record can be a single paragraph. The value is recording _that_ this is now known and _why_ it changes what to teach next — not in filling out sections.
|
|
16
|
+
|
|
17
|
+
## Optional sections
|
|
18
|
+
|
|
19
|
+
Only include these when they add genuine value. Most records won't need them.
|
|
20
|
+
|
|
21
|
+
- **Status** frontmatter (`active | superseded by LR-NNNN`) — useful when an earlier understanding turns out to be wrong and is replaced.
|
|
22
|
+
- **Evidence** — how the user demonstrated the understanding (a question answered, an exercise completed, prior experience cited). Useful when the claim might be revisited.
|
|
23
|
+
- **Implications** — what this unlocks or rules out for future sessions. Worth recording when non-obvious.
|
|
24
|
+
|
|
25
|
+
## Numbering
|
|
26
|
+
|
|
27
|
+
Scan `./learning-records/` for the highest existing number and increment by one.
|
|
28
|
+
|
|
29
|
+
## When to write a learning record
|
|
30
|
+
|
|
31
|
+
Write one when any of these is true:
|
|
32
|
+
|
|
33
|
+
1. **The user demonstrated genuine understanding of something non-trivial** — not just exposure, but evidence they can use the concept correctly. This sets a new floor for what to teach next.
|
|
34
|
+
2. **The user disclosed prior knowledge** — "I already know X." Record it so future sessions don't re-teach it. Also record the _depth_ claimed.
|
|
35
|
+
3. **A misconception was corrected** — the user previously believed something wrong and now sees why. These are high-value: they predict future stumbling blocks for related topics.
|
|
36
|
+
4. **The mission shifted in response to learning** — the user discovered they cared about something different than they thought. Cross-link to [[MISSION.md]] and update it.
|
|
37
|
+
|
|
38
|
+
### What does _not_ qualify
|
|
39
|
+
|
|
40
|
+
- Material that was merely covered. Coverage is not learning. Wait for evidence.
|
|
41
|
+
- Anything already captured tersely in [[GLOSSARY.md]] as a term definition. Don't duplicate.
|
|
42
|
+
- Session-by-session activity logs. Learning records are not a journal — they are decision-grade insights.
|
|
43
|
+
|
|
44
|
+
## Supersession
|
|
45
|
+
|
|
46
|
+
When a later record contradicts an earlier one (the user's understanding deepened or corrected), mark the old record `Status: superseded by LR-NNNN` rather than deleting it. The history of how understanding evolved is itself useful signal.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# MISSION.md Format
|
|
2
|
+
|
|
3
|
+
`MISSION.md` lives at the workspace root. It captures the _reason_ the user is learning this topic. Every teaching decision — what to teach next, which resources to surface, which exercises to design — should trace back to this document.
|
|
4
|
+
|
|
5
|
+
## Template
|
|
6
|
+
|
|
7
|
+
```md
|
|
8
|
+
# Mission: {Topic}
|
|
9
|
+
|
|
10
|
+
## Why
|
|
11
|
+
{1-3 sentences. The concrete real-world goal the user is chasing. What changes in their life or work when they have this skill? Avoid abstract framings like "to understand X" — push for the underlying outcome.}
|
|
12
|
+
|
|
13
|
+
## Success looks like
|
|
14
|
+
- {A specific, observable thing the user will be able to do}
|
|
15
|
+
- {Another specific thing}
|
|
16
|
+
- {…}
|
|
17
|
+
|
|
18
|
+
## Constraints
|
|
19
|
+
- {Time, budget, prior commitments, learning preferences, anything that bounds the approach}
|
|
20
|
+
|
|
21
|
+
## Out of scope
|
|
22
|
+
- {Adjacent topics the user explicitly does not want to chase right now — protects the zone of proximal development}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Rules
|
|
26
|
+
|
|
27
|
+
- **One mission per workspace.** If the user wants to learn two unrelated things, that is two workspaces.
|
|
28
|
+
- **Concrete over abstract.** "Run a half marathon by October" beats "get fitter." "Ship a Rust CLI to my team" beats "learn Rust."
|
|
29
|
+
- **Push back on vagueness.** If the user cannot articulate why, interview them before writing anything. A bad mission is worse than no mission.
|
|
30
|
+
- **Revise when reality shifts.** Missions change. When the user's goal moves, update this file — don't leave a stale mission steering future sessions.
|
|
31
|
+
- **Keep it short.** If `MISSION.md` runs past a screen, it has stopped being a compass and started being a plan.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# RESOURCES.md Format
|
|
2
|
+
|
|
3
|
+
`RESOURCES.md` is the curated set of trusted sources for this topic. Knowledge for explainers should be drawn from here, not from parametric guesses. Wisdom comes from the communities listed here.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
```md
|
|
8
|
+
# {Topic} Resources
|
|
9
|
+
|
|
10
|
+
## Knowledge
|
|
11
|
+
|
|
12
|
+
- [Book: _The Science and Practice of Strength Training_ — Zatsiorsky & Kraemer](https://example.com)
|
|
13
|
+
Foundational text on programming and adaptation. Use for: anything to do with periodisation, recovery, intensity zones.
|
|
14
|
+
- [Article: "How Much Should I Train?" — Greg Nuckols (Stronger By Science)](https://example.com)
|
|
15
|
+
Evidence-based review of volume landmarks. Use for: weekly set targets per muscle group.
|
|
16
|
+
|
|
17
|
+
## Wisdom (Communities)
|
|
18
|
+
|
|
19
|
+
- [r/weightroom](https://reddit.com/r/weightroom)
|
|
20
|
+
High-signal subreddit, moderated against bro-science. Use for: programme critique, plateau troubleshooting.
|
|
21
|
+
- Local: Tuesday strength class at {gym name}
|
|
22
|
+
Use for: real-time coaching feedback on lifts.
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Rules
|
|
26
|
+
|
|
27
|
+
- **High-trust only.** Prefer primary sources, recognised experts, peer-reviewed work, and communities with strong moderation. If a resource is marketing dressed as education, leave it out.
|
|
28
|
+
- **Annotate every entry.** A bare link is useless in three months. Add one line: what it covers and when to reach for it.
|
|
29
|
+
- **Group by Knowledge / Wisdom.** Mirrors the philosophy in [SKILL.md](./SKILL.md). It is fine for a resource to appear in only one group.
|
|
30
|
+
- **Surface gaps explicitly.** If no good resource exists for an area the mission needs, write a `## Gaps` section listing what is missing. This drives future search.
|
|
31
|
+
- **Prune ruthlessly.** A resource that turned out to be wrong, shallow, or off-mission should be removed, not buried. Better five sharp sources than thirty mediocre ones.
|
|
32
|
+
- **Record community preferences.** If the user has opted out of joining communities, note it here so future sessions don't keep proposing them.
|