w3m chat

Interactive AI chat session for modifying your project through conversation. Make iterative changes to contracts and frontend code, see diffs previewed and applied, and watch contracts auto-rebuild after each change.

w3m chat

Requires authentication via w3m auth and an AI provider (your own Anthropic or OpenAI key).

You can also start a chat session from the interactive workspace: run w3m, then select AI Chat.

Options

OptionDefaultDescription
--no-anvilSkip Anvil integration for rebuilds

Requirements

  • Must be run from a project directory
  • Requires a web3.market API key (w3m auth <key>)
  • Requires an AI provider — your own Anthropic (Claude) or OpenAI (GPT) API key, configured via w3m ai setup (prompted on first use if not configured)
  • Requires Git (the chat session uses git snapshots for undo/revert)

How It Works

Validation

Checks that you are inside a project directory, have an API key, and have an AI provider configured. If no AI config exists, you are prompted to set one up inline.

Git Snapshot

Initializes a git repository if one does not exist, and creates a snapshot before the session starts. Every change the AI makes is bookmarked so you can revert at any time.

Conversation Loop

You type requests in plain English. The AI reads your project files (contracts, frontend, config) each turn, then responds with code changes or explanations.

  • Code changes are previewed as a diff, then applied to disk automatically.
  • Solidity changes trigger an automatic rebuild: forge build → deploy to Anvil → codegen.
  • Frontend-only changes are applied without rebuilding contracts.
  • Questions (no code changes) display the AI’s explanation inline.

Build Failure Handling

If a rebuild fails after applying changes, you get a menu:

OptionWhat happens
Auto-fix with AISends the build errors to w3m fix for automatic repair
Refine your requestContinue the conversation to manually adjust
Revert changesRoll back to the pre-change snapshot and rebuild
Continue anywayIgnore the build errors and keep going

Session End

When you exit, a final snapshot is created. All snapshots are preserved in the git history.

Slash Commands

Type these during a chat session:

CommandDescription
/exit, /quit, /qEnd the chat session
/revert [hash]Revert to a previous snapshot. Without a hash, shows an interactive picker.
/undoAlias for /revert
/historyShow recent snapshots with hashes and messages
/helpShow available commands

Snapshots

Every AI change creates two git commits: one before applying changes (so you can revert cleanly) and one after. You can browse and revert to any snapshot using /history and /revert.

Snapshots use standard git commits — you can also inspect them with git log outside of the chat session.

Pre-flight Environment Validation

Before deploying contracts to the local Anvil chain, the CLI scans your deploy script for required environment variables (vm.envUint, vm.envAddress, etc.). Known variables like DEPLOYER_PRIVATE_KEY are auto-provided for local development. If any required variables are missing, you are told exactly which ones to set before deployment is attempted.

Examples

# Start a chat session
w3m chat
 
# Start without Anvil integration (frontend-only project)
w3m chat --no-anvil

Example conversation

you > Change the token name to PEPE and symbol to PEPE

  ┃ contracts/src/Token.sol
  ┃ - string public name = "MyToken";
  ┃ + string public name = "PEPE";
  ┃ - string public symbol = "MTK";
  ┃ + string public symbol = "PEPE";

  ✓ Changes applied
  ✓ Contracts compiled
  ✓ Contracts deployed to local chain

you > Now add a 2% burn fee on every transfer

  ┃ contracts/src/Token.sol (modified)
  ┃ + uint256 public burnFee = 200; // 2% in basis points
  ┃ + ...

  ✓ Changes applied
  ✓ Contracts compiled
  ✓ Contracts deployed to local chain

you > /history
  abc1234  AI: Change the token name to PEPE and symbol...
  def5678  AI: Now add a 2% burn fee on every transfer

you > /revert abc1234
  ✓ Reverted to: AI: Change the token name to PEPE...
  ✓ Contracts compiled

you > /exit
  Chat session ended.
⚠️

AI Chat requires both a web3.market API key (w3m auth <key>) and an AI provider (your own Anthropic or OpenAI key, configured via w3m ai setup). The AI provider is used for inference — you pay your provider directly at their standard rates.