Midnight Compact Agent Skill – Compiler-Validated Reference for AI-Assisted Development
What it is
An open-source Agent Skill that teaches AI coding assistants how to write Compact smart contracts for Midnight. It works with Claude Code, Cursor, Gemini CLI, VS Code Copilot, and any tool that supports the Agent Skill format (30+ and growing).
Instead of relying on an LLM’s training data – which is sparse for a new language like Compact – the skill provides structured reference material and validated examples that the assistant consults in real time. The result is generated code that actually compiles.
What’s included
8 reference documents:
- Language reference (types, syntax, modules, casting, operators)
- Privacy model (shielded vs unshielded state, disclose(), witness pattern, ZK fundamentals)
- Security patterns (10 ZK-specific attack categories with mitigations)
- Testing guide (simulator, invariant testing, adversarial testing, CI/CD)
- Design patterns (circuit optimization, off-chain computation, module composition)
- Standard library reference
- Gotchas (52+ issues from Discord and real compilation)
- Off-chain SDK integration (TypeScript SDK, wallet, deployment, error handling)
29 worked examples across four categories:
- Core: Counter, Bulletin Board, Fungible Token, NFT, Rock-Paper-Scissors
- Privacy: Shielded Voting, Sealed-Bid Auction, Identity Proof, Credential Registry, Prescription, Privacy Mixer
- DeFi/Escrow: Escrow, Time Lock, Multi-Sig, Staking, Crowdfunding, Lending, Prediction Market, Vesting, Revenue Sharing, Lottery
- Advanced: Oracle Feed, Token Swap, Access Control, DID Registry, Micro-DAO, Contract Upgradability, Token Minting, Supply Chain
How it was validated
Every example was compiled against Compact 0.29.0. 27 of 29 examples are compiler-validated with simulator tests (the remaining 2 use Zswap coin operations that require the full network stack). 145 circuits compiled, 182/182 tests passing. 13 contracts were deployed on Midnight preprod (protocol v21000) with ZK proofs generated and verified on-chain.
The gotchas document contains 52+ issues discovered through Discord conversations and compilation, covering compiler behavior, SDK pitfalls, proof server issues, and design traps that are not yet in the official documentation.
Installation
Project-level (recommended):
mkdir -p .claude/skills
git clone GitHub - ADAvault/midnight-skill: Claude Code skill for writing and testing Compact smart contracts on Midnight · GitHub .claude/skills/midnight-compact
Personal (all projects):
git clone GitHub - ADAvault/midnight-skill: Claude Code skill for writing and testing Compact smart contracts on Midnight · GitHub ~/.claude/skills/midnight-compact
The skill auto-activates when you mention Midnight, Compact, circuit, witness, ledger, disclose, or related keywords.
Feedback
This is MIT licensed and built by ADAvault. If you find issues, have corrections, or know of gotchas we missed, contributions are welcome. The goal is a community-maintained reference that keeps pace with the compiler.