Home › Solidity / smart contracts › Solidity + Foundry Copilot path instructions

Solidity + Foundry Copilot path instructions

Path-specific Copilot instructions for Solidity 0.8.x contracts with Foundry: security patterns, fuzz tests, and gas.

GitHub CopilotSolidity / smart contracts

How to use

Save this as .github/instructions/solidity.instructions.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.github/instructions/solidity.instructions.mdDownload  
---
applyTo: "**/*.sol"
description: Solidity contract conventions
---

# Solidity (0.8.x) with Foundry

- Build/test: `forge build`, `forge test -vvv`, `forge fmt --check`, `forge coverage`. Static analysis: `slither .` if installed.
- Pin the pragma to the project's compiler (`pragma solidity 0.8.30;`), not a floating `^`.
- Use audited OpenZeppelin contracts for tokens, access control (`Ownable2Step`, `AccessControl`) and `ReentrancyGuard`; don't reimplement them.
- Checks-effects-interactions order in every function that calls out; add `nonReentrant` where external calls follow state reads.
- Custom errors (`error InsufficientBalance(uint256 have, uint256 want);`) instead of revert strings.
- Validate inputs (zero address, bounds) and emit events for every state change.
- Never use `tx.origin` for auth, `block.timestamp` for randomness, or unchecked low-level `call` return values. Use `SafeERC20` for token transfers.
- Upgradeable contracts: follow the proxy pattern in use, no constructors (use initializers), preserve storage layout.
- NatSpec (`/// @notice`, `@param`) on external functions.

## Tests
Unit tests plus fuzz tests (`function testFuzz_x(uint256 amount)`) and invariant tests for core accounting. Fork tests use a pinned block number.

Never deploy, broadcast, or use private keys from the agent.

More: all Solidity / smart contracts rules · all GitHub Copilot rules

Related rules

Solidity smart contract security CLAUDE.md

CLAUDE.md for reviewing and writing Solidity contracts safely: threat checklist, Foundry tests, and no-deploy rules.

Claude Code (CLAUDE.md)Solidity / smart contracts

Modern C++ with CMake rules

Cursor rules for modern C++ (C++20/23) projects built with CMake presets: RAII, ownership, warnings, and tests.

CursorC++

Embedded C (bare metal / RTOS) AGENTS.md

AGENTS.md for embedded C firmware (bare metal, Zephyr, FreeRTOS): safety-minded C rules, memory, and hardware access.

AGENTS.mdEmbedded / firmware

ESP32 ESP-IDF firmware CLAUDE.md

CLAUDE.md for ESP32 firmware on ESP-IDF 5.x in C: components, FreeRTOS tasks, error handling, and logging.

Claude Code (CLAUDE.md)Embedded / firmware

Arduino / PlatformIO rules

Cursor rules for microcontroller projects with PlatformIO and the Arduino framework: non-blocking loops, memory, pins.

CursorEmbedded / firmware

Zig AGENTS.md

AGENTS.md for Zig 0.15 projects: build.zig, explicit allocators, error unions, defer cleanup, and zig test.

AGENTS.mdZig

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.