/midnight-skills:testingfrom midnight-skills
Debug Compact contracts and manage toolchain versions. Covers static vs dynamic errors, reading compiler messages, the --skip-zk dev loop, version synchronization, and common traps.
Ships in midnight-skills. 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.
None: SKILL.md is the whole skill.
Scope
This skill covers the two error layers in Compact (static vs dynamic), how to read compiler messages (especially undeclared disclosure traces), the fast development loop with --skip-zk, version management across 6 components, and the most common debugging patterns. Official testing docs are "coming soon" — this is battle-tested from real development.
Related: decode an error with midnight-common-errors/, check versions with midnight-doctor/, and see what to test before a release in midnight-testing-checklist/.
Compact has two error types, not one:
Static errors — Caught by the compiler before generating any output. You see these in your terminal while developing. Static errors are your friend — the compiler tells you exactly what's wrong and where.
Dynamic errors — Caught at runtime by the generated JavaScript. You see these when a circuit executes. These are harder to debug because they happen inside generated code you didn't write.
| Error type | What it is | When caught |
|---|---|---|
| Syntax | Malformed code | Parser |
| Type mismatch | Wrong type used | Type checker |
| Undeclared disclosure | disclose() missing | Witness protection |
| Undefined reference | Unknown identifier | Name resolver |
| Generic not specialized | Generic entity used at top level | Scope checker |
| Recursive struct | Struct refers to itself | Declaration checker |
| Recursive circuit | Circuit calls itself | Declaration checker |
return in for | return inside loop | Statement checker |
| Sealed ledger write | Write to sealed field in circuit | Declaration checker |
If the compiler produces no output, there's at least one static error. Check the messages.
| Error type | What it is | Example |
|---|---|---|
| Type mismatch | Wrong argument type/number | Calling with wrong args |
| Overflow | Cast value too large for target | 1000 as Uint<8> |
| Underflow | Counter decremented below zero | counter -= 1 when at 0 |
| Uninitialized nested value | Nested ledger state not initialized | map.lookup(k).lookup(k2) before insert |
| Merkle tree full | Insert into full tree | tree.insert() when isFull() |
Dynamic errors are harder to debug. Read the error message for the line number in your source file.
/path/contract.compact line 12 char 5:
type error: expected Uint<64>, got Field
Read: line:character, expected type, got type. The caret (^) points to the problem token.
Exception: /path/contract.compact line 6 char 11:
potential witness-value disclosure must be declared but is not:
witness value potentially disclosed:
the return value of witness getBalance at line 2 char 1
nature of the disclosure:
ledger operation might disclose the witness value
via this path through the program:
the right-hand side of = at line 6 char 11
Read this bottom to top. The path traces how witness data traveled:
getBalance() at line 2Fix: Add disclose() somewhere along that path, as close to the disclosure point as possible.
disclose() on ReturnException: line 5 char 3:
potential witness-value disclosure must be declared but is not:
witness value potentially disclosed:
the return value of witness getBalance at line 2 char 1
nature of the disclosure:
the value returned from exported circuit check might disclose
the result of a comparison involving the witness value
Even a Boolean comparison result counts as disclosure. Wrap the witness call or the return value with disclose().
Error: Version mismatch: compiled code expects 0.21.0, runtime is 0.16.0
The contract was compiled by toolchain 0.36.x (which targets runtime 0.21.0), but the project still installs @midnight-ntwrk/[email protected]. This message was reproduced on 21 Nov 2026. Pin the runtime the toolchain expects, or compile with the matching toolchain (compact compile +0.36.1). See version management below.
--skip-zk Development LoopGenerating proving keys is slow. During iterative development, skip it:
compact compile --skip-zk contracts/contract.compact contracts/managed/contract
This produces contract/index.js and compiler/contract-info.json, enough to test logic. Re-enable for final builds.
Midnight has 6 components that must stay in sync. When they're not, you get opaque runtime errors about version mismatches.
The expected version of each one is in references/versions.json, the repo's single source of truth (toolchain for the CLI, compiler, language and Docker images; packages / nodePackages for npm).
| Component | What it is | How to check |
|---|---|---|
| CLI tool | compact binary (devtools) | compact --version |
| Compiler | toolchain / language | compact compile --version, compact compile --language-version |
| Runtime | @midnight-ntwrk/compact-runtime | npm list |
| Ledger | @midnightntwrk/ledger-v9 | npm list |
| JS libraries | @midnightntwrk/midnight-js-* | npm list |
| Proof server | midnightntwrk/proof-server Docker image | image tag |
Wallet SDK, indexer and node must also come from the same matrix row. ledger-v8, Midnight.js 4.x and Wallet SDK 1.x cannot transact on Ledger 9 networks.
compact --version
compact compile --version
compact compile --language-version
npm list @midnight-ntwrk/compact-runtime @midnightntwrk/ledger-v9
npm ls | grep -E "@midnight-?ntwrk/" # both scopes: a package in both is a duplicate-WASM bug
The official release compatibility matrix is the source of truth. Never mix versions without checking it.
package.json{
"dependencies": {
"@midnight-ntwrk/compact-runtime": "0.21.0",
"@midnightntwrk/ledger-v9": "1.0.2"
}
}
Do not use ^ or ~ — these allow automatic updates that silently break compatibility. Also pin the compiler in your build script ("compact": "compact compile +0.36.1 src/x.compact src/managed/x") so a newer default toolchain cannot silently outrun the runtime.
npm ci for Reproducible Installsrm -rf node_modules
npm ci
npm ci installs exactly what's in package-lock.json. npm install fetches the latest matching version.
disclose() on Ledger Write// wrong — compiler error
balance = getBalance();
// correct
balance = disclose(getBalance());
disclose() on Return Value// wrong — compiler error (comparison of witness data)
export circuit check(n: Uint<64>): Boolean {
return getSecret() > n;
}
// correct — declare the disclosure
export circuit check(n: Uint<64>): Boolean {
return disclose(getSecret()) > n;
}
return Inside for Loop// wrong — static error
circuit findFirst(v: Vector<4, Field>, target: Field): Boolean {
for (const x of v) {
if (x == target) return true;
}
return false;
}
// correct — use fold
circuit findFirst(v: Vector<4, Field>, target: Field): Boolean {
return fold((found, x) => found || x == target, false, v);
}
// wrong — static error: recursion not allowed
circuit factorial(n: Uint<64>): Uint<64> {
return n == 0 ? 1 : n * factorial(n - 1);
}
Rewrite using fold or explicit unrolling. Compact requires finite circuits.
const x: Uint<64> = 1000;
const y = x as Uint<8>; // dynamic error: 1000 doesn't fit
Always verify the value fits before casting. Use assert or bounded types.
ledger fld: Map<Boolean, Map<Field, Counter>>;
// wrong — dynamic error (inner map not initialized)
export circuit increment(b: Boolean, n: Field): [] {
fld.lookup(b).lookup(n) += 1;
}
// correct — initialize first
export circuit init(b: Boolean): [] {
fld.insert(disclose(b), default<Map<Field, Counter>>);
}
transientHash Result Used Without disclose()// wrong — compiler error (witness-tainted)
ledger h: Field;
export circuit store(v: Field): [] {
h = transientHash<Field>(v);
}
// correct — declare disclosure
h = disclose(transientHash<Field>(v));
// or use transientCommit (nonce provides hiding, no disclose needed)
h = transientCommit<Field>(v, nonce);
| Error | Cause | Fix |
|---|---|---|
compact: command not found | Binary not on PATH | export PATH="$HOME/.compact/bin:$PATH" |
ERR_UNSUPPORTED_DIR_IMPORT | Node.js tried to import directory | Open new terminal, clear caches |
| Docker connection errors | Docker Desktop not running | Start Docker Desktop |
| Port 6300 in use | Another container on same port | -p 6301:6300 |
Version mismatch: compiled code expects X, runtime is Y | Compiler and compact-runtime from different toolchains | Pin runtime 0.21.0 for toolchain 0.36.x, or compile with +<matching version> |
setNetworkId / midnight-js-network-id not found | Removed in Midnight.js 5 | Pass networkId via providers.config |
Indexer 410 ENDPOINT_DECOMMISSIONED | Old preprod/mainnet indexer host | Use Blockfrost endpoints (see references/volatile.md) |
Run this before filing a bug report:
#!/bin/bash
echo "=== Midnight Version Check ==="
echo "CLI:"; compact --version || echo "not found"
echo "Compiler:"; compact compile --version || echo "not found"
echo "Runtime:"
npm list --depth=0 | grep -E "@midnight-?ntwrk/" || echo "none found"
echo "Language:"; compact compile --language-version || echo "not found"
echo "Proof server images:"; docker images midnightntwrk/proof-server --format '{{.Tag}}' 2>/dev/null || echo "docker not running"
echo "Node.js:"; node --version
echo "Compare with: docs.midnight.network/relnotes/support-matrix"
If stuck after checking these notes:
#dev-chat — post your error message and version detailsAlways include:
.compact file (or relevant excerpt)--skip-zk during development. Enable for final builds.package.json. Use npm ci.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub kali-decoder/midnight-skills --plugin midnight-skills43 skills in this plugin
/1am-walletIntegrate the 1AM wallet for dust-free contract deployment and transaction flow on Midnight Network. Use this skill whenever a user is building a Midnight Network dApp, connecting to the 1AM browser extension, deploying or calling a Compact contract, handling ZK proving, setting up providers, or asking about dust-free transaction flow. Also use it for indexer patching, private state providers, payload encryption, or any question involving window.midnight['1am']./android-example-votingBuild a voting/poll dApp on Midnight Network using the Kuira Android SDK — Compact smart contract with create/cast/close circuits, passkey-derived identity, embedded wallet, Compose UI, reactive ledger reads via observeLedger(), and on-device ZK proving. Use when building a poll or voting dApp targeting Android./Other plugins' skills for the same job