/loci:contractfrom LOCI
Author and inspect this repository's Contract Envelope (.loci/contract.yaml) — the stack, timing, energy, memory and structural bounds that let LOCI judge a measurement rather than merely report it. Use when the user states a limit as a requirement: "set a budget", "add a bound", "cap X at N", "X must not exceed N", "fail the build if timing regresses"; also "what are my limits", "show the contract".
Ships in LOCI. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
.loci/contract.yaml holds the bounds this repository requires — one committed
file, a flat list of entries. Every LOCI skill reads it and judges its findings
against it.
A contract is what buys enforcement. Without one, every row's STATUS is the
word the agent's own assessment maps to and the verdict comes from a reading of
the figures: LOCI reports the number and argues about it, but nothing was
compared, which is what the caption under such a table says. An entry here is
what puts a computed word in that column. That is a fact about how the
verdict vocabulary works — see <plugin-dir>/skills/_shared/verdicts.md — and
not a reason for a measuring skill to advertise this one. Skills never prompt for
setup; the user arrives here by asking.
One rule governs this whole skill: you draft, the user applies.
You may read (loci contract show, lint) and draft (loci contract draft …).
You may not run accept, init, or a bare edit/disable/enable, and you
may not edit the file with Edit/Write. All of those are denied by a hook, so
attempting one wastes a turn.
The reason is worth holding onto, because it is not arbitrary: an entry is a requirement. Requirements have an author, and the only author is the repo owner. A bound they never applied is one nobody set — and the portal renders this file as what the repository requires, while the release evidence bundle cites it to a certification reader. So a fabricated entry does not stay local. It also means you never resolve a failing bound by moving it.
Every loci call prints one JSON envelope ({ok,data}); let it print and branch
on ok. These verbs need no sign-in.
loci project [--project-root <the project the user named>]
loci contract show --project-root <project_root>
loci project is the house rules' Resolving the project. A contract is authored
without a recipe, so show or draft it either way; on not_initialized, close with
/loci:init <project_root> — what lets these bounds be measured — never a measurement.
Carry --project-root <project_root> on every loci contract call below: without it
they resolve from the shell's directory, not the project the user named.
data.exists: false or data.counts.enabled == 0 → no active contract
(missing, empty, or everything disabled); go to Step 5.index. They cannot amend what they cannot see.entry_key — the identity a request, a judged row and a
run line name it by. index is its position in the file and moves when an entry
is inserted above it; entry_key does not. Use index for the draft verbs, and
entry_key to match an entry against a recorded run.data.draft present → a draft is already pending. Say what is in it
(loci contract draft show) before adding to it. If data.draft.stale is
true, the contract moved underneath it: run loci contract draft clear and
start over.This is the one part only you can do. Turn what the user said into an entry object:
{
"text": "comms_task must stay under 2 KB of stack",
"kind": "budget",
"function": "comms_task",
"signal": "stack_depth",
"bound": {"max": 2048, "unit": "B"},
"severity": "fail"
}
Rules, in order of how often they are got wrong:
text is the user's sentence, verbatim. Not a paraphrase, not tidied, not
translated, not expanded into your own wording. It is their intent, it is what
a verdict quotes back to them, and it is the entry's identity.2 KB → {"max": 2048, "unit": "B"} while text still says "2 KB".
| signal | unit |
|---|---|
stack_depth, stack_frame_size, rom_size, ram_size | B |
hot_path_time, worst_path_time | ns |
energy | nWs (other energy units convert) |
exec_time, and tell the user to migrate an existing one.
Draft hot_path_time for the normal case, worst_path_time for the worst case.
loci contract lint reports the old spelling, and the entry is not enforced
in practice: no measuring skill recognises the signal, so nothing supplies a
measurement for it and every run files it unjudged. Say that plainly rather than
"it keeps working" — a bound that enforces nothing is the thing the user most
needs to hear about. Rewriting their file is still their call, not yours.bl costs the call, never the
callee body, so the budget does not cover the call tree. If the user means
latency through the callees, say LOCI does not measure it and confirm they
mean the function's own blocks.
energy shares that basis (exec-trace's energy_nws is self-scoped too).rom_size counts its own instructions, not the tables or
strings it reads. Say so when drafting one; bound the whole artifact (no
function) for those. ram_size takes no function.kind from the intent — required on every entry that has a
bound, and rejected without one: "must stay under / must never exceed" →
budget; "must not regress more than" → regression (with
bound.max_delta, e.g. "+10 %" — always against the previous version, and
write the space so drafted entries match what contract init wrote);
a structural property with zero tolerance (budget 0) → invariant. It is what
tells a max: 0 invariant from a budget whose limit is genuinely zero, and it
is part of the entry's identity, so an entry without it is a second bound on
the same thing.
A text-only entry has no bound and takes no kind.bound needs a limit — max, min, or max_delta. A bound carrying
only a unit is rejected: it reads as enforceable and can never be judged.unbounded_recursion, recursion_cycles,
indirect_calls, unknown_callees) are invariant with
bound: {max: 0} and no function — they cover the whole binary, and a
function on one is rejected. stack-depth is what measures all four, over a
linked binary; the count it reports is what the bound is judged against.severity follows the modal in the sentence, so the same wording always
drafts the same severity and the user can predict it:
| the sentence says | severity |
|---|---|
| must, shall, never, no more than, hard fail, fail the build | fail |
| should, can, prefer, try to, ideally, nice to have, just warn me | caution |
| no modal at all — "cap it at 2 KB", "budget is 200 ns" | omit it |
Omitted means caution. There is no defaults: block; never write one. | |
Never draft warn: it is the retired spelling, read as caution with a | |
| lint notice. An existing one still enforces its bound — report the notice, and | |
| change the file only if the user asks. | |
| Two ways this goes wrong: a sentence carrying both ("should never exceed") is | |
caution — the weaker word governs, because escalating a preference into a | |
| build failure is the costlier error; and a modal you are guessing at is one to | |
| ask about, not to pick. An explicit "hard fail" / "just warn me" always wins | |
| over the table. |
{"text": "ISR handlers should avoid heap allocation entirely"} is a complete, valid entry. Do not invent a
signal to make an entry look finished — a text-only entry is judged by you at
review time, which is the point.echo '<entry json>' | loci contract draft add
An array drafts several at once, as one transaction. draft edit --index <n>,
draft disable --index <n>, draft enable --index <n> are the other ops.
On ok: false, read error.message — it names the field — and fix the object.
Do not re-send it unchanged. Two rejections are worth recognising:
draft edit --index <n>, not add.data.warnings with signal_unknown means the entry is kept but will be judged
by a model rather than computed. Say so plainly; don't silently swap the signal
for one that happens to exist.
Offer the suggested bounds once per draft. When loci contract suggested shows
data.missing > 0, ask (the question tool), listing each text not present:
Add them → loci contract draft add --suggested; Only mine → the user's
alone.
Show each drafted entry in full — the sentence and every field — as a short list, one entry per line. Then stop and ask with the question tool, not with prose. A drafted bound buried in a paragraph gets skipped; a question box does not.
One question, header Draft, options in this order:
No option may be worded as accepting. The box is a review — the answer only decides your next move, and applying the draft is still a command the user runs. An option labelled "Accept" reads as the decision, so they approve it, feel done, and the bound never lands.
Put the entries in the question text so the user is deciding on what they can see. With nobody to answer (print mode), give the hand-over line below and stop.
Then, by answer:
Looks right → give exactly one line and nothing else:
! loci contract accept --project-root <project_root>
Change something → ask what to change, then re-draft (draft clear and
draft again, or add more ops) and return to this step.
Discard → loci contract draft clear, confirm in one line.
Say what accepting does: the entries land in .loci/contract.yaml, unstaged, for
them to review and commit. Do not run it. Do not offer to run it. Do not
present it as a formality — this is where authorship transfers. No answer to the
box licenses you to run it yourself.
If they leave it unapplied and the conversation moves on, do not keep raising it —
the Stop hook nudges them every turn while a draft is pending, from the file
rather than from your memory of it.
Once they have accepted, show the change and leave the commit to them:
git diff --stat -- .loci/contract.yaml
Two confirmations, doing different jobs: accept authorizes the content, the
commit shares it with the team and the portal.
First bound, multi-select): stack depth, execution time, energy,
ROM/RAM. Their pick chooses the signal only — you still ask for the number
and still use their sentence verbatim./loci:stack-depth or /loci:exec-trace
will measure a real value to bound — after /loci:init if Step 1 answered
not_initialized.draft enable --index <n>) may be all that is needed.Do not mention loci contract init — that flow is internal and not
user-facing yet. There is no built-in set of bounds
either: a repo with no contract file is judged against nothing.
If the draft carried more than one op, or you changed anything structural:
loci contract lint --draft
Report data.findings at error severity; warn and info only if they bear on
what the user asked.
Keep it short. Show the entry as it will read in the file, not as JSON, unless
the user asked for the object. Cite indices so a follow-up can address an entry.
One remark per report, as voice.md says,
and here the number comes from the file rather than from a run — "six bounds,
four of them structural" beats "your contract looks good".
Where the user has just accepted their first bound, close with one more line, offered and never instructed, in the cockpit's words:
Run
loci cockpitin a separate terminal to see what LOCI catches that your coding agent might miss during planning and coding.
Once, on the first accept only; a contract they were already running against needs no introduction to it. You never run it yourself.
What SKILL.md sets; muted values are Claude Code's defaults
Also "no more than N bytes of stack for X", "max limit of N", "I want function X to stay under N", or /loci:contract; and when the user asks why a report judged nothing, or how to make LOCI enforce something. Requirement vs. measurement: if the user states a limit, use this skill (draft a bound). If they ask what the current usage or worst case is, that is /loci:stack-depth, /loci:exec-trace or /loci:memory-report instead — those measure, this one authors the bound they are judged against.
Other plugins' skills for the same job
12 skills in this plugin
/bug-reportForensic diagnostic report for LOCI — collects environment state, runs health checks, and writes a timestamped report when analysis fails or doesn't trigger. Use when the user says "bug report", "LOCI isn't working", "something is broken", "debug LOCI", or wants any LOCI failure investigated.
/control-flowAnnotated control-flow graphs for compiled C/C++/Rust/Go and Python (Cython): per-function basic blocks, loops with derived trip counts, recursion and irreducible cycles, call sites, in text optimised for LLM analysis. Renders the graph and judges the two structural signals it determines, recursion cycles and indirect calls, and the contract's text-only rules on the functions it draws. Use when the user asks what the control flow of compiled code looks like: call dependencies, function impact, which branches and loops exist, where the hot path could run, or what a change did to the shape of a function.
/exec-tracenpx claudepluginhub auroralabs-loci/loci-claude --plugin loci