api-surface

A design guide describing r3's HTTP/JSON API and command-line interface. An API is the set of routes and commands that other programs use to interact with it.

In plain words
What is it for?
Use it when adding or changing routes, review operations, Git browsing, file rendering, command-line usage, or shared request and response types.
Why use it?
It keeps the browser, command-line tool, and AI agent aligned when data formats or behavior change.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/hyperlogue/r3/api-surface
Any agent
npx skills add hyperlogue/r3 --skill api-surface
Clone the repo
git clone --depth 1 https://github.com/hyperlogue/r3

Made for: Claude Code, Codex.

Per session 109 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,104 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00109 $0.04104
Opus 5 $0.00055 $0.02052
Sonnet 5 $0.00022 $0.00821
Haiku 4.5 $0.00011 $0.00410

Measured 2d ago against content hash afec03c502c5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

api-surface scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/api-surface/SKILL.md · 244 lines

How it starts

The opening of the file, as written. The whole thing — 244 lines — stays where its author put it; the contents beside it link to each section on GitHub.

r3's API + CLI surface

This file is the design source of truth for r3's route catalog and CLI usage — update it here when the surface changes. The wire shapes live in shared/types.ts (the contract itself); this is the map over them.

The HTTP/JSON API is the product, not a detail of the React client — there are three clients (browser, CLI, agent). When you change behavior, change shared/types.ts and keep server + CLI + web in sync.

HTTP API

Routes are served by server/index.ts behind the Host + token guards (see the security-model skill). Highlighting runs server-side — Shiki for code, markdown-it for .md (with per-block source-line mapping for anchoring; a ```mermaid flowchart/sequenceDiagram fence becomes a safe SVG) — shipping tokens to the client cached by content sha, so the WASM/grammar weight never reaches the browser.

Browse (read) GET /api/git/status | /api/git/log | /api/git/tree | /api/diff | /api/blob — status, paged commit history, file tree at a ref, a structured highlighted diff, one rendered file.

Reviews

  • GET /api/reviews — list, queryable by session / meta.<k> / status / repo; each row carries a live watching flag.
  • POST /api/reviews — create { kind, source, meta, title, summary }{ id, url, review }. scratch:true creates a scratch review and the response adds the scratchDir path the agent drops files into; patch:'<diff>' stores a piped diff as round 1.
  • GET /api/reviews/:id — review + feedback[] (with replies[]) + round and snapshot metas.
  • GET …/diff[?seq=] — a diff review's rendered rounds. ?seq= returns that one round ({ rounds: [that] } or { rounds: [] } if missing); omitted returns every stored round (compat). A legacy review with no stored patches renders live as seq 0 (?seq=0 or omitted). Rounds are stored wide and rendered at 3 context lines; each hunk row carries expandable {up,down} saying how many unchanged lines the server still HOLDS: up = the gap above that hunk, down = the gap below, set on the last hunk of each contiguous run (a body has several runs when capture itself had gaps). All-zero/absent = nothing more exists, and the client shows no expander.
  • GET …/diff-context?file=&start=&end=&(seq= | from=&to=)[&theme=]{ file, lines } — fill one collapsed gap. [start,end] are NEW-side line numbers, capped at 5000 rows. seq selects a diff review's stored round; from/to a files review's snapshot diff — branch on which params are present, never on a seq value, since the snapshot diff is presented as synthetic round 0 and would collide with the legacy live-render round 0. A range the source can't fully cover is a 404, never a partial fill.
  • GET/POST/DELETE …/patches[/:seq] — list / append / drop a round.
  • POST …/files — membership { add?, remove? }.
  • GET/POST/DELETE …/snapshots[/:seq], …/snapshot-diff, …/snapshot-blob — content snapshots and their derived diffs.
  • PATCH /api/reviews/:id — edit { status?, meta?, title?, summary?, note? } (notemeta.next_steps); DELETE /api/reviews/:id.

Read the full file on GitHub · 244 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 244 lines · 109 tokens per session scan A afec03c502c5

Subscribe to this mod's changes

api-surface is a skill published in the GitHub repository hyperlogue/r3 (23 stars, last pushed 7d ago), licensed MIT. It adds 109 tokens to every session and 4,104 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.