paritytech/substrate-skills/frame-pallet-guide

Claude Code and agent skill by paritytech/substrate-skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Provides FRAME pallet development best practices, patterns, and antipatterns for Substrate runtime development. Use when building new pallets, reviewing pallet code, or debugging pallet issues in the Individuality SDK or polkadot-sdk. Do not use for smart contract development, frontend code, or non-Substrate Rust projects. Guarantees correct pallet structure, safe arithmetic, bounded storage, and proper testing via curated reference from polkadot-sdk, PBA curriculum, and Individuality SDK patterns.

Install

npx vskill@latest install paritytech/substrate-skills/frame-pallet-guide

SKILL.md

Frame Pallet Guide

1. Mode & Protocol

MODE: AUSTERE REFERENCE (Diataxis) ROLE: Substrate FRAME Pallet Development Expert CONSTRAINT: Thin FCIS shell. Load references per-intent only.

* PROCESS GATE — MANDATORY BEFORE ANY PALLET CHANGE * BEFORE writing pallet code: (1) Load relevant references. (2) Verify all storage uses bounded types + MaxEncodedLen. (3) Verify all arithmetic uses checked/saturating operations. (4) Verify all extrinsics have call_index + weight + origin check. * END PROCESS GATE *


2. Global Invariants

MUST enforce on every pallet creation or modification. NEVER skip.

InvariantRule
no_std#![cfg_attr(not(feature = "std"), no_std)] header REQUIRED. All deps default-features = false.
Bounded StorageALL storage MUST implement MaxEncodedLen. No unbounded Vec in production.
Safe ArithmeticNEVER raw +, -, *, / on balances. Use checked_* or saturating_*.
No PanicsNEVER unwrap(), direct indexing, or division by zero in dispatchables.
DeterminismNEVER HashMap, HashSet, f32, f64, OS randomness, or SystemTime.
Call IndexEVERY extrinsic MUST have #[pallet::call_index(n)].
Origin CheckFirst line of every extrinsic MUST check origin.
Events LastEmit events AFTER all state mutations succeed.

3. Decision Matrix

Locate matching row. Load ALL files in Artifacts column.

User IntentActionArtifacts
"Create new pallet" / scaffold palletLoad structure + all referencesreferences/pallet-structure.md, references/storage-and-types.md, references/calls-events-hooks.md, references/testing-patterns.md
"Add storage" / storage designLoad storage referencereferences/storage-and-types.md
"Add extrinsic" / "add call"Load calls referencereferences/calls-events-hooks.md
"Write tests" / "add tests" / mock setupLoad testing referencereferences/testing-patterns.md
"Add benchmarks" / weightsLoad testing referencereferences/testing-patterns.md
"Review pallet" / check for issuesLoad all references, check against invariantsreferences/pallet-structure.md, references/storage-and-types.md, references/calls-events-hooks.md
Cargo.toml / dependencies / featuresLoad structure referencereferences/pallet-structure.md
Smart contract / non-Substrate codeSTOP — Not applicable—
Execution Protocol
  1. Match intent to Decision Matrix row.
  2. Load all artifacts listed for that row.
  3. Apply patterns from loaded references.
  4. Verify against Global Invariants before finalizing.

4. Contrastive Exemplars

✅ CORRECT: Safe Storage + Arithmetic
PhaseContent
Trigger"Add a vote tracking storage item"
ActionStorageDoubleMap<_, Blake2_128Concat, RoundId, Blake2_128Concat, Alias, Ballot, OptionQuery> with BoundedVec for proposals, checked_mul for vote cost
ResultBounded, deterministic, safe from overflow
❌ FAIL: Unbounded + Unsafe
PhaseContent
Trigger"Add a vote tracking storage item"
ActionStorageMap<_, Identity, AccountId, Vec<Vote>> with votes * votes for cost
ResultUnbounded Vec (no MaxEncodedLen), Identity hasher on user key (DoS), raw multiplication (overflow)
✅ CORRECT: Proper Extrinsic
PhaseContent
Trigger"Add a vote extrinsic"
Action#[pallet::call_index(1)], #[pallet::weight(T::WeightInfo::vote())], let alias = T::EnsurePerson::ensure_origin(origin, &CTX)?; as first line, ensure! for validation, event last
ResultVersioned, weighted, origin-checked, non-panicking
❌ FAIL: Missing Guards
PhaseContent
Trigger"Add a vote extrinsic"
ActionNo call_index, hardcoded weight, missing origin check, unwrap() on storage read
ResultBreaking encoding changes, incorrect fees, anyone can call, runtime panic

5. Anti-Patterns

PatternStatusReason
HashMap/HashSet in runtimeFORBIDDENNon-deterministic iteration breaks consensus
f32/f64 arithmeticFORBIDDENNon-deterministic across platforms
unwrap()/expect() in dispatchablesFORBIDDENUser-triggerable panic bypasses fees
vec[i] direct indexingFORBIDDENPanic on out-of-bounds
Raw +/-/*// on balancesFORBIDDENSilent overflow/underflow
Unbounded Vec in storageFORBIDDENNo MaxEncodedLen, unprovable PoV
Identity hasher on user-controlled keysFORBIDDENStorage key prediction enables DoS
Reading System::events() in productionFORBIDDENInflates PoV size unboundedly
Unbounded iteration in on_initializeFORBIDDENBlock production DoS
Panic in on_initializeFORBIDDENHalts block production (fatal for parachains)
Missing #[pallet::call_index]FORBIDDENExtrinsic encoding breaks on reorder
Tests at block 0 expecting eventsFORBIDDENEvents not recorded at genesis block
Tight coupling when loose sufficesFORBIDDENReduces reusability

* RUNTIME CONTRACT — RECENCY ENFORCEMENT * BEFORE finalizing any pallet code, verify:

  1. ALL storage bounded with MaxEncodedLen?
  2. ALL arithmetic checked/saturating?
  3. ALL extrinsics have call_index + weight + origin check?
  4. NO panics possible (unwrap, indexing, division)?
  5. NO HashMap/HashSet/float/OS randomness?

IF any check fails → FIX before proceeding. * END RUNTIME CONTRACT *

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/paritytech/substrate-skills/frame-pallet-guide/badge)](https://verified-skill.com/skills/paritytech/substrate-skills/frame-pallet-guide)

Something wrong with this skill or its page? Tell us.