agentleFS
MetalLegBobMetalLegBob/solana-vibes-kit/book-of-knowledge/SKILL.md

BOK

Skill19 starsChanged 9 months agoMITView on GitHub

Book of Knowledge: Math verification and economic invariant proving for Solana/Anchor programs. Uses Kani (formal proof), LiteSVM (runtime tests), and Proptest (property-based testing). Run /BOK for a getting-started guide, or /BOK:scan to begin.

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 6 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Look for .claude/svk-meta.json in the current project.

    line 20
  2. Very specific:

    Read the svk_repo path and installed_version from the metadata file.

    line 21
  3. Very specific:

    Run: git -C <svk_repo> tag --sort=-v:refname | head -1 to get the latest tag.

    line 23
  4. Distinctive:

    If they match, skip — the user is up to date.

    line 25
  5. Distinctive:

    If the latest tag is newer, show this message ONCE (never repeat in this session):

    line 26
  6. Distinctive:

    If the git commands fail (offline, repo moved, etc.), skip silently.

    line 32
  7. Distinctive:

    Important: Do NOT block or delay the user's actual command.

    line 34
  8. Very specific:

    All BOK artifacts are stored in .bok/ at the project root — the same directory that contains Cargo.toml or Anchor.toml.

    line 47
  9. Very specific:

    IMPORTANT: Never create BOK artifacts under .claude/.

    line 64
  10. Distinctive:

    If Kani is not installed and the user declines installation, BOK runs with LiteSVM + Proptest only.

    line 101
  11. Distinctive:

    All generated verification code lives in an isolated git worktree — your working tree is never touched.

    line 105

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- SVK Version Check — runs once per session on first skill invocation --><svk-version-check> **On first invocation this session**, silently perform a version check:
  1. Look for .claude/svk-meta.json in the current project. If it doesn't exist, skip this check entirely.
  2. Read the svk_repo path and installed_version from the metadata file.
  3. Run: git -C <svk_repo> fetch --tags --quiet 2>/dev/null
  4. Run: git -C <svk_repo> tag --sort=-v:refname | head -1 to get the latest tag.
  5. Compare the installed version against the latest tag (strip the leading v).
  6. If they match, skip — the user is up to date.
  7. If the latest tag is newer, show this message ONCE (never repeat in this session):

SVK Update Available: v{latest} is available (you're on v{installed}).

  • Update now: I can pull and reinstall the changed skills in this session
  • Update later: Start a new chat and run /SVK:update
  1. If the git commands fail (offline, repo moved, etc.), skip silently. Never show errors from version checking.

Important: Do NOT block or delay the user's actual command. Perform this check, show the notification if needed, then proceed with the command they invoked. </svk-version-check>

Book of Knowledge

Math verification and economic invariant proving for Solana/Anchor programs.

"Knowledge is the greatest weapon."


Artifact Convention

All BOK artifacts are stored in .bok/ at the project root — the same directory that contains Cargo.toml or Anchor.toml. This is NOT under .claude/.

<project-root>/
├── .bok/                  ← BOK artifacts go here
│   ├── STATE.json
│   ├── INDEX.md
│   ├── invariants/
│   ├── confirmed-invariants/
│   ├── worktree/
│   ├── results/
│   └── reports/
├── .claude/               ← Skill code lives here (NOT for artifacts)
├── Cargo.toml
└── programs/

IMPORTANT: Never create BOK artifacts under .claude/. The .claude/ directory contains skill definitions and commands — it is not an artifact output location.


What BOK Does

BOK systematically verifies that your program's arithmetic is correct and economic properties hold. It uses three verification tools in layers: Kani for formal proofs (checks ALL possible inputs), LiteSVM for runtime tests against the actual SVM, and Proptest for rapid property-based stress testing with thousands of random inputs. Every invariant comes with a plain-English explanation and concrete exploit scenario so you learn something from every run.

When to Use

  • Pre-deployment math review — Verify arithmetic before shipping
  • After SOS flags arithmetic issues — BOK can formally prove or refute SOS findings
  • New DeFi math — Swaps, fees, staking, LP, oracles, liquidations, bonding curves
  • Token economics verification — Prove conservation of value, share fairness, rate consistency

Pipeline Overview

CommandPhaseWhat It Does
/BOK:scan0Index codebase, identify math-heavy code, check Kani prerequisites
/BOK:analyze1Match against verification patterns, propose invariants with plain-language explanations
/BOK:confirm2Interactive gate — review, adjust, or add properties before generation
/BOK:generate3Create isolated worktree, generate Kani harnesses + LiteSVM tests + Proptest suites
/BOK:execute4Run all verification tools in the worktree, collect results
/BOK:report5Compile findings, suggest fixes, offer to merge tests back
/BOK:status—Check progress, get guidance on next step

Verification Tools

ToolWhat It DoesWhen BOK Uses It
KaniFormal proof — checks ALL possible inputsPure arithmetic: overflow, precision, rounding, division-by-zero
LiteSVMRuntime tests against actual SVMEconomic invariants involving multiple accounts/CPI
ProptestProperty-based testing — thousands of random inputsEverything — fast sanity layer that catches obvious failures

Graceful Degradation

If Kani is not installed and the user declines installation, BOK runs with LiteSVM + Proptest only. The report clearly flags that results are probabilistic (stress-tested), not formally proven, and recommends Kani for full assurance.

Worktree Workflow

All generated verification code lives in an isolated git worktree — your working tree is never touched. After execution, you choose: merge all tests, cherry-pick specific ones, or discard everything and keep only the report.

Cross-Skill Integration

  • Reads GL docs — Uses specs to understand intended behavior, making invariant proposals more accurate
  • Reads SOS findings — Prioritizes verification around areas SOS flagged as risky
  • SOS reads BOK reports — Skips re-analyzing formally verified math, focuses on non-math attack vectors

Getting Started

/BOK:scan       — Start here. Indexes your code and checks prerequisites.
/BOK:analyze    — Proposes invariants with explanations.
/BOK:confirm    — You review and approve before any code is generated.
/BOK:generate   — Creates verification code in an isolated worktree.
/BOK:execute    — Runs Kani, LiteSVM, and Proptest.
/BOK:report     — Compiles results, suggests fixes, offers test merge.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.