AgentSkillsCN

scaffold-contract

在不实现具体行为的前提下,以 NatSpec 和便于审计的结构搭建新的 Solidity 合约或模块骨架。当您开始构建新模块、适配器或合约时,可选择此标签。

SKILL.md
--- frontmatter
name: scaffold-contract
description: Scaffold new Solidity contract or module skeletons with NatSpec and audit-friendly structure without implementing behavior. Use when starting new modules, adapters, or contracts.

Skill: scaffold-contract

Purpose

Create a new Solidity module skeleton with a standard, audit-friendly structure and NatSpec documentation, suitable for DeFi protocol development.

This skill focuses only on structure and interfaces, not behavior or tests.

When to Invoke

  • Starting a new contract or module
  • Adding a new vault, strategy, adapter, or manager
  • Establishing a consistent layout before implementation begins
  • Preparing a contract surface before spec-to-implementation

Inputs Required

  • Contract name
  • Module type (e.g. vault, strategy, adapter, library)
  • Upgradeability model (immutable or upgradeable)
  • Solidity version (if different from repo default)
  • Required inheritance (base contracts, mixins)
  • Required interfaces to implement

Actions

1) Generate a Solidity contract skeleton

The generated contract must include:

  • SPDX identifier
  • Solidity pragma
  • Imports following .codex/constraints/solidity-style.md
  • Contract declaration
  • Explicit sections for:
    • constants
    • immutables
    • state variables
    • errors
    • events
    • constructor or initializer
    • external/public function declarations
    • internal helper functions

All public and external functions must include NatSpec comments describing:

  • intent
  • parameters
  • return values
  • assumptions (if any)

Function bodies may be empty or revert with a NotImplemented-style custom error where appropriate.

2) Define explicit placeholders (TODOs)

Add inline TODO comments indicating where future work belongs, including:

  • business logic
  • accounting paths
  • external integrations
  • access control checks
  • invariants that must later hold

TODOs must include context explaining what is missing and why.

Constraints and Safety Rules

  • Must not implement business logic
  • Must not generate or modify any tests
  • Must not introduce external calls
  • Must not assume ERC20 compliance
  • Must comply with all rules in .codex/constraints/solidity-style.md
  • Storage layout for upgradeable contracts must be:
    • explicit
    • append-only
    • clearly sectioned
  • Public APIs must be:
    • fully declared
    • documented
    • unimplemented where appropriate

Outputs

  • src/<module-path>/<Contract>.sol

No test files, mocks, or scaffolding may be generated by this skill.

Verification

  • Contract compiles with forge build
  • Formatting passes forge fmt
  • No tests are created or modified

Handoff

After successful execution, this skill should be followed by:

  • spec-to-implementation to implement behavior
  • implementation-to-tests to generate scenario-based tests

Example Prompts

  • “Use scaffold-contract to create an upgradeable ERC4626-style vault named MorphoVault with documented public interfaces only.”
  • “Scaffold a non-upgradeable adapter contract implementing IMarketAdapter without adding any logic or tests.”