New
Apps 6,419Makers 6,403This week 7
Promote your app−30%
casemap screenshot 1
3views in
the last 30 days

casemap

Living map of your app's use cases, one Mermaid flow per use case

Built with Claude Code

by ross-cripto · Unclaimed · added Oct 29, 2026
no ratings0 comments

The living map of your app's use cases, in your terminal.

Every use case gets one Markdown file in docs/flows/ with a Mermaid flowchart of its steps. Your coding agent writes them and keeps them current as it changes the code; casemap checks them, renders them in the terminal and shows what each branch did to them. They are plain Mermaid, so GitHub renders the same files in the browser and in pull requests.

Quick start

Install the CLI, then run it from your repository root:

brew install Ross-cripto/tap/casemap

Run casemap in your repository. With no flows yet, it offers to have Claude Code or Codex write them, then opens the browser.

Without Homebrew, use the installer for your platform or build from source:

# macOS and Linux
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/Ross-cripto/casemap/releases/latest/download/casemap-installer.sh | sh
# Windows (PowerShell)
powershell -ExecutionPolicy Bypass -c "irm https://github.com/Ross-cripto/casemap/releases/latest/download/casemap-installer.ps1 | iex"
# From source (Rust 1.88 or newer)
cargo install --git https://github.com/Ross-cripto/casemap

Prebuilt binaries for macOS, Linux and Windows are attached to each release.

For manual setup, run casemap init.

Ask your coding agent: "document the use-case flows of this repo".

casemap browse         # see the use cases
casemap check          # validate the catalog
casemap diff main      # see what your branch changed

casemap init creates docs/flows/ with a .gitkeep and installs the casemap skill for Claude Code, Codex and other agents. It keeps existing flows and differing skills; use casemap init --force to update those skills.

A real casemap diff --no-color excerpt from the checkout fixtures, with the drawing omitted:

flow changes since HEAD (bbf0cdf): 1 modified, 1 new, 1 removed

Checkout (checkout.md)  modified: +1 step, -1 step, ~1 step, +3 links, -3 links, ~1 link
  + step fraud "Fraud check"
  ~ step confirm "Order confirmed" -> "Order confirmed and emailed"
  - step address "Enter address"
  + link cart -> pay
  + link pay -> fraud "yes"
  + link fraud -> confirm
  ~ link pay -> error "no" -> "declined"
  - link cart -> address
  - link address -> pay
  - link pay -> confirm "yes"

The base SHA depends on your repository.

Browse

casemap browse [--base REF] opens a full-screen catalog browser. The default base is HEAD; --base main compares against its merge base with HEAD. Use --flows DIR, --ascii, --no-color or --dir TD|BT|LR|RL as needed. NO_COLOR also selects a plain UI; --color has no effect here.

An excerpt of the 120×30 browse__wide fixture snapshot:

┌ Flows ───────────────────────┐Pay for an order
│✗ Bad flow                    │tests/fixtures/flows/browse/pay-for-an-order.md
│✗ Broken flow                 │A customer pays for an order and receives a receipt.
│~ Checkout                    │┌ Diagram ─────────────────────────────────────────────────────────────────────────────┐
│· Login                       ││    ╭───────────╮                                                                     │
│! Pay for an order            ││    │ Customer  │                                                                     │
│+ Refund                      ││    ╰─────┬─────╯                                                                     │
│· Wide flow                   ││          │                                                                           │
│- Legacy export               ││          ▼                                                                           │
Key List focus Diagram focus
↑/↓, k/j Select a flow Pan one row
←/→, h/l Pan one column
H/J/K/L Pan ten columns/rows
PgUp/PgDn Select by page Pan by visible height
Home First flow Reset pan
Tab Focus diagram; open it on narrow terminals Focus list
Enter Open diagram on narrow terminals
/ Search title or name Search title or name
d Toggle diff against the base Same
p Toggle problems, code anchors and diff details Same
r Reload flows, checks and anchored code Same
? Help Help
q, Ctrl-C Quit Quit
Esc Close help → finish search → clear kept filter → narrow list → quit Same

Search accepts printable characters, including command letters. ↑/↓ still select; Backspace deletes; Enter keeps the filter, or clears an empty query. Ctrl-C quits even while searching. Changed flow files reload automatically; edits to anchored code outside the catalog refresh on r. When git is unavailable or HEAD has no commit, the status says no git and diff mode is disabled.

Markers, in priority order: ✗ (x in ASCII) means a parse/check error, ! possibly stale, ~ modified, + new, - removed, and · (. in ASCII) unchanged. Removed flows appear last. Diagrams pan without wrapping. Below 80 columns, Tab switches between the list and diagram views.

Bare casemap opens the browser only when stdin and stdout are terminals, CI is unset, TERM is not dumb, the catalog (--flows or docs/flows) has flows, and neither FILE nor --watch is supplied. With no flows it offers setup; outside an interactive session it reads stdin as before. Explicit casemap browse requires terminal stdout. Build with --no-default-features --features cli for the CLI without the browser; library embedders can use default-features = false.

What a flow looks like

docs/flows/check-out-a-cart.md:

# Check out a cart

A customer pays for the items in the cart and gets an order confirmation.

```mermaid
flowchart TD
    cart([Customer opens the cart]) --> pay[Enter payment details]
    pay --> ok{Payment accepted?}
    ok -->|yes| confirm[Show the order confirmation]
    ok -->|no| error[Show the payment error]
    error --> pay
```
  • One use case per top-level Markdown file, named in kebab-case, with a title, a one-sentence description and one Mermaid flowchart.
  • Start from the actor or trigger as a stadium ([...]). Use rectangles for steps and diamonds for decisions, with every exit labelled.
  • Keep it to 3 to 15 steps, using the user's words and behaviour verified in code.
  • Keep node ids stable: change labels to rename steps. Keep file paths stable, because renaming a file reads as removing one flow and adding another.
  • Describe the current behaviour. Casemap computes changes from git.

Keep flows true: anchors

Tie steps to the code that implements them with Mermaid comments inside the flow's first Mermaid block, usually at the end before the closing fence:

%% @code pay src/checkout/payment.ts
%% @code confirm src/checkout/confirmation.ts tests/confirmation.ts
%% @code * src/checkout

A target is a node id, or * for the whole flow. Several patterns on one line and repeated lines for the same target add up. casemap flows NAME shows them in a Code footer. Mermaid and GitHub ignore the comments; rendering is unchanged. Anchors in prose or any other block are errors.

Paths are relative to the repository root and always match from that root:

  • A literal file matches itself; a literal folder matches everything under it.
  • * matches within one path segment and ? matches one character in a segment.
  • ** as a whole segment matches zero or more folders: src/**/pay.rs also matches src/pay.rs. In src/**.rs, the stars behave like *.rs.
  • Every other character is literal, including brackets and braces: app/[id]/page.tsx matches that exact framework path.
  • A leading ./ and trailing / are removed; repeated / separators collapse. Absolute paths, drive prefixes, . or .. segments, and backslashes are rejected.
  • Patterns are separated by whitespace, so anchor paths cannot contain spaces.

casemap check reports anchor-syntax, anchor-unknown-step, and anchor-no-match as errors. It indexes tracked and untracked files through git, excluding ignored files and files deleted from disk. Outside git, or without the git binary, it walks the current directory without following directory symlinks. Update anchors when code moves or is renamed.

casemap diff compares anchored paths with code changed since the merge base, including deleted files, both sides of a rename, and non-ignored untracked files. It appends an advisory section when a flow file was untouched:

possibly stale: 1 flow whose anchored code changed but the flow did not
  Pay for an order (pay.md)
    pay: src/checkout/payment.ts

A flow is touched when any byte in its file changed between the base and the working tree. A touched flow is never reported stale, even when only its prose or anchors changed. Review stale flows: update them when behaviour changed; if they still hold, report that instead of making a cosmetic edit to silence the warning.

casemap diff --strict also exits 1 for possibly stale flows. Use it for local agent runs or teams that require acknowledgement of every anchored change. casemap check --strict remains the recommended CI gate. Running diff --strict in CI requires actions/checkout with fetch-depth: 0 so git can find the merge base.

Run casemap which src/checkout/payment.ts before editing to find anchored flows and steps. It only knows anchored flows. Arguments are literal paths relative to the current directory, or absolute paths; directories expand to indexed files, and deleted paths still match anchors. Paths outside the repository are rejected. Pass several paths for separate result blocks, or --format json for JSON v1:

{"version":1,"paths":[{"path":"src/pay.rs","flows":[{"name":"pay","path":"docs/flows/pay.md","title":"Pay for an order","steps":["pay"],"whole_flow":false}]}]}

Coverage

casemap coverage shows which code files have at least one known @code anchor, with totals by directory and the uncovered file names:

code anchored to flows: 50% (2 of 4 files)

  src/auth/   50%   2/4   not covered: mfa.ts, reset.ts

Run casemap coverage main to list changed code files no flow covers since the merge base with main, including uncommitted and untracked changes. Add --strict to exit 1 when that list is non-empty. Repository mode has no gate. Both modes support --format json (version 1).

Coverage counts files, not lines or symbols. A file is covered when it matches an anchor to an existing step or a whole-flow (*) anchor, just as casemap which does. With no known anchors, both modes explain how to start measuring and exit 0, even with --strict.

By default code extensions are rs, ts, tsx, js, jsx, mjs, cjs, py, go, rb, java, kt, kts, swift, cs, php, ex, exs, scala, c, h, cc, cpp, hpp, m, mm, dart, lua, vue, svelte, elm, clj, fs, erl, hs, ml, zig and sh. Paths under test, tests, __tests__, spec, specs, migrations, vendor, node_modules, target, dist, build, .github or .git are excluded, as are test names *_test.*, *.test.*, *.spec.*, test_*.py and *_spec.rb, config names *.config.*, and TypeScript declarations *.d.ts. Extensions and excluded folder names are matched case-insensitively. Test files named like *Tests.swift or *Test.java outside test folders count as code; use --exclude to remove them. Dotfile folders other than .github and .git count as code by default. A module such as src/config.ts also counts; its name does not match *.config.*.

Repeat --include PATTERN to replace those defaults with your own selection; repeat --exclude PATTERN to remove files. Patterns use the same repository-root syntax as anchors. Excludes always win, and catalog files are always excluded. For example: casemap coverage --include src --exclude src/generated.

On pull requests

Run casemap init --ci to install the agent skill and add .github/workflows/casemap.yml, or add the workflow yourself:

name: casemap

on:
  pull_request:

permissions:
  contents: read
  pull-requests: write

jobs:
  flows:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - uses: Ross-cripto/casemap@v0
        with:
          flows: docs/flows

The Action keeps one comment updated on each pull request, with coloured Mermaid flow changes, possibly stale flows, changed code no flow covers and the check result. It also writes the report to the job summary. Fork PRs with read-only tokens fall back to that summary with a notice. When flows have @code anchors, a pull request that changes code no flow covers gets a comment even if no flow changed. Linux and macOS runners are supported. Checkout must use fetch-depth: 0 so the base revision and its merge base are available.

Only check errors, including broken diagrams, fail the flow review job. Warnings and possibly stale flows are advisory. For local runs, casemap diff main --format markdown prints the same report; adding --strict also fails on possibly stale flows.

A modified flow with an added review step looks like this in the comment:

🗺️ casemap · 1 use case changed · 0 possibly stale · check ok

Compared with main (abc1234).

~ Check out a cart · docs/flows/check-out-a-cart.md

+1 step, +2 links, -1 link

flowchart TD
    n0(["Customer opens the cart"])
    n1["Review the order"]
    n2["Enter payment details"]
    n0 --> n1
    n1 --> n2
    n0 --> n2
classDef added fill:#dcfce7,stroke:#16a34a,color:#14532d
classDef removed fill:#fee2e2,stroke:#dc2626,color:#7f1d1d,stroke-dasharray:4 3
class n1 added
linkStyle 0,1 stroke:#16a34a,stroke-width:2px
linkStyle 2 stroke:#dc2626,stroke-width:2px,stroke-dasharray:4 3
Changes
    • step review "Review the order"
    • link cart -> review
    • link review -> pay
    • link cart -> pay

Check

ok

The Action accepts these inputs:

Input Default Purpose
version latest Release version to install, without v, such as 0.5.1
casemap empty Path to an existing binary; skips installation
flows docs/flows Flow catalog directory
base origin/${{ github.base_ref }} Revision to compare with (using its merge base with HEAD)
comment true Set to false to write only the job summary
bot-login github-actions[bot] Login that owns comments posted with an app token or PAT
token ${{ github.token }} Token for reading and updating the PR comment

The moving v0 Action tag follows releases. A quiet first report creates no comment; an existing comment is updated even when the PR becomes quiet. init --ci keeps a differing workflow unless you pass --force.

For agents

The casemap skill teaches how to identify use cases, group entry points into user journeys, write the format above, and maintain affected flows in the same change as the code. It also teaches how to check the files and report what changed, including open questions about behaviour that was not verified.

casemap init installs the skill at the repository root in .claude/skills/casemap/SKILL.md for Claude Code and .agents/skills/casemap/SKILL.md for Codex and other agents. From a subdirectory, it still installs skills at the root while creating the catalog relative to the current directory. The installed skill records that catalog's path relative to the root. Run casemap from the root when following the skill.

To install only the skill through the skills CLI:

npx skills add Ross-cripto/casemap

Both installers use the source at skills/casemap/SKILL.md. casemap init prints a reminder when git ignores an installed skill, so you can make it available to teammates. It follows symlinked skill directories, including those created by the skills CLI.

For agents to keep flows current on every task, add this line to AGENTS.md and CLAUDE.md (init prints it, and leaves those files for you to edit):

Use-case flows live in docs/flows/ (casemap skill): update them when behaviour changes and run `casemap check`.

For agents without skill support, casemap guide prints the skill body. casemap guide --flows flows renders its paths for a custom catalog.

Agent hooks

casemap hook stop checks uncommitted changes against HEAD when a coding agent is about to finish. It reports catalog check errors, possibly stale flows whose anchored code changed, and changed code no flow covers (when the catalog has known anchors). It blocks once per new set of warnings, remembering them per session in the git directory. The agent can update flows, anchor code, or explain why the flow still holds or no flow applies. The same warnings do not stop it twice; a clean state clears the memory. Internal errors silently let the agent finish. If writing the warning memory fails, the hook still blocks and may repeat the warnings on the next stop.

Install the Stop hook for both Claude Code and Codex:

casemap init --hooks

This merges the hook into .claude/settings.json and .codex/hooks.json, preserving existing settings and hooks. Adding the entry rewrites the JSON with 2-space indentation and sorted keys. An existing casemap Stop command leaves the file untouched; use --force to replace that command, for example after changing --flows. Custom catalog paths are quoted only when needed; quoted paths assume a POSIX shell. Codex asks you to trust project hooks once: run /hooks in Codex.

For manual setup, merge this JSON into each of .claude/settings.json (Claude Code) and .codex/hooks.json (Codex):

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          { "type": "command", "command": "casemap hook stop", "timeout": 30 }
        ]
      }
    ]
  }
}

For a custom catalog, use casemap init --hooks --flows docs/use-cases, or set the command to casemap hook stop --flows 'docs/use-cases' manually.

You can also validate flows with the pre-commit framework. Install casemap on PATH and add this to .pre-commit-config.yaml (pin rev to a release or commit containing the hook definition):

repos:
  - repo: https://github.com/Ross-cripto/casemap
    rev: main
    hooks:
      - id: casemap-check

Commands

Command Result
casemap init [--ci] [--force] [--agent claude|codex] Create the catalog and install the agent skill; --ci adds the PR workflow; --force updates differing skills and the requested workflow; --agent opens that agent in a terminal
casemap init --hooks Install the skill and merge Stop hooks for Claude Code and Codex
casemap hook stop Check uncommitted changes for agents; block once per new warning set
casemap browse [--base REF] Explore the catalog interactively (for humans; agents use the other commands)
casemap flows [NAME] List the catalog, or render one use case
casemap flows --format json List catalog metadata as JSON v1; cannot be combined with NAME
casemap check [--strict] [--format text|json] Validate the catalog; --strict also fails on warnings
casemap diff [REF] [--strict] [--format text|markdown] Compare with the merge base of REF and HEAD; --format markdown writes the PR comment and also fails on check errors (unlike text mode); --strict also exits 1 for possibly stale flows
casemap coverage [REF] [--include P] [--exclude P] [--strict] [--format text|json] Code no flow covers, by directory or changed since REF; --strict fails only in branch mode
casemap which <file>... [--format text|json] Show flows and steps anchored to files or directories
casemap guide Print the agent skill body
casemap FILE

Description taken from the repository README.

Ratings

–
0 ratings
5 0
4 0
3 0
2 0
1 0

Rate this app

Sign in to rate

Comments 0

Sign in to comment

No comments yet.

Related apps

#use-cases · #mermaid · #documentation