> 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-claude-plugin/skills-reference-for-loci-claude-plugin.md).

# Skills Reference for LOCI Claude Plugin

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

### 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.

### 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.

#### /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.
