Writes and runs tests for NEAR smart contracts with near-contract-sim, an in-process simulator that runs nearcore's runtime inside cargo test. Covers everyday call-and-assert tests that replace near-sdk unit tests (testing_env!) and near-workspaces sandbox tests, cross-contract calls, callbacks and refunds, who paid whom per call, the clock, epochs and yields, stub contracts, injected faults and late receipts, gas, and audit harnesses that scan faults and edges, measure resources as inputs grow, and search overlapping calls, with shrunk, replayable findings. Use when the user asks to write, add or improve tests for a NEAR contract (a near-sdk crate or a wasm), to port testing_env! or near-workspaces tests, to test callbacks, yields or cross-contract flows, to check gas margins, to property-test or fuzz a contract, to check token or accounting invariants, to audit or hunt for bugs in a contract or deployed wasm, or mentions near-contract-sim, near-workspaces or sandbox tests.
Ships in near-contract-sim. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
near-contract-sim runs a contract on nearcore's own runtime inside
#[test]: real signed transactions, every receipt, callback and refund,
a node's gas, and a clock the test sets. It replaces testing_env! unit
tests and near-workspaces sandbox tests.
.wasm or a .wat, see
sim.md, "A contract without source".testing_env! and near-workspaces idiom.| concept | what it is | page |
|---|---|---|
Sim, Fixture | the chain, setup built once, accounts, contract state, the toolchain and CI | references/sim.md |
| a contract without source | deploying a .wat or a prebuilt wasm, its exports, raw args and returns, asserting on storage | references/sim.md |
Tx | a signed transaction: calls, gas, keys, relayers, signed payloads, global contracts, a callback on picked results; external calls (NEP-667) | references/transactions.md |
TxOutcome, Effects | what a call did, receipt by receipt; logs, gas, who paid whom; the built-in findings | references/outcomes-and-effects.md |
Fault, Receipts | a callee that fails, a callback short of gas, a late receipt | references/faults.md |
Stub | a contract that answers as the test says; the calls an account got | references/stubs.md |
| blocks and the clock | many calls in one block, settle, advance_to, yields, epochs | references/blocks-and-clock.md |
Also: references/mpc.md (yield-based contracts), references/fidelity.md (what matches a node), references/near-kit.md (near-kit client code).
Rules:
use near_contract_sim::prelude::* names the everyday types. Import
Token on its own. An audit harness uses explore::prelude::*.transact() doesn't panic on a failed call: assert on its outcome,
and put "{out}" in assert messages for the receipt tree. An
assert's panic opens with the first receipt that failed; the tree and
gas table are cut to about 100 lines, and {out:#} prints all of it.U128 is a JSON string: send n.to_string(), and read a
view's or a call's with .u128().sim.findings().assert_none(), or assert the findings
you expect..cargo/config.toml (quickstart), and keep
build parallelism modest.For an audit, you map the value flows and declare the books or
properties; the library tries faults, edges, growing inputs,
interleavings and gas, shrinks each finding and saves its replay. A
clean run is no proof. This layer, explore, is experimental.
Read in this order:
Books
(the checks they derive), plans and excuses.scan, curves,
search, Pick, replays, diff, and how to read the summary.Rules (the harness's own are in harness.md):
Unobserved isn't a pass. Watch every token a check reads.references/audit.md (opens in a new tab)references/blocks-and-clock.md (opens in a new tab)references/explore.md (opens in a new tab)references/faults.md (opens in a new tab)references/fidelity.md (opens in a new tab)references/harness.md (opens in a new tab)references/migrating.md (opens in a new tab)references/mpc.md (opens in a new tab)references/near-kit.md (opens in a new tab)references/outcomes-and-effects.md (opens in a new tab)references/quickstart.md (opens in a new tab)references/sim.md (opens in a new tab)references/stubs.md (opens in a new tab)references/transactions.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/near-contract-sim:near-contract-simfrom near-contract-sim
npx claudepluginhub near/near-contract-sim --plugin near-contract-sim