feat(reuse): recording model becomes the pattern library — every shape at first build (#2687)

Decision #2686: snippets are the project's pattern library, not a dedup
net. The floor, the reusing-code skill, and the snippet tool docstrings
now state the proactive model — record every shape the first time it is
built, with no will-it-recur judgment, and start later instances from
the recorded shape; second-copy consolidation stays as the backstop.
The floor guard test pins all three elements (tool, first-build trigger,
backstop) so the model cannot silently regress to the reactive wording.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-16 11:33:24 -04:00
co-authored by Claude Fable 5
parent 4107b17727
commit 2d58e74ec7
4 changed files with 70 additions and 42 deletions
+17 -7
View File
@@ -23,7 +23,12 @@ async def list_snippets(
q: str = "", tag: str = "", limit: int = 50, project_id: int = 0,
repo: str = "", path: str = "", symbol: str = "", verification: str = "",
) -> dict:
"""List recorded snippets (reusable functions/components).
"""List recorded snippets — the project's pattern library.
Search here BEFORE building any shape (a component, control, route
handler, service class, helper, scaffold): a recorded shape is the
starting point for every later instance, and building without checking is
how the same button ends up defined four diverging ways.
Two ways to ask, usable together: by MEANING (`q` — "what do I need this code
to do?") and by PLACE (`repo`/`path`/`symbol` — "what canonical helpers
@@ -101,13 +106,18 @@ async def create_snippet(
system_ids: list[int] | None = None,
force: bool = False,
) -> dict:
"""Record a reusable function/component so future sessions can RECALL it
instead of writing a fresh one-off.
"""Record a shape in the project's pattern library, so every later
instance starts from it instead of re-deriving it.
Reach for this the moment you build (or notice) something reusable: a helper,
a hook, a component, a pattern worth repeating. Recording it once makes it
surface automatically when a similar problem comes up later. Before writing a
new utility, search first — a snippet may already exist.
Reach for this the FIRST time any shape is built — a component, a control,
a route handler, a service class, a helper, a test scaffold — not only
when something is judged "reusable": the builder of the first instance
can't know what will recur, and a missed record is invisible until it
resurfaces as an uninformed duplicate. Over-recording is safe (dead weight
shows in the usage counters and can be pruned); under-recording has no
signal. A deliberate departure from a recorded shape is recorded as its
own named variant, not left as drift. Before building, search first — the
shape may already be recorded.
Args:
name: Short name of the function/component, e.g. "useDebouncedRef".