diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 67b50ac..8806434 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -78,6 +78,12 @@ "description": "Concurrency skills for finding and fixing time-of-check to time-of-use races in files, databases, caches, authorization, and distributed stores", "source": "./plugins/trogonstack-concurrency", "category": "development" + }, + { + "name": "trogonstack-engineering", + "description": "Engineering principles for deciding where to invest effort so mistakes are prevented by the codebase and tooling instead of prose and human review", + "source": "./plugins/trogonstack-engineering", + "category": "development" } ] } diff --git a/.cursor-plugin/marketplace.json b/.cursor-plugin/marketplace.json index bc13b90..d62f8bd 100644 --- a/.cursor-plugin/marketplace.json +++ b/.cursor-plugin/marketplace.json @@ -66,6 +66,11 @@ "name": "trogonstack-concurrency", "source": "plugins/trogonstack-concurrency", "description": "Concurrency skills for finding and fixing time-of-check to time-of-use races in files, databases, caches, authorization, and distributed stores" + }, + { + "name": "trogonstack-engineering", + "source": "plugins/trogonstack-engineering", + "description": "Engineering principles for deciding where to invest effort so mistakes are prevented by the codebase and tooling instead of prose and human review" } ] } diff --git a/.github/release-please-config.json b/.github/release-please-config.json index 4bacb18..1277011 100644 --- a/.github/release-please-config.json +++ b/.github/release-please-config.json @@ -69,6 +69,9 @@ }, "plugins/trogonstack-concurrency": { "component": "trogonstack-concurrency" + }, + "plugins/trogonstack-engineering": { + "component": "trogonstack-engineering" } }, "plugins": [ diff --git a/.github/release-please-manifest.json b/.github/release-please-manifest.json index 686212c..fa69e44 100644 --- a/.github/release-please-manifest.json +++ b/.github/release-please-manifest.json @@ -10,5 +10,6 @@ "plugins/trogonstack-product-requirements": "0.2.0", "plugins/trogonstack-elixir": "0.2.0", "plugins/trogonstack-protobuf": "0.1.1", - "plugins/trogonstack-concurrency": "0.1.0" + "plugins/trogonstack-concurrency": "0.1.0", + "plugins/trogonstack-engineering": "0.0.1" } diff --git a/plugins/trogonstack-engineering/.claude-plugin/plugin.json b/plugins/trogonstack-engineering/.claude-plugin/plugin.json new file mode 100644 index 0000000..e1bdc75 --- /dev/null +++ b/plugins/trogonstack-engineering/.claude-plugin/plugin.json @@ -0,0 +1,9 @@ +{ + "name": "trogonstack-engineering", + "description": "Engineering principles for deciding where to invest effort so mistakes are prevented by the codebase and tooling instead of prose and human review", + "version": "0.0.1", + "author": { + "name": "TrogonStack", + "url": "https://github.com/TrogonStack" + } +} diff --git a/plugins/trogonstack-engineering/.cursor-plugin/plugin.json b/plugins/trogonstack-engineering/.cursor-plugin/plugin.json new file mode 100644 index 0000000..03c0f83 --- /dev/null +++ b/plugins/trogonstack-engineering/.cursor-plugin/plugin.json @@ -0,0 +1,26 @@ +{ + "name": "trogonstack-engineering", + "displayName": "TrogonStack Engineering", + "description": "Engineering principles for deciding where to invest effort so mistakes are prevented by the codebase and tooling instead of prose and human review", + "version": "0.0.1", + "author": { + "name": "TrogonStack" + }, + "homepage": "https://github.com/TrogonStack/agentskills/tree/main/plugins/trogonstack-engineering", + "repository": "https://github.com/TrogonStack/agentskills", + "license": "MIT", + "keywords": [ + "trogonstack", + "engineering", + "guardrails", + "static-analysis", + "agents-md" + ], + "category": "developer-tools", + "tags": [ + "engineering", + "guardrails", + "code-quality" + ], + "skills": "./skills/" +} diff --git a/plugins/trogonstack-engineering/README.md b/plugins/trogonstack-engineering/README.md new file mode 100644 index 0000000..875b8d3 --- /dev/null +++ b/plugins/trogonstack-engineering/README.md @@ -0,0 +1,7 @@ +# trogonstack-engineering + +Engineering principles for deciding where to invest effort so mistakes are prevented by the codebase and tooling instead of prose and human review. + +```bash +claude plugin install trogonstack-engineering@trogonstack +``` diff --git a/plugins/trogonstack-engineering/plugin.json b/plugins/trogonstack-engineering/plugin.json new file mode 100644 index 0000000..7ec335f --- /dev/null +++ b/plugins/trogonstack-engineering/plugin.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json", + "name": "trogonstack-engineering", + "version": "0.0.1", + "description": "Engineering principles for deciding where to invest effort so mistakes are prevented by the codebase and tooling instead of prose and human review", + "author": { + "name": "TrogonStack", + "url": "https://github.com/TrogonStack" + }, + "homepage": "https://github.com/TrogonStack/agentskills/tree/main/plugins/trogonstack-engineering", + "repository": "https://github.com/TrogonStack/agentskills", + "license": "MIT", + "keywords": [ + "trogonstack", + "engineering", + "guardrails", + "static-analysis", + "agents-md" + ] +} diff --git a/plugins/trogonstack-engineering/skills/engineering-place-guardrails/SKILL.md b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/SKILL.md new file mode 100644 index 0000000..c78610d --- /dev/null +++ b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/SKILL.md @@ -0,0 +1,96 @@ +--- +name: engineering-place-guardrails +description: "Decide where a guardrail belongs so a mistake is prevented by the cheapest layer that can carry it: the codebase itself (API design, architecture, refactoring), then static analysis (types, compilers, lints, tests, CI), then verification (formal, property, runtime), then prose (rules, skills, AGENTS.md), and only last human review. Walks a proposed rule or a recurring mistake down that pyramid, stops at the first layer that can hold it, and reports what to build there plus what prose or review can be deleted once it lands. Use when someone wants to add a rule to AGENTS.md, CLAUDE.md, a skill, a style guide, or a review checklist; when the same review comment or agent mistake keeps coming back; when auditing an instructions file that keeps growing; when asking 'how do we stop agents from doing X', 'should this be a lint', or 'where should this convention live'. Do not use for choosing a specific lint tool's configuration, writing the test itself, or general code review." +allowed-tools: + - AskUserQuestion + - Read + - Write + - Bash +--- + +# Place Guardrails + +Every guardrail costs something each time it is used. Put it where that cost is lowest: make the mistake impossible in the code before making it detectable, detectable before asking anyone to remember it, and remembered before asking a human to catch it. + +## Core Principle + +Picture an inverted pyramid. The wide top is where effort should go; cost per prevented mistake grows as you move down. + +| Layer | How it stops the mistake | Paid on every change | Read when weighing it | +|---|---|---|---| +| 1. Codebase | cannot be written | nothing | [layers/codebase.md](references/layers/codebase.md) | +| 2. Static analysis | rejected deterministically before merge | machine time | [layers/static-analysis.md](references/layers/static-analysis.md) | +| 3. Verification | caught against a stated property, at build or run time | more machine time, some misses reach runtime | [layers/verification.md](references/layers/verification.md) | +| 4. Prose | a reader remembers and complies | context, attention, drift | [layers/prose.md](references/layers/prose.md) | +| 5. Human review | a person notices | scarce time, slow feedback, inconsistency | [layers/human-review.md](references/layers/human-review.md) | + +Each layer down is less reliable and more expensive per use, and the cost recurs: prose is re-read by every agent on every task, review is paid on every pull request. A refactor at the top is paid once. + +The lower layers are not bad. They are the right home for intent, trade-offs, and judgment, which the upper layers cannot express. The failure is using a lower layer for something an upper layer could carry: the expensive layer fills with work the cheap one should do, and crowds out what only it can do. + +## Principles + +### 1. Start At The Top And Walk Down + +Ask each layer in order "can you carry this?" and stop at the first yes. Do not start from the layer the request arrived in. A request to "add a line to AGENTS.md" is a request to prevent a mistake; the prose is one candidate answer, usually not the best. Read only the layer files you are actually weighing, top down, and stop reading once one says yes. + +### 2. Make It Unrepresentable Before Making It Detectable + +A type that cannot hold an invalid value beats a lint that flags it, which beats a test that catches it. If the right path is also the easy path, agents and humans take it without being told. + +Read [references/layers/codebase.md](references/layers/codebase.md) when looking for the codebase move, or when it seems too expensive to make now. + +### 3. Deterministic Beats Probabilistic + +Layers 1 to 3 give the same answer every time and do not depend on anyone having read anything. Layers 4 and 5 depend on attention, which is finite. If a program can check a rule, a program should check it. "Never import X from Y" is a lint, not a sentence. + +Read [references/layers/static-analysis.md](references/layers/static-analysis.md) when a rule is phrased "never" or "always", or when a proposed check would be noisy. + +### 4. Prose Is A Backlog + +Every rule in an instructions file is either something only a reader can apply, or a guardrail waiting to be promoted. Treat the second kind as debt. When it is promoted, delete the prose. + +Read [references/layers/prose.md](references/layers/prose.md) when deciding whether a rule is judgment or mechanical. Read [references/review/audit-instructions.md](references/review/audit-instructions.md) when the input is a whole AGENTS.md, CLAUDE.md, rules directory, or checklist rather than one rule. + +### 5. Recurrence Is The Signal + +The same review comment twice, or the same agent error across sessions, means the current layer is not holding it. Move it up, not sideways: a second, louder sentence is not a fix. + +### 6. Human Review Is For Judgment Only + +Reserve the bottom layer for what no layer above can decide. Every mechanical catch a reviewer makes is evidence of a missing guardrail higher up. + +Read [references/layers/human-review.md](references/layers/human-review.md) when the guardrail seems to land at the bottom, or when mining review comments for candidates. + +## Procedure + +1. **Name the mistake.** State the concrete wrong outcome, not the rule text. "Handlers call the database directly", not "follow the repository pattern". For a whole file, switch to the audit steps (principle 4). +2. **Find where it lives today.** Which layer catches it now, if any, and the evidence it slips through. +3. **Walk the layers top down** (principle 1), reading each layer's file only while weighing it. +4. **Weigh one-time cost against recurring cost.** If the upper layer is too expensive now, pick the next one down and record the upper move as a follow-up. A breaking change is the user's call; ask with AskUserQuestion. +5. **Plan the deletion.** List the prose, checklist items, or review steps that become redundant once the guardrail lands. +6. **Report** in the format below. + +## Report Format + +```markdown +### + +- Today: () +- Layer chosen: +- Why not higher: +- Move: +- Delete after: +- Follow-up: +``` + +Read [references/review/report-template.md](references/review/report-template.md) before writing the first entry, for worked examples including one that correctly lands at human review. + +## Quality Checklist + +- [ ] The mistake is stated as an outcome, not as the text of a rule. +- [ ] Every layer above the chosen one has a stated reason it cannot carry the guardrail. +- [ ] Rules a program can check were not left in prose. +- [ ] Prose kept in place encodes intent, priority, or judgment. +- [ ] Redundant prose and review steps are listed for deletion. +- [ ] Deferred higher-layer moves are recorded, not dropped. diff --git a/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/codebase.md b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/codebase.md new file mode 100644 index 0000000..446171c --- /dev/null +++ b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/codebase.md @@ -0,0 +1,20 @@ +# Layer 1: Codebase + +The guardrail is the shape of the code. Nothing runs and nothing is read; the wrong thing is impossible or harder to write than the right thing. Paid once, when the change lands. + +## Moves + +- **Parse, do not validate.** A constructor returns a typed value (`EmailAddress`, `NonEmptyList`, `Money`) so downstream code never receives the raw form. +- **Narrow the signature.** Accept the domain type instead of `string`, a closed enum instead of a flag string, return a result type instead of throwing. +- **Remove the footgun.** Delete or make private the API that is easy to misuse, and leave one obvious path. +- **Draw the boundary.** Put the dependency behind a module or package the wrong caller cannot import. +- **Make the default safe.** Timeouts, escaping, and limits on by default, with an explicit and greppable opt-out. +- **Implement the rule once.** Refactor duplication into one place so the rule is enforced by a single implementation instead of remembered at every call site. + +## Can This Layer Carry It? + +Yes when the mistake is a value, call, or dependency the type system or module system can make unreachable. Usually no when the mistake is about behavior over time, cross-service agreement, or intent. + +## When It Is Too Expensive Now + +A breaking API change, a migration across many callers, or a public contract you do not own. Say so, carry the guardrail one layer down (often a lint), and record the codebase move as a follow-up. Do not decide a breaking change alone; ask. diff --git a/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/human-review.md b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/human-review.md new file mode 100644 index 0000000..5c4ab81 --- /dev/null +++ b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/human-review.md @@ -0,0 +1,17 @@ +# Layer 5: Human Review + +A person notices and decides. The scarcest resource, the slowest feedback, and the least consistent result. Paid on every pull request. + +## What Belongs Here + +- Is this the right problem, and the right design for it. +- Is the trade-off acceptable for users and the business. +- Does the change fit where the system is going. + +## What Does Not + +Any mechanical catch: style, naming, banned calls, missing tests, wrong layer dependencies. Each time a reviewer makes one, a guardrail is missing higher up. Turn it into one and remove it from the checklist. + +## Signal To Collect + +Recurring review comments are the cheapest source of promotion candidates. Group them by mistake, count recurrences, and walk each group down the pyramid from the top. diff --git a/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/prose.md b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/prose.md new file mode 100644 index 0000000..d14896c --- /dev/null +++ b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/prose.md @@ -0,0 +1,20 @@ +# Layer 4: Prose + +A reader, human or agent, is asked to remember and comply. Paid on every read: context, attention, and drift as the code changes underneath it. Compliance is probabilistic. + +## What Belongs Here + +- **Intent and priorities.** Why the system is shaped this way, what to optimize for when goals conflict. +- **Judgment calls.** When to choose A over B, and the signals that tell them apart. +- **Navigation.** Where things live, which tool or command to use for what. +- **Pointers upward.** "Run `make check` before pushing" beats restating everything it checks. + +## What Does Not + +- Anything phrased "never X" or "always Y" that a program can decide: that is a lint or a type. +- Rules restating what a tool already enforces: delete them. +- A second, louder version of a rule that is already being ignored: the rule is in the wrong layer. + +## Test For A Prose Rule + +Ask: could a program decide whether this rule was followed, from the code alone? If yes, it is a promotion candidate. If deciding needs context about goals, users, or trade-offs, it belongs here. diff --git a/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/static-analysis.md b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/static-analysis.md new file mode 100644 index 0000000..683e2c5 --- /dev/null +++ b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/static-analysis.md @@ -0,0 +1,19 @@ +# Layer 2: Static Analysis + +The wrong thing can be written, but a deterministic tool rejects it before merge. Paid in machine time on every change, never in attention. + +## Moves + +- **Compiler and type checker settings.** Strict mode, exhaustive matching, no implicit any, warnings as errors. +- **Lint rules, including custom ones.** Banned imports, banned calls, required patterns, naming. A rule phrased as "never X" or "always Y" is usually a lint. +- **Architecture tests.** Assert dependency direction between modules and layers. +- **Unit and integration tests.** For behavior types cannot express, tied to the specific mistake. +- **CI gates.** Formatting, schema compatibility, generated code up to date, and every check marked required. A check that can be skipped is prose with extra steps. + +## Can This Layer Carry It? + +Yes when a program can decide the rule from the source, the build, or a test run, without false positives that teach people to ignore it. If the check is noisy, the rule is probably a codebase move (layer 1) in disguise, or genuine judgment (layer 4 or 5). + +## Backstop Role + +Even when layer 1 carries the guardrail, a cheap lint here can keep the escape hatch from spreading (for example, flag uses of the explicit opt-out). diff --git a/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/verification.md b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/verification.md new file mode 100644 index 0000000..fe292a3 --- /dev/null +++ b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/layers/verification.md @@ -0,0 +1,18 @@ +# Layer 3: Verification + +A stated property is checked across many inputs, a model of the system, or the running system. More expensive to build and run than static analysis, and runtime checks let some mistakes reach a live system before they are caught. + +## Moves + +- **Property-based tests and fuzzing.** Invariants over input spaces: round-trips, idempotence, ordering, conservation of totals. +- **Model checking and formal specs.** Protocols, state machines, concurrency, where examples cannot cover the interleavings. +- **Runtime assertions and contracts.** Fail loudly at the point the invariant breaks instead of corrupting state downstream. +- **Production signals tied to the property.** Alert on the invariant (balance never negative, every instance terminates) rather than on symptoms. + +## Can This Layer Carry It? + +Yes when the rule is a property of behavior that holds for all inputs or all executions, and examples in layer 2 would miss cases. No when the property cannot be stated precisely; that is judgment. + +## Why It Sits Below Static Analysis + +Verification states what must be true; it does not stop the wrong code from being written, and runtime checks fire after deploy. Prefer a layer 1 or 2 move when one exists, and use this layer for what they cannot express. diff --git a/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/review/audit-instructions.md b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/review/audit-instructions.md new file mode 100644 index 0000000..f3e28cf --- /dev/null +++ b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/review/audit-instructions.md @@ -0,0 +1,32 @@ +# Auditing An Instructions File + +For AGENTS.md, CLAUDE.md, a rules directory, a style guide, or a review checklist that keeps growing. + +## Steps + +1. **Split into rules.** One line per distinct instruction. Merge duplicates; note contradictions as findings on their own. +2. **Classify each rule.** + - *Mechanical*: a program could decide compliance from the code alone. Promotion candidate. + - *Already enforced*: a tool already checks it, the check runs in a required CI gate, and it covers the rule's full scope. Delete. A check that only runs locally, is optional, or covers part of the rule is a promotion candidate: make it required or widen it first. + - *Judgment*: intent, priority, trade-off, navigation. Stays in prose. + - *Stale reference*: the requirement still holds but names code, tools, or paths that moved. Update the reference, then classify the rule again. + - *Obsolete*: the requirement itself no longer applies. Delete. +3. **Walk each promotion candidate down the pyramid** and write a report entry using [report-template.md](report-template.md). +4. **Rank** candidates by recurrence (how often the mistake actually happens) times cost of a miss. Promote the top ones first; the rest are recorded as follow-ups. +5. **Show the end state.** The file after deletions and promotions, so the reduction is visible. + +## Output + +```markdown +## Summary + rules: to promote, already enforced, obsolete, judgment (kept) + +## Promotions + + +## Delete +- : + +## Keep +- : +``` diff --git a/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/review/report-template.md b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/review/report-template.md new file mode 100644 index 0000000..c900dd7 --- /dev/null +++ b/plugins/trogonstack-engineering/skills/engineering-place-guardrails/references/review/report-template.md @@ -0,0 +1,32 @@ +# Report Template + +One entry per mistake. Three worked entries follow, ending with one that correctly lands at the bottom. The first shows a common shape: a codebase move that makes the right path easy, with a static check closing the escape hatch the code alone leaves open. + +## Handlers query the database directly + +- Today: human review (flagged in review repeatedly, still slips in agent-written handlers) +- Layer chosen: codebase +- Why not higher: n/a, top layer +- Move: handlers receive only repository interfaces through their constructor; the database client is not exported from the persistence package. Hiding the client does not stop a handler from importing the driver and opening its own connection, so pair it with a required import lint (layer 2) that bans the driver and the persistence internals in the handlers package +- Delete after: the AGENTS.md line "always go through the repository layer" and the matching review checklist item, once the lint runs in a required CI gate +- Follow-up: none + +## Amounts mixed up between cents and dollars + +- Today: prose ("amounts are in cents"), plus incidents +- Layer chosen: codebase +- Why not higher: n/a, top layer +- Move: a `Money` type carrying currency and minor units, built only from explicit factories, with no raw numeric arithmetic exposed +- Delete after: the sentence in the style guide and the review checklist item +- Follow-up: none + +A lint flagging arithmetic on fields named `amount` was considered and rejected: noisy and incomplete, which is a sign the rule belongs higher. + +## The new endpoint might be the wrong abstraction + +- Today: human review +- Layer chosen: human review +- Why not higher: codebase, static analysis, and verification cannot decide whether a design is right; prose can state the team's design principles but cannot apply them +- Move: keep in review, and make sure the design principles exist in prose so the author applies them before review +- Delete after: none +- Follow-up: none