You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
handbook: an implementer digest beside each coding-rules handbook - #128
The generator now renders an implementer digest beside each coding-rules handbook: coding-rules/<lang>.digest.md. The digest keeps the shape decisions of the twelve rules and drops the examples. It is for an agent that writes code and imports the rules into its fixed context. The full handbooks do not change.
New template core/handbook/coding-rules.digest.md and new profile key digest: in all four bindings.
One new line per rule in core/includes/handbook/Rn/digest.md. No binding override is necessary today.
Two new digest-only constructs, documented in the core/README.md handbook table:
maximName: the maxim title only. It fails when maxims.md has no such heading. The existing maxim renders the full Ask paragraph, which is too long.
handbookPath: the full handbook's path relative to the digest, percent-encoded per segment, as the destination of the pointer link.
Generator: the handbook code path is now a list of documents (tools/ldd-gen/internal/gen/documents.go). The digest gets the same marker, overwrite refusal, drift check (missing, changed, exec bit), path claims and residue gate as the handbook. The render fails when a digest is over 8,000 bytes (render.DigestMaxBytes), so task generate and task check both stop growth.
Docs: docs/handbook.md (what the digest is, who it is for, how to consume both, the ceiling), experiment 8 in docs/eval-return-experiments.md (optional digest cell), docs/generator.md, docs/language-residue.md, docs/index.md, README.md, CLAUDE.md, Taskfile.yaml task descriptions.
Sizes
Words are wc -w. Tokens are bytes ÷ 4, the method that reproduces the four token figures of the request. wc -w counts about 3 percent more words than those figures.
Binding
Full handbook
Digest
Digest / full
go
4,875 words, 30,246 B, ~7.6k tokens
1,230 words, 7,246 B, ~1.8k tokens
24%
python
5,417 words, 35,034 B, ~8.8k tokens
1,265 words, 7,451 B, ~1.8k tokens
21%
generic
5,202 words, 32,317 B, ~8.1k tokens
1,220 words, 7,188 B, ~1.8k tokens
22%
ts-react
6,598 words, 42,794 B, ~10.7k tokens
1,300 words, 7,743 B, ~1.9k tokens
18%
The ceiling is 8,000 bytes. ts-react has 257 bytes left. Its house-rule review lines are the largest fixed part (about 900 bytes).
Weighting
Judgment questions per rule
Detect: judgment lines in each binding's rules/Rn/falsifying-questions.md (generic reads the core default). Numbers in brackets are the question numbers.
Rule
go
python
ts-react
generic
R1
1/8 [2]
1/8 [2]
1/8 [2]
5/8 [2 5 6 7 8]
R2
2/6 [1 3]
2/6 [1 3]
2/6 [1 3]
5/6 [1 2 3 5 6]
R3
1/5 [1]
1/5 [1]
1/5 [1]
4/5 [1 2 3 5]
R4
4/6 [1 4 5 6]
4/6 [1 4 5 6]
4/6 [1 4 5 6]
5/6 [1 2 4 5 6]
R5
4/7 [2 3 4 5]
4/7 [2 3 4 5]
4/7 [2 3 4 5]
4/7 [2 3 4 5]
R6
3/5 [2 3 4]
2/5 [3 4]
2/5 [3 4]
4/5 [1 2 3 4]
R7
1/7 [3]
1/7 [3]
1/7 [3]
3/7 [2 3 4]
R8
0/6
0/6
0/6
5/6 [1 2 3 4 6]
R9
2/7 [5 6]
2/7 [5 6]
2/7 [5 6]
3/7 [4 5 6]
R10
3/6 [2 3 6]
3/6 [2 3 6]
2/6 [3 6]
5/6 [1 2 3 4 6]
R11
2/5 [3 5]
2/5 [3 5]
2/5 [3 5]
2/5 [3 5]
R12
3/6 [2 3 5]
3/6 [2 3 5]
3/6 [2 3 5]
4/6 [1 2 3 5]
The generic binding has no language-specific search, so most of its questions are judgment. The picks follow go, python and ts-react, because the numbers are one list for all four.
What the recommended lint configs in core/setup/ hold
Rule order: judgment questions first, because no search finds them and few linters hold them. Then the questions that decide a type's shape at write time, because that shape is expensive to change in review.
Rule
Questions
Why
R1
2, 6, 8
Q2 is its one judgment question. Q6 (ceremony type) and Q8 (container across a boundary) decide a type's shape at write time. Q1 and Q4 are search hits that a review finds cheaply.
R2
1, 3, 4
Q1 and Q3 are judgment. Q4 (upstream validation) decides where validation lives. Q5 (the missing value as a value) is left out: its headline without its body reads as if a declared optional return were a violation.
R3
2, 5
Q1 is judgment but the complexity linters hold it in all three configs. Q2 and Q5 no linter holds.
R4
1, 5, 6
Three of its four judgment questions. Q4 (single-noun package) applies only when a new shared package appears.
R5
2, 3, 4
Three of its four judgment questions. Q5 (migration plan) is a repository-level question, not a write-time one.
R6
3, 4
The two questions that are judgment in every binding. Go's Q2 is also judgment, but python and ts-react detect it by search.
R7
3, 5
Q3 is its one judgment question. Q5 (asserts on a fake's internals) needs no exemption. Q4 is left out: its headline without its body contradicts the move "Delete private-function tests".
R8
3, 5
No judgment question. Q1 and Q2 (globals, init) are lint-held in go and partly in python and ts-react. Q3 and Q5 are not.
R9
5, 6
Its two judgment questions.
R10
2, 3, 6
Its judgment questions in go and python. In ts-react Q2 is a search.
R11
1, 3, 5
Q3 and Q5 are judgment. Q1 (one discriminator in two places) is the shape decision the rule exists for.
R12
2, 3, 5
All three judgment questions.
R4, R5, R10 and R12 (judgment-heavy) and R1, R2 and R11 (shape at write time) get three questions. The others get two.
The twelve draft summaries, for your review
Each is one sentence of 20 words or fewer. The wording is a draft.
Rule
Line
R1
Make a primitive a type when it carries validation, behavior or an invariant, and name each nested container; a wrapper with none of these is over-abstraction.
R2
Validate in the constructor, the only way to get a value, so that no method checks it again.
R3
Write each top-level function as a short list of named steps at one level of abstraction.
R4
Test a private function through its public caller, and give a juicy helper type its own package with direct tests.
R5
Put new code in its feature's package, but in a layered repository follow the architecture doc or the nearby code.
R6
Depend on the concrete type, add an interface only for a second production implementation, and fix an import cycle in the layering.
R7
Test each behavior at the lowest rung that holds it, with real collaborators, and fake only the external boundary.
R8
Pass each dependency in from the caller, and read configuration only at the entry point.
R9
Write a {{.DocComment}} that says why, and change the feature doc in the same change as the behavior.
R10
Give each {{.Task}} an owner that stops it and waits for it, and guard shared state where it lives.
R11
Switch on a value's kind at most once, exhaustively; a second switch on the same kind wants a polymorphic type chosen at the boundary.
R12
Copy collections into a validated type, return copies or iterators, and change it only through methods that keep its invariants.
R4 uses "juicy", the handbook's term for an R1 score of 4 or more; the digest does not define it. R9 and R10 use the binding's scalars ("godoc comment", "docstring", "JSDoc comment"; "goroutine", "concurrent task", "async task").
Maxims are names only. The request allows "at most one short line". Nine extra lines (about 600 to 900 bytes) do not fit in ts-react's 257 bytes of margin. The names are short imperatives already. If you want the lines, the price is a trim elsewhere in the digest, for example one question less on R1, R2 and R11.
Audit of the full handbooks (not changed in this PR)
Bytes per ## section, as rendered on main:
Section
go
python
ts-react
generic
Header
590
602
628
607
1. Mindset
2,092
2,092
2,092
2,092
2. The twelve rules
20,089
23,619
30,165
22,654
3. House rules
4,040
5,003
5,613
3,422
4. Self-review
2,453
2,648
2,915
2,364
5. Mechanics
977
1,097
1,372
1,173
Total
30,246
35,066
42,790
32,317
Inside "The twelve rules", summed over the twelve rules:
Part
go
python
ts-react
generic
Principle (core, with heading)
6,515
6,560
6,510
6,524
Example fence
7,392
8,672
12,830
7,294
> In <Lang> / > Spelling aside
3,715
5,916
8,342
6,359
Moves (core)
2,007
2,007
2,007
2,007
Where each binding is longer than go:
ts-react, +12,544 B (~3.1k tokens). Examples +5,438, asides +4,627, house rules +1,573 (the H1 and H2 spelling asides are 1,125 and 1,334 B against go's 549 and 805), self-review +462, mechanics +395.
python, +4,820 B (~1.2k tokens). Asides +2,201, examples +1,280, house rules +963.
generic, +2,071 B (~0.5k tokens). The > Spelling: asides are +2,644. Its house rules are 618 B shorter.
The longest single items: the ts-react R1 example (1,746 B; go 1,382), the ts-react R11 example (1,345 B; go 630), the ts-react R2 example (1,241 B; go 667), the R4 Principle (1,353 B in every binding, twice the next Principle), and the "When in Rome" maxim (about 560 B).
Proposed trims, for a separate decision
Handbook-only (no plugin file changes, so no eval): none proposed.
A rewrite of the asides in ASD-STE100 that keeps every fact was measured on the twelve ts-react asides: 8,342 to 8,200 bytes, 2% less. It makes the text clearer for a human reader, not shorter, so it is not proposed as a trim. The defects that the rewrite found are fixed in this PR (see below).
Three cuts are not proposed, because each one removes a lesson:
One example pair per rule. Each second pair teaches a different point: R1 names a container, R2 binds a Null Object, and R11 closes a switch with assertNever.
H1 and H2 spelling asides at Go's length. TypeScript has seven suppression forms and Go has two, so the longer aside holds facts, not words.
Only the first question of each maxim. The text after the question is its answer, for example how test pain maps to a design fault.
A fixed cap of about 400 B per aside is not proposed. Each aside holds the language's position, and most of its sentences are separate facts that no other part of the handbook has. For example, the ts-react R8 aside lists what is never a finding, what is a finding only outside the composition root, and what is always a finding. A 400 B cap keeps the findings and removes the "never a finding" list, which stops a reader from applying the rule too widely.
A split of the examples into a separate document is not proposed. The digest is already that split: teams import the digest, and the full handbook costs tokens only when someone opens it. A file per rule would cut an on-demand read from about 43 kB to about 3 kB. Consider it only if evals show that agents often open the full handbook.
Plugin text (would need an eval under docs/eval-baseline.md, "Core text that all bindings render"):
#
Trim
File
Saves
1
Move the constructor paragraph of R4's Principle into its Fix pattern
core/rules/R4-helper-placement.md
~600 B in every binding
2
Shorten the "When in Rome" Ask
core/maxims.md
~400 B in every binding
No plugin file changed, so no eval
git diff --stat origin/main -- over the four plugin directories, core/rules, core/includes/rules, core/agents, core/skills, core/commands, core/maxims.md and lang/*/passthrough is empty.
The full handbooks coding-rules/ts-react.md and coding-rules/python.md change only in their asides (lang/<lang>/handbook/, which no plugin reads). The fixes make each aside stand alone:
Remove the references to other sections: "shown under R1" (ts-react and python R2), "the fence above" (python R2), "the second fence" (ts-react R2).
Remove the internal codes "(T3)" (ts-react R11) and "R2 Q5" (ts-react H2).
Complete the ts-react R9 sentence about the props doc, which had no verb.
The fixes do not change the go and generic handbooks or any digest.
The scope row in docs/eval-baseline.md, "Choosing the eval scope for a change": "Shared script or generator, plugin text byte-identical | Shell tests and task check. No eval."
lang/ts-react/passthrough/README.md names only the full handbook. It is plugin text, so this PR does not change it.
docs/quick-start.md has no passage that tells a team what to import. The import advice lives in README.md, which this PR changes.
Test plan
task generate for go, generic, python and ts-react
task check: every plugin directory, handbook and digest matches its rendering
task lint-core (the Residue section of core/README.md gains one soft row for the interface aside in R6/digest.md)
go test ./... and golangci-lint run ./... in tools/ldd-gen: 0 issues
bash scripts/check-docs.sh
task test-gate
New tests: profile digest: validation; render.Digest (output, unknown maxim, no digest in the profile, at and over the ceiling, not a plugin file); generate and check for a digest (missing, changed, exec bit), residue gate on a non-Go digest, refusal to overwrite a hand-written digest, path conflicts between digests and handbooks
The generator renders coding-rules/<lang>.digest.md for each binding that
names a digest: path. The digest keeps the shape decisions of the rules
(maxim names, one line per rule, move names, two or three question
headlines, house-rule review lines) and drops the examples. It has the
handbook's marker, overwrite refusal, drift check and residue gate, and
its render fails over 8,000 bytes.
No plugin file changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The digests omit required qualifications on architecture layout and helper-type placement and testing, risking unapproved restructuring and missed direct tests.
Adds compact implementer digests beside the four coding-rules handbooks, giving coding agents a smaller fixed-context reference while leaving the full handbooks and plugin text unchanged.
Changes:
Adds a shared digest template, twelve rule summaries, and generated digests for all four bindings.
Extends generation, validation, drift checks, and tests to cover digests, including an 8,000-byte ceiling.
Documents digest consumption, generation, and an optional evaluation experiment.
File
Description
tools/ldd-gen/internal/render/handbook.go
Adds digest rendering, maxim titles, relative links, and size enforcement.
tools/ldd-gen/internal/render/digest_test.go
Tests rendering, errors, size limits, and plugin exclusion.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The digest omits essential exceptions for optional returns and direct-test requirements, creating misleading and contradictory guidance that needs correction and regeneration.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Preserve optional-return exceptions in Q5 digest text
core/handbook/coding-rules.digest.md:39
Extracting Q5's headline alone makes valid X | None and X | undefined returns look like violations, although the Python and TypeScript R2 question bodies explicitly allow narrowed ordinary absence and exempt procedures/platform cases. Preserve those distinctions in binding-specific digest text and regenerate the affected outputs so implementers do not replace valid optional returns with exceptions or null objects.
Clarify Q4 test requirement scope in standalone digests
core/handbook/coding-rules.digest.md:74
Q4's headline loses an essential scope restriction when rendered without its body: private functions and helper types scoring ≤3 do not require direct tests (lang/go/rules/R7/falsifying-questions.md:29–49, with the same exclusions in the other bindings). The standalone digest now asks whether a private leaf lacks a direct test while also listing “Delete private-function tests,” giving implementers contradictory guidance. Qualify this question to cover qualifying helper types after promotion and new public leaf behavior, then regenerate the digests.
…ions
R2 Q5 (the missing value as a value) and R7 Q4 (no direct test) need their
bodies' exemptions, which the digest does not render. R2 Q4 and R7 Q5 do not.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Digest Markdown links use unescaped filesystem paths, causing incorrect destinations for accepted handbook filenames containing URL-significant characters such as '#'.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Markdown link destination fails to encode special filename characters
tools/ldd-gen/internal/render/handbook.go:217
This returns a filesystem path directly into a Markdown link destination, but profile validation accepts URL-significant characters. For example, handbook: coding-rules/c#.md with a sibling digest produces [c#.md](c#.md), which links to c with fragment .md, not to the generated handbook. Encode the relative path for use as a link destination (including literal #, ?, % and spaces), and cover such accepted filenames in the digest renderer tests.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human review is needed to assess the impact of mandatory stop-and-wait guidance that conflicts with supported TypeScript cleanup and query-layer lifecycle alternatives.
Remove the references to other sections ("shown under R1", "the fence
above", "the second fence") and the internal codes "(T3)" and "R2 Q5".
Complete the R9 sentence about the props doc, which had no verb.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because several digests omit qualifications from the source rules, potentially steering implementers toward unnecessary abstractions or collection copies.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to judge whether the digest summaries adequately preserve structural justifications for introducing types and valid exceptions to the dispatch guidance.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because the digests omit lint-policy safeguards and error-boundary context requirements, leaving digest-only agents without that guidance.
No open issues 🎉
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The generator now renders an implementer digest beside each coding-rules handbook:
coding-rules/<lang>.digest.md. The digest keeps the shape decisions of the twelve rules and drops the examples. It is for an agent that writes code and imports the rules into its fixed context. The full handbooks do not change.core/handbook/coding-rules.digest.mdand new profile keydigest:in all four bindings.core/includes/handbook/Rn/digest.md. No binding override is necessary today.core/README.mdhandbook table:maximName: the maxim title only. It fails whenmaxims.mdhas no such heading. The existingmaximrenders the full Ask paragraph, which is too long.handbookPath: the full handbook's path relative to the digest, percent-encoded per segment, as the destination of the pointer link.tools/ldd-gen/internal/gen/documents.go). The digest gets the same marker, overwrite refusal, drift check (missing, changed, exec bit), path claims and residue gate as the handbook. The render fails when a digest is over 8,000 bytes (render.DigestMaxBytes), sotask generateandtask checkboth stop growth.docs/handbook.md(what the digest is, who it is for, how to consume both, the ceiling), experiment 8 indocs/eval-return-experiments.md(optional digest cell),docs/generator.md,docs/language-residue.md,docs/index.md,README.md,CLAUDE.md,Taskfile.yamltask descriptions.Sizes
Words are
wc -w. Tokens are bytes ÷ 4, the method that reproduces the four token figures of the request.wc -wcounts about 3 percent more words than those figures.The ceiling is 8,000 bytes. ts-react has 257 bytes left. Its house-rule review lines are the largest fixed part (about 900 bytes).
Weighting
Judgment questions per rule
Detect: judgmentlines in each binding'srules/Rn/falsifying-questions.md(generic reads the core default). Numbers in brackets are the question numbers.The generic binding has no language-specific search, so most of its questions are judgment. The picks follow go, python and ts-react, because the numbers are one list for all four.
What the recommended lint configs in
core/setup/holddupl,maintidx,argument-limit,function-result-limitPLR0913,PLR2004max-params,no-duplicate-string,max-union-size,no-magic-numbersno-explicit-any,no-unsafe-*,no-non-null-assertiongocyclo,gocognit,funlen,nestif,maintidxC901,PLR0911/0912/0915/1702file-length-limitmax-lines,no-multi-compireturngochecknoglobals,gochecknoinitsPLW0603import/no-mutable-exportsgovetcopylocksexhaustive-deps,no-floating-promises,no-misused-promisesexhaustiveFBT001/002switch-exhaustiveness-check, switch-size rulesB006,B008no-param-reassign,prefer-read-only-propsThe generic binding ships no lint config.
The picks
Rule order: judgment questions first, because no search finds them and few linters hold them. Then the questions that decide a type's shape at write time, because that shape is expensive to change in review.
R4, R5, R10 and R12 (judgment-heavy) and R1, R2 and R11 (shape at write time) get three questions. The others get two.
The twelve draft summaries, for your review
Each is one sentence of 20 words or fewer. The wording is a draft.
{{.DocComment}}that says why, and change the feature doc in the same change as the behavior.{{.Task}}an owner that stops it and waits for it, and guard shared state where it lives.R4 uses "juicy", the handbook's term for an R1 score of 4 or more; the digest does not define it. R9 and R10 use the binding's scalars ("godoc comment", "docstring", "JSDoc comment"; "goroutine", "concurrent task", "async task").
Maxims are names only. The request allows "at most one short line". Nine extra lines (about 600 to 900 bytes) do not fit in ts-react's 257 bytes of margin. The names are short imperatives already. If you want the lines, the price is a trim elsewhere in the digest, for example one question less on R1, R2 and R11.
Audit of the full handbooks (not changed in this PR)
Bytes per
##section, as rendered on main:Inside "The twelve rules", summed over the twelve rules:
> In <Lang>/> SpellingasideWhere each binding is longer than go:
> Spelling:asides are +2,644. Its house rules are 618 B shorter.The longest single items: the ts-react R1 example (1,746 B; go 1,382), the ts-react R11 example (1,345 B; go 630), the ts-react R2 example (1,241 B; go 667), the R4 Principle (1,353 B in every binding, twice the next Principle), and the "When in Rome" maxim (about 560 B).
Proposed trims, for a separate decision
Handbook-only (no plugin file changes, so no eval): none proposed.
A rewrite of the asides in ASD-STE100 that keeps every fact was measured on the twelve ts-react asides: 8,342 to 8,200 bytes, 2% less. It makes the text clearer for a human reader, not shorter, so it is not proposed as a trim. The defects that the rewrite found are fixed in this PR (see below).
Three cuts are not proposed, because each one removes a lesson:
assertNever.A fixed cap of about 400 B per aside is not proposed. Each aside holds the language's position, and most of its sentences are separate facts that no other part of the handbook has. For example, the ts-react R8 aside lists what is never a finding, what is a finding only outside the composition root, and what is always a finding. A 400 B cap keeps the findings and removes the "never a finding" list, which stops a reader from applying the rule too widely.
A split of the examples into a separate document is not proposed. The digest is already that split: teams import the digest, and the full handbook costs tokens only when someone opens it. A file per rule would cut an on-demand read from about 43 kB to about 3 kB. Consider it only if evals show that agents often open the full handbook.
Plugin text (would need an eval under
docs/eval-baseline.md, "Core text that all bindings render"):core/rules/R4-helper-placement.mdcore/maxims.mdNo plugin file changed, so no eval
git diff --stat origin/main --over the four plugin directories,core/rules,core/includes/rules,core/agents,core/skills,core/commands,core/maxims.mdandlang/*/passthroughis empty.The full handbooks
coding-rules/ts-react.mdandcoding-rules/python.mdchange only in their asides (lang/<lang>/handbook/, which no plugin reads). The fixes make each aside stand alone:The fixes do not change the go and generic handbooks or any digest.
The scope row in
docs/eval-baseline.md, "Choosing the eval scope for a change": "Shared script or generator, plugin text byte-identical | Shell tests andtask check. No eval."lang/ts-react/passthrough/README.mdnames only the full handbook. It is plugin text, so this PR does not change it.docs/quick-start.mdhas no passage that tells a team what to import. The import advice lives inREADME.md, which this PR changes.Test plan
task generatefor go, generic, python and ts-reacttask check: every plugin directory, handbook and digest matches its renderingtask lint-core(the Residue section ofcore/README.mdgains one soft row for theinterfaceaside inR6/digest.md)go test ./...andgolangci-lint run ./...intools/ldd-gen: 0 issuesbash scripts/check-docs.shtask test-gatedigest:validation;render.Digest(output, unknown maxim, no digest in the profile, at and over the ceiling, not a plugin file); generate and check for a digest (missing, changed, exec bit), residue gate on a non-Go digest, refusal to overwrite a hand-written digest, path conflicts between digests and handbooks🤖 Generated with Claude Code