Skip to content
EN · PT

anchors code

Generate a unique identity code for a new unit.

Generates the scenario code (the identity, TRACEABILITY §3) of a unit,
GUARANTEEING uniqueness against the codes already in use in the map. Use it BEFORE writing the
spec, so as not to collide with another unit (which would generate wrong cross propagation).
anchors code Spacer → suggests a free code for "Spacer"
anchors code --check SPCR → says whether SPCR is free or already belongs to someone
anchors code list → lists ALL the codes in use, with who uses them
anchors code list --in apps/mobile → only those of the workspace
The "code list" reads the identity field of the MAP, it does not search for a pattern in the text: a grep for
ABCDX-X01 matches a mention in prose, a comment and a file name, and depends on the length of the
code (which varies per project, see code_lengths). The output is "code<TAB>where", one per
line; the summary goes to stderr, so "anchors code list | ..." pipes without dirt.
The algorithm (Layer 2 of the SPEC_GUIDE: name compression; Layer 3: collision
resolution) is agnostic. Module prefixes (Layer 1) are project dialect — if yours
uses them, choose the code by hand and validate it with --check.
Terminal window
anchors code <name> [flags]
Flag Default What it does
--check validate whether a proposed code is free
--map path to the map
--root . project root

List the identity codes IN USE in the project (from the map, not by regex).

Enumerates the codes the map knows, with each unit's folder.
Reads the identity field of the MAP — it does not search for a pattern in the text. A grep for ABCDX-X01 matches
a mention in prose, a comment and a file name, and depends on the length of the code, which
varies per project (see code_lengths in anchors.yaml). Here the answer is exact.
anchors code list every code in use
anchors code list --in apps/mobile only those of one workspace of the monorepo
Output: "code<TAB>where", one per line; the summary goes to stderr, so the list pipes
without dirt. A code with SEVERAL folders is an identity collision — the doctor
reports it, and here it becomes visible for free.
Terminal window
anchors code list [flags]
Flag Default What it does
--check check the LENGTH of each code against code_lengths and show the fix
--in only the codes under this path prefix (e.g.: apps/mobile)
--json emit the list as JSON (for script/pipeline consumption)
--map path to the map
--root . project root

Commands of the same family — what tells each apart:

Command What it does
anchors init Configure the project (anchors.yaml) through questions and answers
anchors new Emit the skeleton of an artifact (spec, feature, test, plan…) per the ruler
anchors code Generate a unique identity code for a new unit
anchors guide Print the Anchors guides for AI agents
anchors docs Compile the documentation from the templates in doct/
anchors install-hooks Install the git pre-commit that runs the gates over staged files
anchors migrate Bring the Anchors files up to the current format
anchors settings This agent’s LOCAL configuration — what is its own, not the project’s
anchors touch Bump updated_at in the @anchors header of the files that changed