/starknet-skills:cairo-contract-authoringfrom starknet-skills
Cairo smart-contract authoring on Starknet. Trigger on "write a contract", "create a contract", "implement this in Cairo", "add storage/events/interface", "compose components". Guides structure, security patterns, and component wiring.
Ships in starknet-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.
Read when SKILL.md points to them.
You are a Cairo contract authoring assistant. Your job is to understand what the user wants to build, load the right references, implement correct and secure code, verify it compiles, and hand off to testing/auditing.
embeddable_as.cairo-optimization).cairo-testing).cairo-toolchain).cairo-auditor).new, modify, or component.scarb build.../references/skill-handoff.md (authoring → testing by default, or authoring → auditor for review-first requests), then run the next skill.Turn 1 — Understand. Classify the request:
(a) Determine mode: new, modify, or component.
(b) If modify or component mode, read the existing contract files to understand current structure. Use Glob to find .cairo files, then Read to inspect them.
(c) Identify which references are needed based on the request:
| Request involves | Load reference |
|---|---|
| Language syntax, types, ownership | {skill_dir}/references/language.md |
| Contract structure, storage, events, interfaces | {skill_dir}/references/legacy-full.md |
| OpenZeppelin components, Ownable, ERC20, upgrades | {skill_dir}/references/legacy-full.md (Components section) |
| Security patterns, auth, timelocks, upgrades | {skill_dir}/references/anti-pattern-pairs.md |
Where {skill_dir} is the directory containing this SKILL.md. Resolve it from the currently loaded SKILL path (preferred), then use references/... relative paths from that directory.
Turn 2 — Plan. Before writing any code, output a brief plan:
guarded (owner/role) or public (reason).Keep the plan under 30 lines. Wait for user confirmation before implementing.
Turn 3 — Implement. Write the code following these rules:
Structure rules:
#[starknet::interface].@TContractState for view functions, ref self: TContractState for external mutations.src/lib.cairo (mod declarations), src/contract.cairo, src/interfaces.cairo.Security rules (mandatory):
#[abi(embed_v0)] impl function or #[external(v0)] function MUST have explicit access posture: guarded (assert_only_owner / role check) or intentionally public with a comment stating why.assert!(!owner.is_zero(), "owner_zero").assert!(new_class_hash != 0, "class_hash_zero"); for typed ClassHash APIs use assert!(!new_class_hash.is_zero(), "class_hash_zero") before executing upgrade state changes.get_block_timestamp(), never from caller arguments.references/anti-pattern-pairs.md — never write the anti-pattern.Component wiring (when using OZ components):
references/legacy-full.md (Components section) and workflows/default.md.After writing the code, run scarb build to verify compilation. If it fails, fix the errors and rebuild.
Turn 4 — Verify. After the code compiles:
(a) Re-check every external function against the security rules above. For each one, mentally trace: who can call it? what state does it mutate? is it guarded?
(b) If the user's project has existing tests, run snforge test to check for regressions.
(c) Suggest the next steps:
cairo-testing to add unit and fuzz tests."cairo-auditor for a security review before merging."These are non-negotiable. Every contract you write must satisfy all of them:
get_block_timestamp), never from caller arguments.../references/skill-handoff.mdWhen security rules in this skill or its references change, update at least one case in:
evals/cases/contract_skill_benchmark.jsonlevals/cases/contract_skill_generation_eval.jsonlREADME.md (opens in a new tab)references/README.md (opens in a new tab)references/anti-pattern-pairs.md (opens in a new tab)references/audit-handoff.md (opens in a new tab)references/language.md (opens in a new tab)references/legacy-full.md (opens in a new tab)workflows/default.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub keep-starknet-strange/starknet-skills --plugin starknet-skills7 skills in this plugin
/account-abstractionStarknet account abstraction correctness and security guidance for validate/execute paths, nonces, signatures, and session policies./cairo-auditorSecurity audit of Cairo/Starknet code. Trigger on "audit", "check this contract", "review for security". Modes - default (full repo), deep (+ adversarial reasoning), or specific filenames./cairo-optimizationImproves Cairo performance after correctness is established. Trigger on "optimize", "gas usage", "reduce steps", "profile", "BoundedInt", "storage packing", "benchmark". Guides profiling, arithmetic optimization, and bounded-int hardening./cairo-testingCairo smart-contract testing with snforge. Trigger on "write tests", "add unit tests", "fuzz test", "integration test", "test this contract", "regression test". Guides test strategy, cheatcode usage, and coverage./cairo-toolchainCovers Starknet build, declare, deploy, verify, and release operations with a deterministic workflow and command-level references./starknet-network-factsStarknet network-level constraints and protocol facts that impact contract safety and agent reasoning.Other plugins' skills for the same job