KeiSeiKit-1.0/_capabilities/quality/constructor-pattern/text.md
Parfii-bot c0c3483f02 feat(agent-substrate/phase-1): capability library — 11 declarative bundles
22 files per locked §Initial capability atom inventory:

policy/no-git-ops/               (gate: PreToolUse:Bash, bypass ORCHESTRATOR_META)
scope/files-whitelist/           (gate + verify worktree)
scope/files-denylist/            (gate + verify worktree)
quality/constructor-pattern/     (verify worktree)
quality/cargo-check-green/       (verify both — worktree short-circuit + simulated-merge)
quality/tests-green/             (verify both)
safety/no-dep-bump/              (gate + verify both)
output/report-format/            (verify worktree)
output/severity-grade/           (verify worktree)
tools/read-only/                 (gate: deny Edit/Write)
tools/cargo-only-bash/           (gate: Bash allowlist)

All capability.toml share [capability]/[restricts]/[parameterized]/[text]/
[gate]/[verify] section layout. rust-module paths pre-wired to match
phase-3 file layout. All text.md under 200 words, imperative,
self-contained (composer concatenates with --- separator).

Cross-refs to rule files preserved:
- policy::no-git-ops → RULE 0.13 (orchestrator-branch-first.md)
- quality::constructor-pattern → RULE ZERO (code-style.md)
- output::severity-grade → debugging.md §Security Review
- safety::no-dep-bump → supply-chain rationale

Agent attempted wc -w for word counts — sandbox correctly denied Bash
per RULE 0.13, observable reinforcement of the very policy this
capability encodes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 02:35:52 +08:00

1 KiB

Constructor Pattern — size limits

You MUST keep every file you write or edit under 200 lines of code, and every function under 30 lines of code. These are hard limits, not guidelines.

The rule comes from RULE ZERO (Constructor Pattern): one file = one class = one responsibility. Files that breach 200 LOC should be decomposed into sibling modules. Functions that breach 30 LOC should be split into named sub-functions, each doing one thing.

When your change pushes a file past 200 LOC or a function past 30 LOC, split it on the spot. Do not commit with TODO: refactor later.

Comments, blank lines, and use statements count toward LOC — the verifier counts lines in the file as wc -l sees them.

Exceptions:

  • Auto-generated code (e.g. include!(...) expansions) is skipped.
  • Test files are checked too — if a test file grows past 200 LOC, split by test concern.

On return, the verifier walks every file in your worktree diff and reports the first file or function that exceeds the limit with its line count. No partial credit.