scaffold-agent — AI / agent instructions
This file documents the scaffold-agent CLI published on npm (scaffold-agent). The CLI generates new project directories; this repo (scaffoldagent.xyz) is the documentation website, not the CLI source tree.
Upstream reference: https://github.com/1clawAI/scaffold-agent — authoritative files there are AGENTS.md, README.md, and .cursor/skills/scaffold-agent/.
What it does
- Interactive (or fully flagged) CLI that scaffolds a monorepo: Solidity (Foundry or Hardhat or none) + app (Next.js, Vite, or Python A2A).
- Optional 1Claw vault/secrets, Shroud LLM proxy, Ampersend SDK, multiple swarm agent wallets.
- Generated apps follow patterns from Scaffold-ETH 2 (wagmi, ABIs,
/debug on Next, etc.) using Scaffold UI packages (@scaffold-ui/hooks, @scaffold-ui/components, @scaffold-ui/debug-contracts).
Terminology: 1claw = 1claw.xyz (vault, Shroud). OpenClaw (openclaw.ai) is a different product.
Prerequisites
- Node.js ≥ 18 and npm (for
npx scaffold-agent and the generated workspace).
- just installed on the host (not an npm dependency). Generated repos use a root
justfile for just chain, just deploy, just start, etc. Without just, run the equivalent npm run scripts from the generated README.md.
Invoke the CLI
npx scaffold-agent@latest
npx scaffold-agent@latest my-agent # creates ./my-agent, skips name prompt
scaffold-agent --help # full flag list; unknown flags error
scaffold-agent --version
Typical flow (generated repo, local chain)
Order matters: the local node must be up before auto-fund / deploy.
- Scaffold:
npx scaffold-agent@latest my-agent → cd my-agent
- Second terminal:
just chain (Foundry/Hardhat local RPC, default http://127.0.0.1:8545)
just fund — fund deployer + agent (+ swarm addresses in public/agents.json when present)
just deploy — deploy contracts, refresh ABIs
just start — frontend / agent dev server (often http://localhost:3000)
Skip steps 2–4 if you chose no chain; configure RPC / scaffold.config.ts per generated README.
Env skips: SCAFFOLD_SKIP_NPM_INSTALL=1 or --skip-npm-install; SCAFFOLD_SKIP_AUTO_FUND=1 or --skip-auto-fund when scaffolding.
Non-interactive / automation (-y)
Use -y / --non-interactive for CI or agents (no prompts).
--env-password (≥ 6 characters) is required when --secrets is oneclaw or encrypted, unless --secrets none.
--defer-oneclaw-api-key — skip ONECLAW_API_KEY at scaffold time.
--oneclaw-intents — register 1Claw agent with Intents enabled.
- Defaults under
-y match scaffold-agent --help (e.g. Foundry + Next.js + 1Claw Shroud + token billing).
Shroud + -y validation:
--llm oneclaw with --secrets none (or non-oneclaw): supply --oneclaw-agent-id and --oneclaw-agent-api-key.
--shroud-billing provider_api_key: supply --shroud-provider-api-key (vault vs .env depends on --secrets).
CLI flags (common)
Strict parsing: unknown options error. Full list: scaffold-agent --help.
| Flag |
Notes |
-y / --non-interactive |
No prompts |
--project <name> |
Or single positional directory name |
--secrets |
oneclaw | encrypted | none |
--env-password |
Required for oneclaw / encrypted with -y (min 6 chars) |
--defer-oneclaw-api-key |
Skip user API key at scaffold |
--oneclaw-intents |
Register 1Claw agent with Intents enabled (with -y) |
--llm |
oneclaw | gemini | openai | anthropic |
--shroud-upstream |
openai | anthropic | google | gemini | mistral | cohere | openrouter |
--shroud-billing |
token_billing | provider_api_key |
--shroud-provider-api-key |
Required for provider_api_key in -y |
--oneclaw-agent-id / --oneclaw-agent-api-key |
For oneclaw LLM when secrets are not oneclaw |
--chain |
foundry | hardhat | none |
--framework |
nextjs | vite | python |
--agent |
generate | none |
--ampersend |
yes | no |
--skip-npm-install |
|
--skip-auto-fund |
|
--swarm <n> |
1–64 agent wallets; extras in SWARM_AGENT_KEYS_JSON |
--from-config <file> |
Merge agent.json; CLI overrides file |
--dump-config |
Print merged config JSON to stdout (secrets omitted) |
--dump-config-out <file> |
Write that JSON to a file |
agent.json (--from-config / --dump-config)
- Merge with
--from-config <file>; any flag passed on the CLI wins over the file.
- Shape:
project or name, swarm, agents: { "my-agent-id": "preset-label" }, optional extra (written to generated agent.config.extra.json), optional options: { "secrets": "encrypted", … }.
- Top-level keys may mirror CLI long-option names.
--dump-config prints merged JSON (no scaffold). --dump-config-out writes the same; passwords and API keys are omitted so the file is safe to share.
Swarm (--swarm)
--swarm <n> (1–64): multiple generated agent wallets; first remains AGENT_ADDRESS / AGENT_PRIVATE_KEY; extras in encrypted SWARM_AGENT_KEYS_JSON.
- Public roster:
packages/*/public/agents.json (addresses only).
- Next/Vite:
lib/agent-swarm.tsx, header picker, /swarm page; balances/identity follow selected agent.
- Post-scaffold:
just swarm agents=N (see generated justfile).
Unified network model
scaffold.config.ts → targetNetwork is the single source of truth for the active EVM network across UI, API routes, and AI agent tools.
getActiveNetwork() resolves targetNetwork to a NetworkDefinition with rpcOverrides applied.
- Agent on-chain tools default
chainId and chain parameters to getActiveNetwork().
ONECLAW_CHAIN_NAMES maps chainId → 1Claw slug (e.g. 8453 → "base").
Agent on-chain tools (generated repos)
lib/agent-onchain-tools.ts — Vercel AI SDK tools in the chat route:
list_deployed_contracts — enumerate addresses from deployedContracts.ts.
contract_read — call any view/pure function via RPC (defaults to active network).
oneclaw_intent_simulate — simulate via 1Claw Intents + Tenderly.
oneclaw_intent_submit — submit signed intent to 1Claw TEE.
Generated layout (high level)
After scaffold, expect roughly:
- Root
justfile, package.json (workspaces), README.md, .env (gitignored), optional .env.secrets.encrypted
scripts/ — fund-deployer.mjs, swarm-agents.mjs, with-secrets.mjs, check-network.mjs, deploy scripts, etc.
packages/foundry or packages/hardhat (if chain chosen)
packages/nextjs or packages/vite or packages/python — chat UI, /api/chat, identity/ENS/balances/swarm/debug routes
just commands (generated repo)
| Command |
Description |
just chain |
Local blockchain |
just fund |
Fund deployer + agent (+ swarm from public/agents.json) |
just deploy |
Deploy + ABI generation |
just start |
Dev server / agent (runs check-network precheck) |
just check-network |
Validate targetNetwork chainId in deployedContracts.ts |
just use-network KEY |
Switch targetNetwork and run check (ethereum, base, sepolia, baseSepolia, polygon, bnb, localhost) |
just accounts |
QR for deployer + agent |
just balances |
Balances across configured chains |
just generate |
Deployer wallet (+ auto-fund if RPC up) |
just swarm agents=N |
Append swarm wallets |
just env KEY VALUE |
Upsert .env |
just enc KEY VALUE |
Update encrypted secrets (password prompt) |
just vault PATH VALUE |
1Claw vault secret |
just list-1claw |
List vault and agent UUIDs |
just sync-1claw-env |
Write first vault + agent UUIDs to .env |
just reown PROJECT_ID |
WalletConnect project id → env |
just reset |
Re-bootstrap 1Claw vault + agent (backup .env first) |
LLM providers and models
Shroud upstreams
SHROUD_LLM_PROVIDER |
Default SHROUD_DEFAULT_MODEL |
openai |
gpt-4o |
anthropic |
claude-sonnet-4-20250514 |
google or gemini |
gemini-2.0-flash |
mistral |
mistral-large-latest |
cohere |
command-r-plus |
openrouter |
openai/gpt-4o |
Direct LLM defaults (not Shroud)
| Provider |
Default model |
Override |
| Gemini |
gemini-2.5-flash |
GOOGLE_GENERATIVE_AI_MODEL |
| OpenAI |
gpt-4o |
Edit the generated chat route |
| Anthropic |
claude-sonnet-4-20250514 |
Edit the generated chat route |
1Claw / Shroud (essentials)
ONECLAW_AGENT_ID is a UUID, not an Ethereum 0x… address.
- Shroud docs: Shroud guide. Chat uses
X-Shroud-Agent-Key, not Authorization: Bearer for Shroud.
SHROUD_BILLING_MODE: token_billing (1Claw billing) vs provider_api_key (BYOK in vault or SHROUD_PROVIDER_API_KEY).
Security
- Never commit real keys, agent API keys, or deployer private keys.
- Do not put Ethereum addresses in
ONECLAW_AGENT_ID.
- Prefer
--dump-config for shareable config; secrets are stripped.
Links
Synthesized from upstream (SKILL.md, reference.md, README.md, AGENTS.md). If behavior diverges, trust scaffold-agent --help and the upstream repo.
1---
2name: scaffold-agent
3description: >-
4 How to use the scaffold-agent npm CLI to generate onchain AI agent monorepos
5 (Foundry/Hardhat + Next.js/Vite/Python): npx invocation, -y flags, agent.json,
6 swarm, 1Claw/Shroud, just commands, and security. Upstream source lives at
7 https://github.com/1clawAI/scaffold-agent.
8metadata:
9 source: https://skillmd.com/skills/aibot88/scaffold-agent
10---
11
12# scaffold-agent — AI / agent instructions
13
14This file documents the **`scaffold-agent`** CLI published on npm ([scaffold-agent](https://www.npmjs.com/package/scaffold-agent)). The CLI **generates** new project directories; this repo (scaffoldagent.xyz) is the **documentation website**, not the CLI source tree.
15
16**Upstream reference:** [https://github.com/1clawAI/scaffold-agent](https://github.com/1clawAI/scaffold-agent) — authoritative files there are `AGENTS.md`, `README.md`, and `.cursor/skills/scaffold-agent/`.
17
18---
19
20## What it does
21
22- Interactive (or fully flagged) CLI that scaffolds a **monorepo**: Solidity (**Foundry** or **Hardhat** or none) + app (**Next.js**, **Vite**, or **Python** A2A).
23- Optional **1Claw** vault/secrets, **Shroud** LLM proxy, **Ampersend** SDK, multiple **swarm** agent wallets.
24- Generated apps follow patterns from [Scaffold-ETH 2](https://github.com/scaffold-eth/scaffold-eth-2) (wagmi, ABIs, `/debug` on Next, etc.) using [Scaffold UI](https://github.com/scaffold-eth/scaffold-ui) packages (`@scaffold-ui/hooks`, `@scaffold-ui/components`, `@scaffold-ui/debug-contracts`).
25
26**Terminology:** **1claw** = [1claw.xyz](https://1claw.xyz) (vault, Shroud). **OpenClaw** ([openclaw.ai](https://openclaw.ai)) is a different product.
27
28---
29
30## Prerequisites
31
32- **Node.js** ≥ 18 and **npm** (for `npx scaffold-agent` and the generated workspace).
33- **[just](https://just.systems)** installed on the host (not an npm dependency). Generated repos use a root `justfile` for `just chain`, `just deploy`, `just start`, etc. Without `just`, run the equivalent `npm run` scripts from the generated `README.md`.
34
35---
36
37## Invoke the CLI
38
39```bash
40npx scaffold-agent@latest
41npx scaffold-agent@latest my-agent # creates ./my-agent, skips name prompt
42scaffold-agent --help # full flag list; unknown flags error
43scaffold-agent --version
44```
45
46---
47
48## Typical flow (generated repo, local chain)
49
50Order matters: the local node must be up before auto-fund / deploy.
51
521. Scaffold: `npx scaffold-agent@latest my-agent` → `cd my-agent`
532. **Second terminal:** `just chain` (Foundry/Hardhat local RPC, default `http://127.0.0.1:8545`)
543. `just fund` — fund deployer + agent (+ swarm addresses in `public/agents.json` when present)
554. `just deploy` — deploy contracts, refresh ABIs
565. `just start` — frontend / agent dev server (often [http://localhost:3000](http://localhost:3000))
57
58Skip steps 2–4 if you chose **no chain**; configure RPC / `scaffold.config.ts` per generated README.
59
60**Env skips:** `SCAFFOLD_SKIP_NPM_INSTALL=1` or `--skip-npm-install`; `SCAFFOLD_SKIP_AUTO_FUND=1` or `--skip-auto-fund` when scaffolding.
61
62---
63
64## Non-interactive / automation (`-y`)
65
66Use `-y` / `--non-interactive` for CI or agents (no prompts).
67
68- `--env-password` (≥ 6 characters) is **required** when `--secrets` is `oneclaw` or `encrypted`, unless `--secrets none`.
69- `--defer-oneclaw-api-key` — skip `ONECLAW_API_KEY` at scaffold time.
70- `--oneclaw-intents` — register 1Claw agent with Intents enabled.
71- Defaults under `-y` match `scaffold-agent --help` (e.g. Foundry + Next.js + 1Claw Shroud + token billing).
72
73**Shroud + `-y` validation:**
74
75- `--llm oneclaw` with `--secrets none` (or non-oneclaw): supply `--oneclaw-agent-id` and `--oneclaw-agent-api-key`.
76- `--shroud-billing provider_api_key`: supply `--shroud-provider-api-key` (vault vs `.env` depends on `--secrets`).
77
78---
79
80## CLI flags (common)
81
82Strict parsing: unknown options **error**. Full list: `scaffold-agent --help`.
83
84| Flag | Notes |
85|------|--------|
86| `-y` / `--non-interactive` | No prompts |
87| `--project <name>` | Or single positional directory name |
88| `--secrets` | `oneclaw` \| `encrypted` \| `none` |
89| `--env-password` | Required for `oneclaw` / `encrypted` with `-y` (min 6 chars) |
90| `--defer-oneclaw-api-key` | Skip user API key at scaffold |
91| `--oneclaw-intents` | Register 1Claw agent with Intents enabled (with `-y`) |
92| `--llm` | `oneclaw` \| `gemini` \| `openai` \| `anthropic` |
93| `--shroud-upstream` | `openai` \| `anthropic` \| `google` \| `gemini` \| `mistral` \| `cohere` \| `openrouter` |
94| `--shroud-billing` | `token_billing` \| `provider_api_key` |
95| `--shroud-provider-api-key` | Required for `provider_api_key` in `-y` |
96| `--oneclaw-agent-id` / `--oneclaw-agent-api-key` | For `oneclaw` LLM when secrets are not `oneclaw` |
97| `--chain` | `foundry` \| `hardhat` \| `none` |
98| `--framework` | `nextjs` \| `vite` \| `python` |
99| `--agent` | `generate` \| `none` |
100| `--ampersend` | `yes` \| `no` |
101| `--skip-npm-install` | |
102| `--skip-auto-fund` | |
103| `--swarm <n>` | 1–64 agent wallets; extras in `SWARM_AGENT_KEYS_JSON` |
104| `--from-config <file>` | Merge `agent.json`; **CLI overrides file** |
105| `--dump-config` | Print merged config JSON to stdout (secrets omitted) |
106| `--dump-config-out <file>` | Write that JSON to a file |
107
108---
109
110## `agent.json` (`--from-config` / `--dump-config`)
111
112- Merge with `--from-config <file>`; any flag passed on the CLI **wins** over the file.
113- Shape: `project` or `name`, `swarm`, `agents`: `{ "my-agent-id": "preset-label" }`, optional `extra` (written to generated `agent.config.extra.json`), optional `options`: `{ "secrets": "encrypted", … }`.
114- Top-level keys may mirror CLI long-option names.
115
116`--dump-config` prints merged JSON (no scaffold). `--dump-config-out` writes the same; **passwords and API keys are omitted** so the file is safe to share.
117
118---
119
120## Swarm (`--swarm`)
121
122- `--swarm <n>` (1–64): multiple generated agent wallets; first remains `AGENT_ADDRESS` / `AGENT_PRIVATE_KEY`; extras in encrypted `SWARM_AGENT_KEYS_JSON`.
123- Public roster: `packages/*/public/agents.json` (addresses only).
124- Next/Vite: `lib/agent-swarm.tsx`, header picker, `/swarm` page; balances/identity follow selected agent.
125- Post-scaffold: `just swarm agents=N` (see generated `justfile`).
126
127---
128
129## Unified network model
130
131`scaffold.config.ts` → `targetNetwork` is the single source of truth for the active EVM network across UI, API routes, and AI agent tools.
132
133- `getActiveNetwork()` resolves `targetNetwork` to a `NetworkDefinition` with `rpcOverrides` applied.
134- Agent on-chain tools default `chainId` and `chain` parameters to `getActiveNetwork()`.
135- `ONECLAW_CHAIN_NAMES` maps `chainId` → 1Claw slug (e.g. `8453 → "base"`).
136
137---
138
139## Agent on-chain tools (generated repos)
140
141`lib/agent-onchain-tools.ts` — Vercel AI SDK `tool`s in the chat route:
142
143- `list_deployed_contracts` — enumerate addresses from `deployedContracts.ts`.
144- `contract_read` — call any view/pure function via RPC (defaults to active network).
145- `oneclaw_intent_simulate` — simulate via 1Claw Intents + Tenderly.
146- `oneclaw_intent_submit` — submit signed intent to 1Claw TEE.
147
148---
149
150## Generated layout (high level)
151
152After scaffold, expect roughly:
153
154- Root `justfile`, `package.json` (workspaces), `README.md`, `.env` (gitignored), optional `.env.secrets.encrypted`
155- `scripts/` — `fund-deployer.mjs`, `swarm-agents.mjs`, `with-secrets.mjs`, `check-network.mjs`, deploy scripts, etc.
156- `packages/foundry` or `packages/hardhat` (if chain chosen)
157- `packages/nextjs` or `packages/vite` or `packages/python` — chat UI, `/api/chat`, identity/ENS/balances/swarm/debug routes
158
159---
160
161## `just` commands (generated repo)
162
163| Command | Description |
164|---------|-------------|
165| `just chain` | Local blockchain |
166| `just fund` | Fund deployer + agent (+ swarm from `public/agents.json`) |
167| `just deploy` | Deploy + ABI generation |
168| `just start` | Dev server / agent (runs `check-network` precheck) |
169| `just check-network` | Validate `targetNetwork` chainId in `deployedContracts.ts` |
170| `just use-network KEY` | Switch `targetNetwork` and run check (ethereum, base, sepolia, baseSepolia, polygon, bnb, localhost) |
171| `just accounts` | QR for deployer + agent |
172| `just balances` | Balances across configured chains |
173| `just generate` | Deployer wallet (+ auto-fund if RPC up) |
174| `just swarm agents=N` | Append swarm wallets |
175| `just env KEY VALUE` | Upsert `.env` |
176| `just enc KEY VALUE` | Update encrypted secrets (password prompt) |
177| `just vault PATH VALUE` | 1Claw vault secret |
178| `just list-1claw` | List vault and agent UUIDs |
179| `just sync-1claw-env` | Write first vault + agent UUIDs to `.env` |
180| `just reown PROJECT_ID` | WalletConnect project id → env |
181| `just reset` | Re-bootstrap 1Claw vault + agent (**backup `.env` first**) |
182
183---
184
185## LLM providers and models
186
187### Shroud upstreams
188
189| `SHROUD_LLM_PROVIDER` | Default `SHROUD_DEFAULT_MODEL` |
190|---|---|
191| `openai` | `gpt-4o` |
192| `anthropic` | `claude-sonnet-4-20250514` |
193| `google` or `gemini` | `gemini-2.0-flash` |
194| `mistral` | `mistral-large-latest` |
195| `cohere` | `command-r-plus` |
196| `openrouter` | `openai/gpt-4o` |
197
198### Direct LLM defaults (not Shroud)
199
200| Provider | Default model | Override |
201|---|---|---|
202| Gemini | `gemini-2.5-flash` | `GOOGLE_GENERATIVE_AI_MODEL` |
203| OpenAI | `gpt-4o` | Edit the generated chat route |
204| Anthropic | `claude-sonnet-4-20250514` | Edit the generated chat route |
205
206---
207
208## 1Claw / Shroud (essentials)
209
210- `ONECLAW_AGENT_ID` is a **UUID**, not an Ethereum `0x…` address.
211- Shroud docs: [Shroud guide](https://docs.1claw.xyz/docs/guides/shroud). Chat uses `X-Shroud-Agent-Key`, not `Authorization: Bearer` for Shroud.
212- `SHROUD_BILLING_MODE`: `token_billing` (1Claw billing) vs `provider_api_key` (BYOK in vault or `SHROUD_PROVIDER_API_KEY`).
213
214---
215
216## Security
217
218- Never commit real keys, agent API keys, or deployer private keys.
219- Do not put Ethereum addresses in `ONECLAW_AGENT_ID`.
220- Prefer `--dump-config` for shareable config; secrets are stripped.
221
222---
223
224## Links
225
226- npm: [https://www.npmjs.com/package/scaffold-agent](https://www.npmjs.com/package/scaffold-agent)
227- GitHub: [https://github.com/1clawAI/scaffold-agent](https://github.com/1clawAI/scaffold-agent)
228- Shroud: [https://docs.1claw.xyz/docs/guides/shroud](https://docs.1claw.xyz/docs/guides/shroud)
229- SKILL.md (for AI agents): [https://scaffoldagent.xyz/SKILL.md](https://scaffoldagent.xyz/SKILL.md)
230
231---
232
233*Synthesized from upstream (SKILL.md, reference.md, README.md, AGENTS.md). If behavior diverges, trust `scaffold-agent --help` and the upstream repo.*