From compact-core
This skill should be used when a user needs help debugging Compact smart contract errors, including compiler failures ("parse error", "unbound identifier"), proof generation issues, TypeScript witness type mismatches, disclosure errors ("potential witness-value disclosure must be declared"), or compatibility problems between Midnight components. Also applies when a user says their contract "won't compile", "worked before but broke after update", or when consecutive fix attempts keep revealing new errors. This skill orchestrates the debugging process and routes to domain-specific compact-core skills.
How this skill is triggered — by the user, by Claude, or both
Slash command
/compact-core:compact-debuggingThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Core principle: **NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.**
Core principle: NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.
Debugging flow: Don't guess → Hypothesize → Instrument → Reproduce → Analyze → Fix → Verify.
This skill is process orchestration — it routes to existing compact-core skills for domain knowledge and does NOT duplicate their content.
First determine: "Is this a code bug or a compatibility issue?"
Code bug indicators:
Compatibility issue indicators:
If compatibility: fetch live support matrix from midnightntwrk/midnight-docs (docs/relnotes/support-matrix.mdx), compare against installed versions. Recommend /midnight-tooling:doctor for automated diagnostics.
| Functional Area | Components |
|---|---|
| Network | Node |
| Runtime & Contracts | Compact Compiler, Compact Runtime, Compact JS, On-chain Runtime, Ledger |
| SDKs & APIs | Wallet SDK, Midnight.js, DApp Connector API |
| Indexing & Data | Midnight Indexer |
| ZK & Proving | Proof Server |
If code bug: proceed to triage table.
Before any investigation, run /midnight-verify:verify on the contract:
/midnight-verify:verify <file.compact>
If the issue involves witnesses:
/midnight-verify:verify <contract.compact> <witnesses.ts>
The verification result immediately narrows the problem space:
If /midnight-verify:verify identifies the issue directly, present the finding — no further investigation may be needed.
| Symptom | Route To Skill | Investigation Phase |
|---|---|---|
parse error: found... | compact-language-ref (troubleshooting) | Root Cause |
unbound identifier | compact-language-ref + compact-standard-library (hallucination traps) | Root Cause |
potential witness-value disclosure | compact-privacy-disclosure (debugging-disclosure) | Root Cause |
implicit disclosure of witness value | compact-privacy-disclosure (debugging-disclosure) | Root Cause |
incompatible combination of types | compact-language-ref (types-and-values) | Root Cause |
cannot cast from type | compact-language-ref (types-and-values) | Root Cause |
cannot prove assertion | compact-language-ref (troubleshooting, runtime section) | Hypothesis |
operation undefined for type | compact-ledger (types-and-operations) | Root Cause |
| TypeScript type mismatch | compact-witness-ts (type-mappings) | Root Cause |
| Witness returns unexpected value | compact-witness-ts (witness-implementation) | Hypothesis |
| Token mint/transfer fails | compact-tokens (token-operations) | Pattern Analysis |
| MerkleTree proof fails | compact-privacy-disclosure + compact-standard-library | Hypothesis |
| "Works locally, fails on devnet" | compact-witness-ts (contract-runtime) | Pattern Analysis |
| Contract deploys but can't query state | Compatibility check (Indexer ↔ Ledger) | Compatibility |
| Proof generation hangs or fails | Compatibility check (Proof Server ↔ Compiler) | Compatibility |
| Wallet can't sign transactions | Compatibility check (Wallet SDK ↔ DApp Connector ↔ Midnight.js) | Compatibility |
| SDK bindings don't match generated types | Compatibility check (Compact JS ↔ Compiler) | Compatibility |
| Node rejects transaction | Compatibility check (Node ↔ On-chain Runtime) | Compatibility |
import not found / module not found | compact-language-ref (modules-and-imports) | Root Cause |
Adding disclose() keeps causing new errors | compact-privacy-disclosure (step 5: restructure) | Pattern Analysis |
| Constructor errors or missing initialization | compact-structure (patterns) + compact-ledger (state-design) | Root Cause |
| Enum variant access errors | compact-language-ref (troubleshooting) | Root Cause |
Entered based on triage result, not enforced sequentially.
skipZk=truedisclose() additions: "What can an on-chain observer learn from this value?"Track every fix attempt internally using this format:
Fix #1: [category] [what was tried] [result: resolved | new error | same error]
Fix #2: ...
Escalation triggers:
Surface a warning (non-blocking) when detecting:
| Pattern | Warning |
|---|---|
| Fix applied without stated hypothesis | "What's our hypothesis for why this will work?" |
| Same error category failed 3+ times | "We've tried this approach multiple times. Let's reconsider." |
| Fix in area A causes new error in area B | "This fix introduced a new issue elsewhere. Possible architectural concern." |
| Rapid successive fix attempts | "Let's slow down and verify our understanding before the next attempt." |
Stop immediately if the reasoning pattern matches any of the following.
If any of these apply: Stop. Return to Phase 1 (Root Cause Investigation) before attempting any fix.
Consecutive fixes revealing new problems in different areas indicates architectural issues: stop patching, document findings, discuss with team, consider design rethink.
After every fix:
skipZk=true. If unavailable, advise manual compilation.disclose() added, trace value to source and document what becomes public.Skills (loaded on demand via triage routing):
compact-language-ref — compiler errors, syntax, types, troubleshootingcompact-privacy-disclosure — disclosure errors, privacy patterns, debugging processcompact-structure — contract anatomy, common mistakescompact-standard-library — stdlib verification, hallucination trapscompact-witness-ts — TypeScript witnesses, type mappings, contract runtimecompact-ledger — state design, ADT operationscompact-tokens — token operations, mint/transfer patternsCross-plugin references:
/midnight-tooling:doctor — automated version diagnostics, environment healthmidnightntwrk/midnight-docs → docs/relnotes/support-matrix.mdxThis skill is purely process orchestration + triage routing + fix tracking.
npx claudepluginhub devrelaicom/midnight-expert --plugin compact-coreDebugs issues in GRACE-structured projects via semantic navigation of knowledge graphs, verification plans, and blocks to analyze mismatches and apply targeted fixes.
Guides four-phase root cause investigation for bugs, test failures, unexpected behavior, and deep-stack issues in multi-component systems before proposing fixes.
Methodical 4-phase debugging process for resolving errors, test failures, and unexpected behavior systematically.