> For the complete documentation index, see [llms.txt](https://docs.loci-dev.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.loci-dev.net/loci-plugin-for-ai-coding-assistants/loci-plugin/skills-reference-for-loci-plugin.md).

# Skills Reference for LOCI Plugin

All skills need a signed-in session except `help`, `setup`, `contract` and `bug-report` — see [Authenticating](https://docs.loci-dev.net/loci-plugin-for-ai-coding-assistants/loci-plugin/authenticating-loci-plugin.md).

### **Reading a LOCI verdict**

Every measuring skill closes on a table with two columns per row.

| STATUS     | Means                        |
| ---------- | ---------------------------- |
| ✅ PASS     | Every compared bound holds.  |
| 🔶 CAUTION | Worth a look, not blocking.  |
| ❌ FAIL     | A bound is breached.         |
| —          | Nothing to judge the row on. |

AGENT ASSESSMENT is the agent's own reading of the same row: Needs attention (it names the block, callee or region behind the concern), Looks good, or As reported.

A bound comes from your Contract Envelope (.loci/contract.yaml, drafted with **`/loci-contract`**) or from a limit you state in the request, such as "keep this under 200 ns". LOCI never invents a bound. When no bound covers a row, its STATUS is composed from the agent assessment, and the report says so under the table.

Plan Guard (**`/loci-preflight`**) judges a plan rather than a measurement, so it closes on GOOD, ADJUST PLAN or STOP.

### Automatic - no command needed

#### **`/loci-preflight`**

Runs automatically in `/plan` mode when you describe new logic. Audits the plan at the binary level — before any code is written — checking timing, energy, and control-flow impact of the callees your new code will invoke.

*Example:* you ask Claude to "add a retry mechanism to `uart_send`." Before writing code, LOCI checks the timing/energy/safety profile of the functions the retry logic will call, and returns one of three verdicts:

* **GOOD** — plan is safe to proceed
* **ADJUST PLAN** — a specific concern is flagged with a recommendation
* **STOP** — regression risk is high; the plan should be reworked

#### **`/loci-post-edit`**

Runs automatically after every edit to a C/C++/Rust source file. Compiles the change, diffs the binary against the pre-edit version, and reports the timing/energy delta at the function level.

*Example output:*

```
uart_send
  Before:  1.24 µs   After:  1.31 µs   Δ +5.6%   ⚠ CAUTION
```

Regressions are caught at the binary level — a change that looks clean in the source diff can still alter execution behavior.

### **`/loci:init`**

Records how this project builds, once per clone: target ISA, compiler, build system and the binary to measure, in .loci/build.yaml. Every skill that compiles or measures uses it. Needs sign-in.

Supported projects: C and C++ (from a compile database, a Makefile, or a fully built binary), Rust (cargo), Go and TinyGo, and Python projects compiled with Cython (aarch64 and Neoverse V2 targets). If a Python project doesn't use Cython, init lists its modules and asks once whether LOCI may compile them; your own build is never changed.

Also run it to switch target ("switch the LOCI target") or when a skill reports recipe\_stale, recipe\_invalid or compiler\_missing.

### On-demand - invoke with a slash command or a natural-language question

#### **`/exec-trace`**

Function-level timing and energy from real hardware traces (via LCLM).

*Ask:* "What's the execution cost of `motor_control_loop`?"

```
motor_control_loop
  Execution time:  3.82 µs  (std dev: 0.12 µs)
  Energy:          0.0041 Ws
  Hottest block:   pid_update — 61% of total cycles
```

Low standard deviation means strong empirical backing from LCLM's training data; high standard deviation means the assembly pattern is underrepresented, and the estimate should be treated with more caution.

Timings are given at the model's trained clock unless you tell LOCI your board's clock ("my board runs at 100 MHz"); it then runs loci frequency set and every report says which clock the figures are at. Ask "which cores does LOCI cover?" to see each model's trained clock.

When a loop's count depends on input, the timing is a lower bound such as ≥ 184 ns. Ask "what if the loop runs 5 times?" and LOCI times that count, labelled as an assumption.

#### /stack-depth

Worst-case stack depth via call-graph traversal, with a pass/fail verdict against a budget.

*Ask:* "Is the stack safe for `TaskMain` with a 2048-byte budget?"

```
Stack Depth: TaskMain
  Worst-case depth:   312 bytes
  Worst-case path:    TaskMain → process_data → decode → crypto_verify
  Budget:             2048 bytes  (15.2% used)
  Verdict: ✅ PASS 15.2%
```

Auto-detects RTOS task entry points from `xTaskCreate`, `Task_construct`, `osThreadNew`, and `FreeRTOSConfig.h`.

#### /memory-report

ROM/RAM section breakdown and top consumers from a compiled ELF binary — no runtime, no instrumentation.

*Ask:* "How much ROM/RAM does my build use?"

Reports section-by-section size (`.text`, `.rodata`, `.data`, `.bss`), top ROM/RAM consumers by function/variable, and — if you provide a linker map file — usage against your memory region budgets.

#### /control-flow

Annotated control-flow graph for a function, extracted directly from the compiled binary.

*Ask:* "Show me the call graph for `process_data()`."

```
Control-Flow Analysis: process_data()
  Call graph:
    process_data()
      ├─ validate_header()        [direct]
      ├─ dispatch_handler()       [direct]
      │    └─ r3 → ??            [indirect · bl r3]  ⚠
      └─ finalize_output()        [direct]
  Findings:
    ⚠  dispatch_handler — indirect call via register (bl r3)
       Verify the dispatch table is bounds-checked before this path is reachable.
```

Indirect calls through registers are a finding class source review alone can't see.

#### /trends

Per-function measurement history on the current branch — timing, stack, and memory trends over time.

*Ask:* "Show me my optimization progress on this branch" or just `/trends`.

Shows a table of tracked functions with edits, first/latest measurement, and direction (improved / regressed / stable / baseline). Read-only — this skill never records new data itself.

#### /contract

Authors and inspects `.loci/contract.yaml` — the stack, timing, energy, memory, and structural bounds every LOCI measurement is judged against. Claude drafts a bound from what you say; only you can apply it.

Ask: *"TaskMain must not exceed 4KB of stack."*

> ```
> Draft: TaskMain must not exceed 4KB of stack
>   kind: budget · signal: stack_depth · bound: max 4096B · severity: fail
>
> [Looks right — give me the command] [Change something] [Discard]
> ```

Read-only checks (`show`, `lint`) need no sign-in; nothing is written to the file until you run the `accept` command Claude gives you.

### Utility - work signed out

#### /help

Shows your environment status (target architecture, compiler, build system, sign-in state, daily quota) and the full skill list, adapted to what's currently working.

#### /loci:setup

Installs, repairs, or verifies the `loci` CLI. Safe to re-run any time; also runs automatically if a skill hits a "CLI missing" error.

#### /bug-report

Generates a full forensic diagnostic report (environment snapshot, a 10-point health checklist, and root-cause reasoning) when something isn't working. Writes a timestamped `.md` file you can share or load into a new session.
