feat(shapes): the practice is written where it is read, and the coverage line measures the slip (milestone 439 step 6)
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 16s
CI & Build / TypeScript typecheck (push) Successful in 54s
CI & Build / integration (push) Successful in 47s
CI & Build / Python tests (push) Successful in 1m39s
CI & Build / Build & push image (push) Successful in 29s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 16s
CI & Build / TypeScript typecheck (push) Successful in 54s
CI & Build / integration (push) Successful in 47s
CI & Build / Python tests (push) Successful in 1m39s
CI & Build / Build & push image (push) Successful in 29s
- reusing-code: "Before the turn ends — say what you built" — the four verdicts, the one classify_shapes(repo=…) call, and the component file as a shape. Description names the end-of-turn moment. - shape-accounting: the writer judges; audits are the check that it held. The write path SUGGESTS (no more hook instances); component file rows and whole-file canon described; scoped covers Svelte too. - _INSTRUCTIONS reuse line: "before the turn ends, say what you built (create_snippet the reusable, classify_shapes the rest)" — 1570/1600. - Coverage line: "written-shape check (7d): N turns checked, M asked, K left unjudged", from the Stop hook's recorded outcomes; silent until the question has been put. - test_guidance_ownership pins the new topic on reusing-code. - prior-art hook header no longer says it stamps instance rows. Plugin version minted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: reusing-code
|
||||
description: Use when you're about to build ANY shape — a component, control, route handler, service class, helper, test scaffold — search recorded snippets FIRST and start from the recorded shape instead of re-solving it. And the FIRST time a shape is built, record it as a snippet so every later instance starts from it. Triggers on "write a util/helper", "I need a function that…", "let me add a component/button/field/route", or having just built the first instance of anything.
|
||||
description: Use when you're about to build ANY shape — a component, control, route handler, service class, helper, test scaffold — search recorded snippets FIRST and start from the recorded shape instead of re-solving it. And before the turn that built it ends, say what it is — record the reusable as a snippet, classify the rest — so every later instance starts from it. Triggers on "write a util/helper", "I need a function that…", "let me add a component/button/field/route", having just built the first instance of anything, or the end-of-turn list of shapes to judge.
|
||||
---
|
||||
|
||||
# Reusing code — the pattern library
|
||||
@@ -85,6 +85,32 @@ through recall/auto-inject; this skill is the active reflex around that.
|
||||
per reusable thing. If it already exists, `update_snippet` it instead of
|
||||
recording a second copy (the create gate will flag a near-duplicate anyway).
|
||||
|
||||
## Before the turn ends — say what you built
|
||||
|
||||
You are the one who knows what the code you just wrote is. The shape ledger
|
||||
records it from your answer, not from a guess made later, so give the answer
|
||||
in the turn that built it — while it is still true. When a turn wrote
|
||||
definitions nobody has judged, the plugin's Stop hook lists them once, with
|
||||
whatever evidence the machinery holds ("looks like #N", "#M is canon in this
|
||||
directory", "new"); other clients reach the same moment through
|
||||
`list_shapes(project_id, path=…)`. For each one, decide:
|
||||
|
||||
- **Something another part of the code should reuse** → record it with
|
||||
`create_snippet` (the fields above). Its own row becomes the canon.
|
||||
- **Built from a recorded snippet** → `instance` of it.
|
||||
- **A deliberate departure from one** → `variant`, with the why.
|
||||
- **A genuine one-off** → `exempt`, with a reason (`reason_code` such as
|
||||
`one-off-handler`, `test-helper`, `scoped-css` or `pure-helper` indexes it).
|
||||
|
||||
One call records them all: `classify_shapes(project_id, repo="<the repo's
|
||||
remote>", classifications=[{path, symbol, kind, status, snippet_id?, reason?}])`.
|
||||
`repo` lets a verdict land on a shape the ledger has not synced yet — the one
|
||||
you wrote a minute ago. A component file is a shape too (`kind: "file"`, named
|
||||
by its stem): when a card, chip or dialog is the reusable thing, the file is
|
||||
what you record. An unsure call is still yours to make — the reason you write
|
||||
is what the next reader judges it by — and a verdict is permanent, so each
|
||||
shape is asked about once.
|
||||
|
||||
## A shared snippet is a suggestion, not a standard
|
||||
|
||||
Scribe is multi-user, so a search can return snippets other people own. Those
|
||||
|
||||
Reference in New Issue
Block a user