Development

Teaching AI to Write Smart Contracts: Open-Source Agent Skills for Cardano and Midnight

14 March 2026
Cardano Midnight Aiken Compact AI Agent Skills Smart Contracts Claude Code Open Source

AI coding assistants are good at general-purpose programming. But ask one to write a Cardano validator in Aiken or a Midnight contract in Compact, and you’ll hit the limits fast. The training data is thin, the hallucinations are confident, and the code doesn’t compile.

We built two open-source agent skills to fix that.

The Problem

Both Aiken and Compact are relatively new. LLM training data for both is sparse compared to Solidity or Rust, and what exists is often outdated. AI assistants invent types that don’t exist, miss critical security patterns, and generate plausible code that fails to compile. For Midnight they miss privacy requirements entirely. For Cardano they miss eUTxO-specific patterns like double satisfaction prevention.

Community knowledge is scattered across Discord threads, GitHub issues, and evolving docs.

What We Built

Two open-source agent skills following the Agent Skills open standard — compatible with Claude Code, Cursor, Gemini CLI, VS Code Copilot, and 30+ other tools:

cardano-skill — 10 reference docs, 27 example validators across 8 difficulty phases, 11 security categories, 5-phase audit methodology, 249 unit tests, and 61 E2E operations on Cardano preview testnet. Covers all 6 Aiken handler types from hello-world through CIP-113 programmable tokens.

midnight-skill — 9 reference docs, 29 example contracts, 151 compiled circuits, 182 passing tests, 30 preprod deployments with DUST fee data, and 57 documented gotchas. Covers the privacy model, ZK proofs, witness security, and 6 privacy-specific patterns.

Install a skill, and your AI assistant stops hallucinating — it has real, validated reference material to draw from.

Compiler-Validated, Not Just Documented

Every example is compiler-validated. For Cardano, all 27 validators compile against Aiken v1.1.21 with 249 passing tests. Two companion projects — cardano-notary and programmable-tokens — run 61 end-to-end operations on preview testnet. Real transactions, real on-chain state.

For Midnight, all 29 examples compiled against Compact 0.29.0 with 182 passing tests. We deployed 30 contracts to preprod, documenting real DUST fees (331B–721B per deployment) and confirming ZK proofs verified on-chain.

Compilation uncovered undocumented behaviours on both chains — tx.inputs being sorted lexicographically on Cardano, Uint<N> + literal type widening on Midnight, Conway-era stake registration being permissionless — all captured in the gotchas lists.

The Gotchas Lists

Perhaps the most valuable part. The issues that block developers for hours and aren’t in the official docs yet.

Cardano (gotchas.md): 20+ learnings covering Aiken’s type system, values/assets handling, governance, and compiler behaviour, plus extensive MeshJS off-chain gotchas from E2E testing.

Midnight (gotchas.md): 57 issues sourced from Discord dev-chat (Feb 2024 – Mar 2026) and real compilation — compiler behaviour, SDK pitfalls, proof server issues, and design traps.

Security

Both skills include systematic security references. Cardano covers 11 attack categories (double satisfaction, datum hijacking, reference input manipulation, and more) with a 5-phase audit methodology. Midnight covers 10 ZK-specific categories including witness forgery, disclosure over-exposure, and privacy leaks through timing or transaction patterns.

How to Use Them

# Cardano (Aiken)
git clone https://github.com/ADAvault/cardano-skill.git .claude/skills/aiken-smart-contract

# Midnight (Compact)
git clone https://github.com/ADAvault/midnight-skill.git .claude/skills/midnight-compact

Both skills auto-activate on relevant keywords. Both repos are MIT licensed. Community contributions welcome — new patterns, security findings, gotcha reports.

The repos: