@sockulags/agent-os 0.11.0 → 0.12.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.
Files changed (43) hide show
  1. package/README.md +155 -127
  2. package/cli/index.mjs +1022 -735
  3. package/cli/index.test.mjs +574 -300
  4. package/hooks/hooks.json +17 -0
  5. package/package.json +34 -32
  6. package/policy.md +47 -45
  7. package/skills/batch-work/SKILL.md +43 -43
  8. package/skills/batch-work/agents/openai.yaml +2 -2
  9. package/skills/batch-work/references/manifest.md +100 -100
  10. package/skills/batch-work/scripts/manifest-hash.mjs +263 -263
  11. package/skills/batch-work/scripts/test-manifest-hash.mjs +132 -132
  12. package/skills/chart-work/SKILL.md +37 -37
  13. package/skills/chart-work/references/elicitation.md +25 -25
  14. package/skills/chart-work/references/map.md +84 -84
  15. package/skills/chart-work/references/prototypes.md +21 -21
  16. package/skills/check-work/SKILL.md +61 -0
  17. package/skills/deliver-work/SKILL.md +12 -12
  18. package/skills/deliver-work/workflow.md +119 -113
  19. package/skills/diagnose-before-fix/SKILL.md +24 -24
  20. package/skills/dispatch-next/SKILL.md +28 -28
  21. package/skills/init-agent-os/SKILL.md +54 -39
  22. package/skills/init-agent-os/references/repository-init.md +74 -0
  23. package/skills/init-agent-os/scripts/policy-block.ps1 +87 -87
  24. package/skills/list-skills/SKILL.md +43 -42
  25. package/skills/list-skills/agents/openai.yaml +2 -2
  26. package/skills/plain-voice/SKILL.md +39 -0
  27. package/skills/plain-voice/references/tells.md +82 -0
  28. package/skills/proportional-testing/SKILL.md +30 -30
  29. package/skills/proportional-testing/references/strategy.md +75 -75
  30. package/skills/quality-ratchet/SKILL.md +50 -0
  31. package/skills/quality-ratchet/scripts/quality-delta.mjs +752 -0
  32. package/skills/quality-ratchet/scripts/quality-delta.test.mjs +514 -0
  33. package/skills/scope-guard/SKILL.md +21 -21
  34. package/skills/shape-work/SKILL.md +39 -39
  35. package/skills/shape-work/references/implementation-issues.md +69 -69
  36. package/skills/shape-work/references/mockups.md +23 -23
  37. package/skills/simplifier/SKILL.md +34 -34
  38. package/skills/simplifier/agents/openai.yaml +2 -2
  39. package/skills/simplifier-audit/SKILL.md +28 -28
  40. package/skills/simplifier-audit/agents/openai.yaml +2 -2
  41. package/skills/simplifier-review/SKILL.md +36 -29
  42. package/skills/verify-before-done/SKILL.md +29 -29
  43. package/skills/writing-skills/SKILL.md +68 -68
@@ -1,87 +1,87 @@
1
- # Manages the AGENT OS block in global instruction files.
2
- # Source of truth: policy.md at the plugin root (two levels up from this script).
3
- #
4
- # Semantics (locked in the agent-os plan, M3):
5
- # - No block in target -> append exactly one block, preserve everything else.
6
- # - Empty target file -> treated as "no block"; the block becomes the whole file.
7
- # - Exactly one well-formed -> replace only the content between the markers.
8
- # - Duplicated, crossed, or half-open markers -> abort without mutation, exit 2.
9
- # - -Check -> read-only; exit 0 in sync, exit 1 on drift/missing, never writes.
10
- # - Text outside the block is never touched or normalized.
11
-
12
- [CmdletBinding()]
13
- param(
14
- [switch]$Check,
15
- [string[]]$Targets = @(
16
- (Join-Path (Join-Path $HOME '.claude') 'CLAUDE.md'),
17
- (Join-Path (Join-Path $HOME '.codex') 'AGENTS.md')
18
- )
19
- )
20
-
21
- $ErrorActionPreference = 'Stop'
22
- $BeginMarker = '<!-- BEGIN AGENT OS -->'
23
- $EndMarker = '<!-- END AGENT OS -->'
24
-
25
- $policyPath = Join-Path $PSScriptRoot '..\..\..\policy.md' | Resolve-Path
26
- $policy = (Get-Content -Raw -Path $policyPath).TrimEnd()
27
- $block = "$BeginMarker`n$policy`n$EndMarker"
28
-
29
- $exit = 0
30
-
31
- foreach ($target in $Targets) {
32
- $label = $target
33
- if (-not (Test-Path $target)) {
34
- if ($Check) {
35
- Write-Output "DRIFT $label : file missing"
36
- $exit = 1
37
- } else {
38
- $dir = Split-Path $target
39
- if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Force -Path $dir | Out-Null }
40
- Set-Content -NoNewline -Path $target -Value ($block + "`n")
41
- Write-Output "ADDED $label : created file with managed block"
42
- }
43
- continue
44
- }
45
-
46
- # An empty file returns $null from -Raw, which would throw in Matches below.
47
- $content = Get-Content -Raw -Path $target
48
- if ($null -eq $content) { $content = '' }
49
- $beginCount = ([regex]::Matches($content, [regex]::Escape($BeginMarker))).Count
50
- $endCount = ([regex]::Matches($content, [regex]::Escape($EndMarker))).Count
51
-
52
- if ($beginCount -eq 0 -and $endCount -eq 0) {
53
- if ($Check) {
54
- Write-Output "DRIFT $label : managed block missing"
55
- $exit = 1
56
- } else {
57
- $sep = if ($content.Length -eq 0) { '' } elseif ($content.EndsWith("`n")) { "`n" } else { "`n`n" }
58
- Set-Content -NoNewline -Path $target -Value ($content + $sep + $block + "`n")
59
- Write-Output "ADDED $label : appended managed block"
60
- }
61
- continue
62
- }
63
-
64
- $wellFormed = ($beginCount -eq 1 -and $endCount -eq 1 -and
65
- $content.IndexOf($BeginMarker) -lt $content.IndexOf($EndMarker))
66
- if (-not $wellFormed) {
67
- Write-Output "ERROR $label : malformed markers (begin=$beginCount end=$endCount) - no mutation"
68
- exit 2
69
- }
70
-
71
- $start = $content.IndexOf($BeginMarker)
72
- $end = $content.IndexOf($EndMarker) + $EndMarker.Length
73
- $current = $content.Substring($start, $end - $start)
74
-
75
- if ($current -eq $block) {
76
- Write-Output "OK $label : in sync"
77
- } elseif ($Check) {
78
- Write-Output "DRIFT $label : block differs from policy.md"
79
- $exit = 1
80
- } else {
81
- $updated = $content.Substring(0, $start) + $block + $content.Substring($end)
82
- Set-Content -NoNewline -Path $target -Value $updated
83
- Write-Output "UPDATED $label : block replaced from policy.md"
84
- }
85
- }
86
-
87
- exit $exit
1
+ # Manages the AGENT OS block in global instruction files.
2
+ # Source of truth: policy.md at the plugin root (two levels up from this script).
3
+ #
4
+ # Semantics (locked in the agent-os plan, M3):
5
+ # - No block in target -> append exactly one block, preserve everything else.
6
+ # - Empty target file -> treated as "no block"; the block becomes the whole file.
7
+ # - Exactly one well-formed -> replace only the content between the markers.
8
+ # - Duplicated, crossed, or half-open markers -> abort without mutation, exit 2.
9
+ # - -Check -> read-only; exit 0 in sync, exit 1 on drift/missing, never writes.
10
+ # - Text outside the block is never touched or normalized.
11
+
12
+ [CmdletBinding()]
13
+ param(
14
+ [switch]$Check,
15
+ [string[]]$Targets = @(
16
+ (Join-Path (Join-Path $HOME '.claude') 'CLAUDE.md'),
17
+ (Join-Path (Join-Path $HOME '.codex') 'AGENTS.md')
18
+ )
19
+ )
20
+
21
+ $ErrorActionPreference = 'Stop'
22
+ $BeginMarker = '<!-- BEGIN AGENT OS -->'
23
+ $EndMarker = '<!-- END AGENT OS -->'
24
+
25
+ $policyPath = Join-Path $PSScriptRoot '..\..\..\policy.md' | Resolve-Path
26
+ $policy = (Get-Content -Raw -Path $policyPath).TrimEnd()
27
+ $block = "$BeginMarker`n$policy`n$EndMarker"
28
+
29
+ $exit = 0
30
+
31
+ foreach ($target in $Targets) {
32
+ $label = $target
33
+ if (-not (Test-Path $target)) {
34
+ if ($Check) {
35
+ Write-Output "DRIFT $label : file missing"
36
+ $exit = 1
37
+ } else {
38
+ $dir = Split-Path $target
39
+ if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Force -Path $dir | Out-Null }
40
+ Set-Content -NoNewline -Path $target -Value ($block + "`n")
41
+ Write-Output "ADDED $label : created file with managed block"
42
+ }
43
+ continue
44
+ }
45
+
46
+ # An empty file returns $null from -Raw, which would throw in Matches below.
47
+ $content = Get-Content -Raw -Path $target
48
+ if ($null -eq $content) { $content = '' }
49
+ $beginCount = ([regex]::Matches($content, [regex]::Escape($BeginMarker))).Count
50
+ $endCount = ([regex]::Matches($content, [regex]::Escape($EndMarker))).Count
51
+
52
+ if ($beginCount -eq 0 -and $endCount -eq 0) {
53
+ if ($Check) {
54
+ Write-Output "DRIFT $label : managed block missing"
55
+ $exit = 1
56
+ } else {
57
+ $sep = if ($content.Length -eq 0) { '' } elseif ($content.EndsWith("`n")) { "`n" } else { "`n`n" }
58
+ Set-Content -NoNewline -Path $target -Value ($content + $sep + $block + "`n")
59
+ Write-Output "ADDED $label : appended managed block"
60
+ }
61
+ continue
62
+ }
63
+
64
+ $wellFormed = ($beginCount -eq 1 -and $endCount -eq 1 -and
65
+ $content.IndexOf($BeginMarker) -lt $content.IndexOf($EndMarker))
66
+ if (-not $wellFormed) {
67
+ Write-Output "ERROR $label : malformed markers (begin=$beginCount end=$endCount) - no mutation"
68
+ exit 2
69
+ }
70
+
71
+ $start = $content.IndexOf($BeginMarker)
72
+ $end = $content.IndexOf($EndMarker) + $EndMarker.Length
73
+ $current = $content.Substring($start, $end - $start)
74
+
75
+ if ($current -eq $block) {
76
+ Write-Output "OK $label : in sync"
77
+ } elseif ($Check) {
78
+ Write-Output "DRIFT $label : block differs from policy.md"
79
+ $exit = 1
80
+ } else {
81
+ $updated = $content.Substring(0, $start) + $block + $content.Substring($end)
82
+ Set-Content -NoNewline -Path $target -Value $updated
83
+ Write-Output "UPDATED $label : block replaced from policy.md"
84
+ }
85
+ }
86
+
87
+ exit $exit
@@ -1,42 +1,43 @@
1
- ---
2
- name: list-skills
3
- description: Lists the installed agent-os skills with their invocation syntax and purpose so the developer can see what is available and pick the right one. Use manually when the developer asks what agent-os can do, which skill fits, or for a skill list, overview, or reference card. Not for running any listed skill, choosing or dispatching the next action in planned work, or explaining work already underway.
4
- disable-model-invocation: true
5
- ---
6
-
7
- # List skills
8
-
9
- Answer what this installation offers and how to reach it. The skill returns one reference card and
10
- changes nothing.
11
-
12
- ## Read the installation, never a remembered list
13
-
14
- Take every skill from the sibling directories beside this one, using each `SKILL.md` frontmatter for
15
- its name and description. A reference card recited from memory goes stale the moment a skill is
16
- added, removed, or partially installed, and it hides exactly the drift a developer opens the card to
17
- find. Report a directory whose frontmatter is missing or unreadable as unavailable rather than
18
- omitting it.
19
-
20
- Each skill's own frontmatter also carries its invocation: `disable-model-invocation: true` plus
21
- `agents/openai.yaml` means the developer invokes it explicitly; neither switch means it is automatic
22
- and needs no invocation.
23
-
24
- ## Report
25
-
26
- Group by invocation, explicit skills first, and give each one line: how to invoke it and what it
27
- does, condensed from its description rather than copied whole. Show the invocation form matching how
28
- this skill was itself reached — `/agent-os:<name>` through the Claude plugin, `/<name>` for a direct
29
- Claude install, `$<name>` on Codex — and name which form is shown, since the same skill set is typed
30
- differently per host.
31
-
32
- Close with the entry points for a developer who has not named a skill: an unclear desire starts at
33
- `guide-me`, bounded choices at `shape-work`, broad or coupled work at `chart-work`, and a
34
- decision-complete unit at `deliver-work`. Say plainly that automatic skills need no entry point
35
- instead of listing them as choices.
36
-
37
- ## Boundaries
38
-
39
- One card, then stop. Do not invoke, stage, or offer to run a listed skill, and write no file, state,
40
- or default. Listing what exists is not choosing what to do next: a developer who wants the next
41
- action picked or dispatched wants `dispatch-next`, and one who wants the current task described
42
- wants `explain-work`.
1
+ ---
2
+ name: list-skills
3
+ description: Lists the installed agent-os skills with their invocation syntax and purpose so the developer can see what is available and pick the right one. Use manually when the developer asks what agent-os can do, which skill fits, or for a skill list, overview, or reference card. Not for running any listed skill, choosing or dispatching the next action in planned work, or explaining work already underway.
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # List skills
8
+
9
+ Answer what this installation offers and how to reach it. The skill returns one reference card and
10
+ changes nothing.
11
+
12
+ ## Read the installation, never a remembered list
13
+
14
+ Take every skill from the sibling directories beside this one, using each `SKILL.md` frontmatter for
15
+ its name and description. A reference card recited from memory goes stale the moment a skill is
16
+ added, removed, or partially installed, and it hides exactly the drift a developer opens the card to
17
+ find. Report a directory whose frontmatter is missing or unreadable as unavailable rather than
18
+ omitting it.
19
+
20
+ Each skill's own frontmatter also carries its invocation: `disable-model-invocation: true` plus
21
+ `agents/openai.yaml` means the developer invokes it explicitly; neither switch means it is automatic
22
+ and needs no invocation. An automatic workflow may still document explicit modes in its own
23
+ instructions.
24
+
25
+ ## Report
26
+
27
+ Group by invocation, explicit skills first, and give each one line: how to invoke it and what it
28
+ does, condensed from its description rather than copied whole. Show the invocation form matching how
29
+ this skill was itself reached — `/agent-os:<name>` through the Claude plugin, `/<name>` for a direct
30
+ Claude install, `$<name>` on Codex — and name which form is shown, since the same skill set is typed
31
+ differently per host.
32
+
33
+ Close with the entry points for a developer who has not named a skill: an unclear desire starts at
34
+ `guide-me`, bounded choices at `shape-work`, broad or coupled work at `chart-work`, and a
35
+ decision-complete unit at `deliver-work`. Say plainly that automatic skills need no entry point
36
+ for an implicit trigger; mention an automatic workflow's explicit modes only when useful.
37
+
38
+ ## Boundaries
39
+
40
+ One card, then stop. Do not invoke, stage, or offer to run a listed skill, and write no file, state,
41
+ or default. Listing what exists is not choosing what to do next: a developer who wants the next
42
+ action picked or dispatched wants `dispatch-next`, and one who wants the current task described
43
+ wants `explain-work`.
@@ -1,2 +1,2 @@
1
- policy:
2
- allow_implicit_invocation: false
1
+ policy:
2
+ allow_implicit_invocation: false
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: plain-voice
3
+ description: Removes generated-prose tells from every agent-authored textual response, including short chat and status replies, documentation, commit and pull request text, and issue comments, so each sentence carries a fact, an instruction, or a number. It skips code, identifiers, structured data, quoted source material, and prose the developer wrote.
4
+ ---
5
+
6
+ # Plain voice
7
+
8
+ Apply this discipline to every textual response the agent authors, including short conversational
9
+ and status replies. It is not limited to formal prose artifacts.
10
+
11
+ Write so every sentence leaves the reader with a fact, an instruction, or a number. Cut the rest.
12
+
13
+ Generated prose fails in a small number of recurring ways. Judge a draft against these, then
14
+ rewrite:
15
+
16
+ - **Claims with no source or mechanism.** Praise, promotional adjectives, and attribution to unnamed
17
+ experts or reports. Name who said it or what the thing does, or delete the sentence.
18
+ - **Length without meaning.** Elevated synonyms, filler openers, stacked hedges, and adverbs propping
19
+ up a weak verb. Prefer the plain word and the stronger verb.
20
+ - **Abstract metaphor in place of a concrete noun.** Substrate, vector, surface, north star. Name the
21
+ mechanism.
22
+ - **Structure imposed on the content rather than drawn from it.** Ideas forced into threes, "not just
23
+ X but Y", ranges whose ends share no scale, and bold labels that restate the line they introduce.
24
+ - **Conversational residue.** Openers that congratulate the reader, closing offers of further help,
25
+ and disclaimers about what could not be checked. State the finding, or go find it.
26
+
27
+ Two checks settle a doubtful sentence. Ask what it tells the reader to do or know; if it cannot be
28
+ restated as a fact, an instruction, or a number, cut it. Then ask whether it could appear unchanged
29
+ in another project's writing; if it could, it says nothing about this one.
30
+
31
+ Dashes do not belong in running text. Split the sentence or use a comma.
32
+
33
+ The failures above apply in any language. Spelling, punctuation, and vocabulary tells are English, so
34
+ apply [the tells reference](references/tells.md) to English prose. Established technical terms run
35
+ the opposite way and stay in English whatever language surrounds them: a reader who has to turn
36
+ `kantfall` back into `edge case` cannot act on the sentence until they do.
37
+
38
+ Rewriting never reaches code, identifiers, structured data, quoted source material, or the
39
+ developer's own prose. Leave those unchanged unless the request is to edit them.
@@ -0,0 +1,82 @@
1
+ # Prose tells
2
+
3
+ Lookups for the failures named in the skill. Sections 1 to 3 apply to English prose. Section 4
4
+ applies when the surrounding prose is any other language.
5
+
6
+ A replacement is a default, not a ban. Keep the flagged word when it is the accurate one: a
7
+ `vector` in geometry and a `cache` that is literally a cache are correct.
8
+
9
+ ## 1. Words with a plainer replacement
10
+
11
+ Elevated synonyms: `utilize` becomes `use`, `leverage` becomes `use`, `facilitate` becomes `help`,
12
+ `numerous` becomes `many`, `additionally` becomes `also`, `crucial` becomes `important` or the
13
+ consequence itself, `enhance` becomes `improve`, `ensure` becomes `make sure` or the mechanism that
14
+ guarantees it.
15
+
16
+ Fancy ways to say `is`: `serves as`, `stands as`, `acts as`, `boasts`, and `features` all become `is`
17
+ or `has`.
18
+
19
+ Vocabulary that signals generated text: `delve`, `interplay`, `intricate`, `tapestry`, `testament`,
20
+ `underscore`, `showcase`, `pivotal`, `garner`, `landscape` used abstractly, `vibrant` used
21
+ abstractly. Replace with the plain word or cut the sentence.
22
+
23
+ Abstract metaphor nouns, with the concrete word they usually stand for: `substrate` becomes `base`,
24
+ `wedge` becomes `add`, `vector` becomes `way` or `method`, `surface` becomes `interface` or `API`,
25
+ `primitive` becomes the actual type or operation, `nexus` and `locus` become `center` or the named
26
+ component, `bedrock` becomes `foundation`, `scaffolding` becomes `setup` or `generated files`,
27
+ `north star` and `flywheel` become the goal or the mechanism itself, `gold-plating` becomes `more
28
+ than the job needs`, `ratchet` becomes `a limit that only tightens`, `evacuate` becomes `move out`,
29
+ `endgame` becomes `the last phase`.
30
+
31
+ ## 2. Phrases to cut outright
32
+
33
+ Filler that carries no information: `in order to` becomes `to`, `due to the fact that` becomes
34
+ `because`, `it is important to note that` is deleted along with everything like it, `at this point in
35
+ time` becomes `now`.
36
+
37
+ Stacked hedges: `could potentially possibly be argued that it might` becomes `may`. One hedge is
38
+ honest, three are noise.
39
+
40
+ Vague attribution: `experts believe`, `industry reports suggest`, `some critics argue`. Name the
41
+ source or delete the claim.
42
+
43
+ Conversational residue: `Great question`, `You are absolutely right`, `Certainly`, `I hope this
44
+ helps`, `Let me know if`, `Found the smoking gun`. Delete them and start with the finding.
45
+
46
+ Disclaimers that substitute for work: `while specific details are limited`, `I was unable to fully
47
+ verify`. Go find the detail, or state precisely what is unverified and what that costs the reader.
48
+
49
+ Generic conclusions: `the future looks bright`, `this positions the project well`. Replace with the
50
+ next concrete step or delete the paragraph.
51
+
52
+ ## 3. Punctuation and formatting habits
53
+
54
+ Dashes as connectors in running text. Split the sentence or use a comma. Reaching for parentheses
55
+ instead trades one habit for another.
56
+
57
+ Colons joining two independent clauses mid-sentence. A colon belongs before a list or an example.
58
+ Elsewhere, end the sentence.
59
+
60
+ Boldface on every proper noun, product name, or acronym. Bold marks the one thing that matters in a
61
+ passage; bolding six things marks none of them.
62
+
63
+ Bold labels that restate the line they introduce, as in `**Performance:** Performance improved`.
64
+ Convert to prose. A bold lead-in naming a distinct item followed by genuinely new detail is fine.
65
+
66
+ Title case headings become sentence case. Decorative emoji in headings and bullets are removed. Curly
67
+ quotes become straight quotes.
68
+
69
+ ## 4. Technical terms that stay English
70
+
71
+ When writing in another language, keep the term a developer says out loud. A translated term the
72
+ reader has never heard costs them a translation step before they can act on the sentence.
73
+
74
+ Keep in English: `edge case`, `pull request`, `commit`, `merge`, `branch`, `rebase`, `deploy`,
75
+ `build`, `cache`, `endpoint`, `race condition`, `refactor`, `rollback`, `staging`, `linter`, `mock`,
76
+ `fixture`, `feature flag`, `deprecated`, `boilerplate`, `callback`, `throughput`, `scope`.
77
+
78
+ Translate normally: `databas`, `server`, `fil`, `minne`, `nätverk`, `kod`, `tabell`, `användare`.
79
+ These are the words people actually use.
80
+
81
+ The test is usage, not the dictionary. `kantfall` for `edge case` and `draganmodan` for `pull
82
+ request` are inventions no developer says. When unsure, keep the English term.
@@ -1,30 +1,30 @@
1
- ---
2
- name: proportional-testing
3
- description: Selects the smallest meaningful test surface when code is implemented or modified. It activates before adding or expanding tests, and when choosing affected test execution for a change or bug fix. It skips test-status reporting, diagnosis of an already failing test, and repository-wide test-strategy design requested as its own deliverable.
4
- ---
5
-
6
- # Test proportionally
7
-
8
- Read [references/strategy.md](references/strategy.md) before creating or expanding tests.
9
-
10
- Protect the changed behavior and plausible regressions without optimizing for test count or coverage.
11
-
12
- ## Decision
13
-
14
- Before adding a test:
15
-
16
- 1. Identify the observable behavior changed and its plausible blast radius.
17
- 2. Search existing tests for that behavior and affected contracts.
18
- 3. Name the realistic regression the proposed test would catch that existing coverage would not.
19
- 4. If that regression is unclear, do not add the test.
20
- 5. Otherwise extend existing or table-driven coverage when practical, using the cheapest test level
21
- that proves the behavior.
22
-
23
- For a confirmed bug, establish one reproducing regression check when practical, prove it fails for
24
- the expected reason, fix it, then run that check and relevant affected tests. Expand execution only
25
- when the blast radius is uncertain, shared infrastructure changed, or project policy requires a
26
- broader gate.
27
-
28
- Do not create a test for every function, branch, file, or generated code path. Prefer observable
29
- contracts over call sequences and private structure. This discipline controls test creation and
30
- development-time selection; it never removes required repository or CI checks at delivery.
1
+ ---
2
+ name: proportional-testing
3
+ description: Selects the smallest meaningful test surface when code is implemented or modified. It activates before adding or expanding tests, and when choosing affected test execution for a change or bug fix. It skips test-status reporting, diagnosis of an already failing test, and repository-wide test-strategy design requested as its own deliverable.
4
+ ---
5
+
6
+ # Test proportionally
7
+
8
+ Read [references/strategy.md](references/strategy.md) before creating or expanding tests.
9
+
10
+ Protect the changed behavior and plausible regressions without optimizing for test count or coverage.
11
+
12
+ ## Decision
13
+
14
+ Before adding a test:
15
+
16
+ 1. Identify the observable behavior changed and its plausible blast radius.
17
+ 2. Search existing tests for that behavior and affected contracts.
18
+ 3. Name the realistic regression the proposed test would catch that existing coverage would not.
19
+ 4. If that regression is unclear, do not add the test.
20
+ 5. Otherwise extend existing or table-driven coverage when practical, using the cheapest test level
21
+ that proves the behavior.
22
+
23
+ For a confirmed bug, establish one reproducing regression check when practical, prove it fails for
24
+ the expected reason, fix it, then run that check and relevant affected tests. Expand execution only
25
+ when the blast radius is uncertain, shared infrastructure changed, or project policy requires a
26
+ broader gate.
27
+
28
+ Do not create a test for every function, branch, file, or generated code path. Prefer observable
29
+ contracts over call sequences and private structure. This discipline controls test creation and
30
+ development-time selection; it never removes required repository or CI checks at delivery.
@@ -1,75 +1,75 @@
1
- # Proportional testing strategy
2
-
3
- The goal is maximum confidence with the minimum necessary test surface. Test count and coverage
4
- percentage are signals, not quality targets.
5
-
6
- ## Select the protected behavior
7
-
8
- Understand the behavior being changed, inspect existing coverage, and identify nearby behavior that
9
- could realistically regress. Protect:
10
-
11
- - the observable behavior directly changed;
12
- - important edge cases introduced or affected by the change;
13
- - consumers that depend on a changed contract;
14
- - relevant previously discovered regressions;
15
- - integration boundaries actually crossed by the change.
16
-
17
- Do not create tests merely because new code, branches, functions, files, or components exist.
18
- Existing coverage may already be sufficient.
19
-
20
- ## Prefer durable tests
21
-
22
- Test externally observable behavior and contracts. A behavior-preserving refactor should not force
23
- large test rewrites. Avoid tests whose main value is asserting internal calls, exact call sequences
24
- when ordering is not contractual, trivial delegation, getters, constructors, framework boilerplate,
25
- private structure, or mocks that reproduce the implementation.
26
-
27
- Before adding coverage, search for an existing behavioral test. Prefer extending it, adding a case
28
- to a table-driven test, and reusing its fixtures. One strong regression test is better than several
29
- tests with equivalent setup and assertions.
30
-
31
- ## Choose the cheapest sufficient level
32
-
33
- Use a focused unit or component test when it can prove the contract. Use integration or end-to-end
34
- tests only when the behavior depends on boundaries they exercise. Mock genuine system boundaries,
35
- not every internal dependency.
36
-
37
- Keep unit tests fast, deterministic, and isolated. If a test needs broad application startup,
38
- external infrastructure, network access, substantial global state, or expensive fixtures, classify
39
- and run it at the appropriate broader level rather than disguising it as a unit test.
40
-
41
- Balance regression protection against execution time, maintenance, flakiness, setup complexity, and
42
- duplication. A broader test is justified by broader risk, not by the amount of code generated.
43
-
44
- ## Fix bugs with one regression story
45
-
46
- For a confirmed bug, when practical:
47
-
48
- 1. Add or identify the smallest check that reproduces the incorrect behavior.
49
- 2. Verify that it fails for the expected reason.
50
- 3. Implement the fix.
51
- 4. Verify that the regression check passes.
52
- 5. Run affected tests for plausible nearby regressions.
53
-
54
- Do not generate a collection of unrelated tests merely because a bug was fixed. If an existing test
55
- already proves the regression, use it and add no new test.
56
-
57
- ## Select execution scope
58
-
59
- During development, start with the smallest reliable affected set. Add dependency or consumer tests
60
- when the changed contract can affect them. Expand to broader suites when affected-test selection is
61
- unreliable, the blast radius is uncertain, shared infrastructure changed, or repository policy and
62
- CI strategy require it.
63
-
64
- Narrow execution is not an excuse to ignore plausible regressions. Conversely, do not run the full
65
- suite after every small edit when reliable focused selection exists. Required delivery checks still
66
- run even when development checks were narrow.
67
-
68
- ## Stop adding tests
69
-
70
- Coverage is adequate when the intended behavior is verified, plausible affected behavior and
71
- important justified edge cases have been considered, relevant existing tests pass, and the chosen
72
- test level is proportional to the risk.
73
-
74
- Before adding another test, ask: **What realistic regression would this catch that existing tests
75
- would not?** If there is no clear answer, do not add it.
1
+ # Proportional testing strategy
2
+
3
+ The goal is maximum confidence with the minimum necessary test surface. Test count and coverage
4
+ percentage are signals, not quality targets.
5
+
6
+ ## Select the protected behavior
7
+
8
+ Understand the behavior being changed, inspect existing coverage, and identify nearby behavior that
9
+ could realistically regress. Protect:
10
+
11
+ - the observable behavior directly changed;
12
+ - important edge cases introduced or affected by the change;
13
+ - consumers that depend on a changed contract;
14
+ - relevant previously discovered regressions;
15
+ - integration boundaries actually crossed by the change.
16
+
17
+ Do not create tests merely because new code, branches, functions, files, or components exist.
18
+ Existing coverage may already be sufficient.
19
+
20
+ ## Prefer durable tests
21
+
22
+ Test externally observable behavior and contracts. A behavior-preserving refactor should not force
23
+ large test rewrites. Avoid tests whose main value is asserting internal calls, exact call sequences
24
+ when ordering is not contractual, trivial delegation, getters, constructors, framework boilerplate,
25
+ private structure, or mocks that reproduce the implementation.
26
+
27
+ Before adding coverage, search for an existing behavioral test. Prefer extending it, adding a case
28
+ to a table-driven test, and reusing its fixtures. One strong regression test is better than several
29
+ tests with equivalent setup and assertions.
30
+
31
+ ## Choose the cheapest sufficient level
32
+
33
+ Use a focused unit or component test when it can prove the contract. Use integration or end-to-end
34
+ tests only when the behavior depends on boundaries they exercise. Mock genuine system boundaries,
35
+ not every internal dependency.
36
+
37
+ Keep unit tests fast, deterministic, and isolated. If a test needs broad application startup,
38
+ external infrastructure, network access, substantial global state, or expensive fixtures, classify
39
+ and run it at the appropriate broader level rather than disguising it as a unit test.
40
+
41
+ Balance regression protection against execution time, maintenance, flakiness, setup complexity, and
42
+ duplication. A broader test is justified by broader risk, not by the amount of code generated.
43
+
44
+ ## Fix bugs with one regression story
45
+
46
+ For a confirmed bug, when practical:
47
+
48
+ 1. Add or identify the smallest check that reproduces the incorrect behavior.
49
+ 2. Verify that it fails for the expected reason.
50
+ 3. Implement the fix.
51
+ 4. Verify that the regression check passes.
52
+ 5. Run affected tests for plausible nearby regressions.
53
+
54
+ Do not generate a collection of unrelated tests merely because a bug was fixed. If an existing test
55
+ already proves the regression, use it and add no new test.
56
+
57
+ ## Select execution scope
58
+
59
+ During development, start with the smallest reliable affected set. Add dependency or consumer tests
60
+ when the changed contract can affect them. Expand to broader suites when affected-test selection is
61
+ unreliable, the blast radius is uncertain, shared infrastructure changed, or repository policy and
62
+ CI strategy require it.
63
+
64
+ Narrow execution is not an excuse to ignore plausible regressions. Conversely, do not run the full
65
+ suite after every small edit when reliable focused selection exists. Required delivery checks still
66
+ run even when development checks were narrow.
67
+
68
+ ## Stop adding tests
69
+
70
+ Coverage is adequate when the intended behavior is verified, plausible affected behavior and
71
+ important justified edge cases have been considered, relevant existing tests pass, and the chosen
72
+ test level is proportional to the risk.
73
+
74
+ Before adding another test, ask: **What realistic regression would this catch that existing tests
75
+ would not?** If there is no clear answer, do not add it.