Claude Code
Claude Code is Anthropic's CLI-based AI coding agent. It doesn't have built-in LSP integration, but you can configure it to work effectively with Solidity projects using instruction files and MCP servers.
Configure
Claude Code uses a hierarchy of configuration files. For Solidity projects, create a CLAUDE.md in your project root:
CLAUDE.md
# Project
This is a Solidity project using Foundry.
## Build and Test
- Build: `forge build`
- Test: `forge test`
- Single test: `forge test --match-test testFunctionName -vvv`
- Gas report: `forge test --gas-report`
## Structure
- `src/` — Solidity source contracts
- `test/` — Foundry test files
- `script/` — Deploy scripts
- `lib/` — Dependencies (git submodules)
## Conventions
- Use Solidity 0.8.x
- Follow NatSpec documentation for all public/external functions
- Tests use the `test_` prefix for passing tests, `testFail_` for expected failures
- Use `forge fmt` before committingHow it works
Claude Code interacts with your code through file read/write/edit tools and bash commands. For Solidity development:
- Diagnostics: Run
forge buildto get compiler errors and warnings - Testing: Run
forge testto validate changes - Code navigation: Uses file search, grep, and code reading tools to understand the codebase
- Edits: Applies targeted edits to source files
Configuration scopes
Claude Code reads instructions from multiple locations (highest to lowest priority):
| Scope | Location | Use case |
|---|---|---|
| Managed | Set by admins | Organization policies |
| User | ~/.claude/CLAUDE.md | Personal preferences |
| Project | CLAUDE.md (repo root) | Project-specific instructions (committed) |
| Local | .claude/CLAUDE.md | Local overrides (gitignored) |
MCP servers
Claude Code supports MCP servers for extending tool capabilities. Configure them in .claude/settings.json:
.claude/settings.json
{
"permissions": {
"allow": [
"Bash(forge build)",
"Bash(forge test*)",
"Bash(forge fmt*)"
]
}
}Tips
- Pre-approve common commands in
.claude/settings.jsonso the agent doesn't ask for permission on everyforge build - Keep
CLAUDE.mdconcise — the agent reads it on every session start - Use
forge buildoutput as the primary source of compiler diagnostics - Run
forge testafter changes to verify correctness - Add project-specific conventions (naming, import style, test patterns) to
CLAUDE.mdso the agent follows your standards