Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

using-foundry

БесплатноБез исполняемых скриптовНе проверен

Use when starting, configuring, or doing day-to-day work in a Foundry project. Covers forge init, build, test, fmt, project layout, remappings, foundry.toml…

idchain-worldот idchain-world★ 19 звёзд на GitHub

Об этом скилле

Using Foundry

You are working on a Foundry project. Foundry is the toolchain (forge, cast, anvil, chisel) that compiles, tests, and deploys Solidity. This skill encodes the project-hygiene defaults you must follow on every session.

The Iron Laws

  1. NO COMMIT WITHOUT forge fmt --check AND forge build CLEAN. If either fails, fix before committing. Do not commit "just the tests" or "just the config" to work around a formatter or compiler error.
  2. NO forge test WITHOUT -vvv ON FAILURE. If a test fails at default verbosity, re-run the same test with -vvv (or -vvvv for opcode traces) before you start guessing. The trace is the diagnosis.
  3. NO NEW DEPENDENCY WITHOUT PINNING. forge install a dependency, then record the exact tag or commit in the install command (forge install OpenZeppelin/[email protected]). Never install from master/main for production work.
  4. NO EDITING remappings.txt OR foundry.toml WITHOUT A REASON STATED IN THE COMMIT MESSAGE. These files control the entire toolchain. A silent change here breaks every contributor.
  5. NEVER DELETE lib/ OR out/ TO "FIX" A BUILD. If forge build fails, read the error. forge clean is the escape hatch, not rm -rf lib.

Project layout

Standard Foundry layout, produced by forge init <name>:

my-project/
├── foundry.toml          # toolchain config
├── remappings.txt        # optional, overrides auto-remappings
├── .gitignore            # must include out/, cache/, broadcast/
├── src/                  # production contracts
├── test/                 # *.t.sol test files
├── script/               # *.s.sol deploy + ops scripts
└── lib/                  # forge-std and other git-submodule deps

Do not rename these directories. foundry.toml can redirect them, but every Foundry-literate engineer expects src/ / test/ / script/ / lib/. Surprising layouts cost onboarding time.

First-contact workflow

When you open a Foundry project you have never seen before, run in this order:

  1. cat foundry.toml — read the profile, Solidity version, EVM version, remappings, fuzz runs.
  2. cat remappings.txt (if it exists) — understand how imports resolve.
  3. ls lib/ — see which dependencies are vendored.
  4. forge build — confirm the project compiles as-is before you touch anything.
  5. forge test --fail-fast — confirm tests pass as-is.

If step 4 or 5 fails on a clean checkout, stop and report to the user. Do not try to "fix" a broken baseline. You cannot tell which failures are new versus pre-existing.

foundry.toml essentials

Pin three things at minimum:

[profile.default]
src = "src"
out = "out"
libs = ["lib"]
solc_version = "0.8.26"
evm_version = "cancun"
optimizer = true
optimizer_runs = 200
via_ir = false

[fmt]
line_length = 120
tab_width = 4
bracket_spacing = true
int_types = "long"

[fuzz]
runs = 256

[invariant]
runs = 256
depth = 15

Rule: solc_version is pinned, not floating. solc = "^0.8.20" is wrong for a foundry.toml. Use an exact version so every contributor and CI run compiles with the same compiler. (Source: https://book.getfoundry.sh/config/)

Remappings

Foundry auto-derives remappings from lib/. You only need remappings.txt when you want to override them — usually to flatten OpenZeppelin's deep path or to alias a fork.

DO:

@openzeppelin/=lib/openzeppelin-contracts/
forge-std/=lib/forge-std/src/
solady/=lib/solady/src/

DON'T:

# Rely on implicit remappings and then wonder why an import fails
# in one tool (forge) but works in another (hardhat).

If you edit remappings.txt, also run forge remappings > remappings.txt once to see what Foundry derives today, and then decide which to override.

Dependency management

Three options. In order of preference for a new project:

Option A: forge install + git submodules (default)

forge install OpenZeppelin/[email protected]
forge install transmissions11/solmate@v7
  • Installs as a git submodule under lib/.
  • Pros: canonical, zero extra tooling, the Foundry Book assumes this.
  • Cons: git submodules are clunky. Collaborators must run git submodule update --init --recursive.

Option B: Soldeer (forge soldeer)

forge soldeer install @openzeppelin-contracts~5.0.2
  • Installs into dependencies/ with a lockfile in soldeer.lock.
  • Pros: real package manager, reproducible, no submodule headaches.
  • Cons: younger ecosystem, some libraries still publish only to GitHub.

Option C: npm / pnpm

Only if the project also ships a JS SDK in the same monorepo. Otherwise don't mix.

Rule: pick one per project. Do not mix lib/ submodules and dependencies/ soldeer in the same repo without a comment in the README explaining why.

The forge CLI commands you use every day

Command When Key flags
forge init Once per project --no-commit if you'll init git yourself
`forge
Полный SKILL.md на GitHub

Установить using-foundry в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл using-foundry?

Use when starting, configuring, or doing day-to-day work in a Foundry project. Covers forge init, build, test, fmt, project layout, remappings, foundry.toml, and dependency management with forge install / soldeer / git submodules. Load before any other Foundry skill when the project is unfamiliar.

Как установить скилл using-foundry?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл using-foundry запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить using-foundry с