backend-patterns

Implement FRAME pallet patterns for extrinsics, storage, and runtime APIs.

Updated Feb 6, 2026
One-click install
npx skills add https://github.com/MoriwakiYusuke/anarchy --skill backend-patterns-moriwakiyusuke
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-patterns
Source: https://github.com/MoriwakiYusuke/anarchy/tree/main/.claude/skills/backend-patterns
Command: npx skills add https://github.com/MoriwakiYusuke/anarchy --skill backend-patterns-moriwakiyusuke

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill prevents brittle or insecure Substrate pallet designs by providing proven FRAME patterns for extrinsics, storage, runtime API wiring, and pallet-to-pallet interface coupling in Anarchy’s tight architecture.

Core Features & Use Cases

  • Pallet skeleton & structure: Standardize Config/Storage/Event/Error/Call layout so new pallets compile cleanly for no_std WASM runtime targets.
  • Extrinsic flow correctness: Enforce a validate → charge → mutate → emit ordering using ensure! to guarantee safe reverts and predictable side effects.
  • Tight coupling without dependency traps: Use trait-based interfaces and ownership rules so pallets depend on abstractions rather than circular concrete bounds.
  • Storage & sizing safety: Choose hashers appropriately and use BoundedVec with explicit Max* constants to keep weights and benchmarking stable.
  • Runtime API & query guardrails: Declare sp_api runtime APIs for efficient frontend scanning while adding range-query upper limits to avoid DoS vectors.
  • Runtime composition checklist: Wire pallets into construct_runtime, add impls, declare runtime APIs, and bump spec_version to keep clients compatible.

Quick Start

Use the backend-patterns skill to implement a new Anarchy Substrate pallet by copying its Config/Storage/Event/Error/Call skeleton and applying the validate → charge → mutate → emit extrinsic ordering.

Frequently Asked Questions about backend-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design safe extrinsic logic in a Substrate pallet?

Safe extrinsic logic in a Substrate pallet requires enforcing a strict validate, charge, mutate, and emit ordering using ensure! semantics to guarantee predictable side effects and safe reverts.

How do I prevent storage bloat and keep weights stable in FRAME pallets?

Preventing storage bloat in FRAME pallets involves choosing appropriate hashers and using BoundedVec with explicit Max* constants to keep data structures bounded and weight benchmarking stable.

How do I avoid circular dependencies when coupling multiple Substrate pallets?

Avoiding circular dependencies when coupling Substrate pallets requires using trait-based interfaces and strict ownership rules so pallets depend on abstractions rather than concrete bounds.

How do I expose runtime APIs for frontend queries without creating DoS vectors?

Exposing runtime APIs for frontend queries safely requires declaring sp_api runtime interfaces for efficient scanning while implementing range-query upper limits to prevent DoS vectors.

What is the correct checklist for composing pallets into a Substrate runtime?

The correct checklist for composing pallets into a Substrate runtime involves wiring pallets into construct_runtime, adding impls, declaring runtime APIs, and bumping spec_version to keep clients compatible.

Why do my Substrate pallets fail to compile for no_std WASM runtime targets?

Substrate pallets fail to compile for no_std WASM targets when the Config, Storage, Event, Error, and Call layout lacks standardization, requiring a strict pallet skeleton structure to compile cleanly.