From cardano-dev-skills
Guides writing Cardano smart contracts (validators, minting policies, staking scripts) from specification through secure implementation with datum/redeemer design, security checks, and test planning. Default language is Aiken.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cardano-dev-skills:write-validatorThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
<!-- Documentation lookup path: ${CLAUDE_SKILL_DIR}/../../docs/sources/ -->
Guide the development of a Cardano smart contract from specification to implementation, with security built in from the start.
The datum represents the state stored at the script address.
Questions to answer:
See references/datum-redeemer-design.md for detailed guidance, and the eUTxO
Design Decisions section of references/aiken-patterns.md for how to choose between
parameter, datum, and redeemer — the central design axis.
Search the bundled documentation for relevant content:
${CLAUDE_SKILL_DIR}/../../docs/sources/aiken/ - Aiken language docs${CLAUDE_SKILL_DIR}/../../docs/sources/aiken-stdlib/ - Aiken standard library docs${CLAUDE_SKILL_DIR}/../../docs/sources/aiken-examples/ - Aiken example projects${CLAUDE_SKILL_DIR}/../../docs/sources/aiken-design-patterns/ - Aiken design patterns${CLAUDE_SKILL_DIR}/../../docs/sources/plutus/ - Plutus docsThe redeemer represents the action the user wants to perform.
type Redeemer { Action1 | Action2 { field: Type } }For each redeemer variant, define:
Structure the validator clearly:
validator my_validator(params: Params) {
spend(
datum: Option<Datum>,
redeemer: Redeemer,
own_ref: OutputReference,
tx: Transaction,
) {
expect Some(datum) = datum
when redeemer is {
Action1 -> handle_action1(datum, tx)
Action2 { field } -> handle_action2(datum, field, tx)
}
}
}
For each action handler:
See references/aiken-patterns.md for worked patterns (vesting, marketplace,
multisig, one-shot minting, withdraw-zero, state machine) and
references/advanced-patterns.md for when a straightforward validator won't fit
(UTxO indexers, merkelized validators, linked lists).
Before considering the validator complete, verify each item:
extra_signatoriesFor each redeemer action, document the transaction shape:
This becomes the specification for the off-chain transaction building code.
Define tests for each redeemer action:
Positive tests (should succeed):
Negative tests (should fail):
Use Aiken's built-in test framework. Call the validator handler directly with a
constructed transaction (transaction.placeholder + record-update overrides), and
use the boolean-toggle methodology: one success test with all conditions valid,
then one test ... fail per validation condition, each flipping exactly one
condition — so every guard is individually proven to guard. See
references/testing-validators.md for the full manual-vs-mocktail guidance, the
mocktail builder API, and the include: Bool pass/fail-matrix idiom.
fn tx_with(signers, range) -> Transaction {
Transaction { ..transaction.placeholder, extra_signatories: signers, validity_range: range }
}
test claim_succeeds() {
vesting.spend(Some(datum), Claim, oref, tx_with([beneficiary], interval.entirely_after(deadline)))
}
test claim_before_deadline_fails() fail {
vesting.spend(Some(datum), Claim, oref, tx_with([beneficiary], interval.entirely_before(deadline)))
}
Plutus/Haskell notes:
plutus-simple-model or cardano-testnet for testingPlutusTx.compile for on-chain compilationPlutusTx.unstableMakeIsDataOpShin notes:
build() function from opshin.builder (e.g., from opshin.builder import build; contract = build("path/to/contract.py"))opshin eval for local testingreferences/aiken-patterns.md -- Validator patterns with code structure, plus eUTxO design decisionsreferences/advanced-patterns.md -- Advanced/scaling patterns (UTxO indexers, merkelized validators, linked lists)references/datum-redeemer-design.md -- Designing datums and redeemersreferences/testing-validators.md -- How to test validators (manual placeholder vs mocktail)${CLAUDE_SKILL_DIR}/../../docs/sources/ for existing protocol specifications and design documentsnpx claudepluginhub cardano-foundation/cardano-dev-skills --plugin cardano-dev-skillsExplains Cardano's extended UTxO model to developers, covering datums, redeemers, validators, script contexts, and how eUTxO differs from account-based chains like Ethereum.
Builds production-grade Web3 apps, smart contracts, and decentralized systems across Ethereum, Solana, Cosmos, and other ecosystems. Covers DeFi, NFTs, DAOs, security auditing, and Layer 2 solutions.