Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

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 committing

How it works

Claude Code interacts with your code through file read/write/edit tools and bash commands. For Solidity development:

  1. Diagnostics: Run forge build to get compiler errors and warnings
  2. Testing: Run forge test to validate changes
  3. Code navigation: Uses file search, grep, and code reading tools to understand the codebase
  4. Edits: Applies targeted edits to source files

Configuration scopes

Claude Code reads instructions from multiple locations (highest to lowest priority):

ScopeLocationUse case
ManagedSet by adminsOrganization policies
User~/.claude/CLAUDE.mdPersonal preferences
ProjectCLAUDE.md (repo root)Project-specific instructions (committed)
Local.claude/CLAUDE.mdLocal 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.json so the agent doesn't ask for permission on every forge build
  • Keep CLAUDE.md concise — the agent reads it on every session start
  • Use forge build output as the primary source of compiler diagnostics
  • Run forge test after changes to verify correctness
  • Add project-specific conventions (naming, import style, test patterns) to CLAUDE.md so the agent follows your standards