1- # AGENTS.md
1+ import { withDefaults } from "../utils.js" ;
2+
3+ const contents = ( {
4+ extraProjectOverview,
5+ extraSections,
6+ fullContentOverride,
7+ } ) => {
8+
9+ if ( fullContentOverride [ 0 ] ) {
10+ return fullContentOverride [ 0 ] ;
11+ }
12+
13+ return `# AGENTS.md
214
315This file provides guidance to coding agents working in this repository.
416
517## Project Overview
618
719Scaffold-ETH 2 (SE-2) is a starter kit for building dApps on Ethereum. It comes in **two flavors** based on the Solidity framework:
820
9- - ** Hardhat flavor** : Uses ` packages/hardhat ` with hardhat-deploy plugin
10- - ** Foundry flavor** : Uses ` packages/foundry ` with Forge scripts
21+ - **Hardhat flavor**: Uses \ `packages/hardhat\ ` with hardhat-deploy plugin
22+ - **Foundry flavor**: Uses \ `packages/foundry\ ` with Forge scripts
1123
1224Both flavors share the same frontend package:
1325
@@ -17,14 +29,14 @@ Both flavors share the same frontend package:
1729
1830Check which package exists in the repository:
1931
20- - If ` packages/hardhat ` exists → ** Hardhat flavor** (follow Hardhat instructions)
21- - If ` packages/foundry ` exists → ** Foundry flavor** (follow Foundry instructions)
22-
32+ - If \ `packages/hardhat\ ` exists → **Hardhat flavor** (follow Hardhat instructions)
33+ - If \ `packages/foundry\ ` exists → **Foundry flavor** (follow Foundry instructions)
34+ ${ extraProjectOverview . filter ( Boolean ) . join ( "\n" ) }
2335## Common Commands
2436
2537Commands work the same for both flavors unless noted otherwise:
2638
27- `` `bash
39+ \`\`\ `bash
2840# Development workflow (run each in separate terminal)
2941yarn chain # Start local blockchain (Hardhat or Anvil)
3042yarn deploy # Deploy contracts to local network
@@ -50,65 +62,65 @@ yarn account # View current account info
5062yarn deploy --network <network> # e.g., sepolia, mainnet, base
5163
5264yarn vercel:yolo --prod # for deployment of frontend
53- `` `
65+ \`\`\ `
5466
5567## Architecture
5668
5769### Smart Contract Development
5870
5971#### Hardhat Flavor
6072
61- - Contracts: ` packages/hardhat/contracts/ `
62- - Deployment scripts: ` packages/hardhat/deploy/ ` (uses hardhat-deploy plugin)
63- - Tests: ` packages/hardhat/test/ `
64- - Config: ` packages/hardhat/hardhat.config.ts `
73+ - Contracts: \ `packages/hardhat/contracts/\ `
74+ - Deployment scripts: \ `packages/hardhat/deploy/\ ` (uses hardhat-deploy plugin)
75+ - Tests: \ `packages/hardhat/test/\ `
76+ - Config: \ `packages/hardhat/hardhat.config.ts\ `
6577- Deploying specific contract:
6678 - If the deploy script has:
67- `` `typescript
79+ \`\`\ `typescript
6880 // In packages/hardhat/deploy/01_deploy_my_contract.ts
6981 deployMyContract.tags = ["MyContract"];
70- `` `
71- - ` yarn deploy --tags MyContract `
82+ \`\`\ `
83+ - \ `yarn deploy --tags MyContract\ `
7284
7385#### Foundry Flavor
7486
75- - Contracts : ` packages/foundry/contracts/ `
76- - Deployment scripts : ` packages/foundry/script/ ` (uses custom deployment strategy )
77- - Example : ` packages/foundry/script/Deploy.s.sol ` and ` packages/foundry/script/DeployYourContract.s.sol `
78- - Tests : ` packages/foundry/test/ `
79- - Config : ` packages/foundry/foundry.toml `
87+ - Contracts: \ `packages/foundry/contracts/\ `
88+ - Deployment scripts: \ `packages/foundry/script/\ ` (uses custom deployment strategy)
89+ - Example: \ `packages/foundry/script/Deploy.s.sol\ ` and \ `packages/foundry/script/DeployYourContract.s.sol\ `
90+ - Tests: \ `packages/foundry/test/\ `
91+ - Config: \ `packages/foundry/foundry.toml\ `
8092- Deploying a specific contract:
81- - Create a separate deployment script and run ` yarn deploy --file DeployYourContract.s.sol `
93+ - Create a separate deployment script and run \ `yarn deploy --file DeployYourContract.s.sol\ `
8294
8395#### Both Flavors
8496
85- - After ` yarn deploy ` , ABIs are auto - generated to ` packages/nextjs/contracts/deployedContracts.ts `
97+ - After \ `yarn deploy\ `, ABIs are auto-generated to \ `packages/nextjs/contracts/deployedContracts.ts\ `
8698
8799### Frontend Contract Interaction
88100
89101**Correct interact hook names (use these):**
90102
91- - ` useScaffoldReadContract ` - NOT ~~ useScaffoldContractRead ~~
92- - ` useScaffoldWriteContract ` - NOT ~~ useScaffoldContractWrite ~~
103+ - \ `useScaffoldReadContract\ ` - NOT ~~useScaffoldContractRead~~
104+ - \ `useScaffoldWriteContract\ ` - NOT ~~useScaffoldContractWrite~~
93105
94- Contract data is read from two files in ` packages/nextjs/contracts/ ` :
106+ Contract data is read from two files in \ `packages/nextjs/contracts/\ `:
95107
96- - ` deployedContracts.ts ` : Auto - generated from deployments
97- - ` externalContracts.ts ` : Manually added external contracts
108+ - \ `deployedContracts.ts\ `: Auto-generated from deployments
109+ - \ `externalContracts.ts\ `: Manually added external contracts
98110
99111#### Reading Contract Data
100112
101- ` ` ` typescript
113+ \`\`\ `typescript
102114const { data: totalCounter } = useScaffoldReadContract({
103115 contractName: "YourContract",
104116 functionName: "userGreetingCounter",
105117 args: ["0xd8da6bf26964af9d7eed9e03e53415d37aa96045"],
106118});
107- ` ` `
119+ \`\`\ `
108120
109121#### Writing to Contracts
110122
111- ` ` ` typescript
123+ \`\`\ `typescript
112124const { writeContractAsync, isPending } = useScaffoldWriteContract({
113125 contractName: "YourContract",
114126});
@@ -118,102 +130,102 @@ await writeContractAsync({
118130 args: [newGreeting],
119131 value: parseEther("0.01"), // for payable functions
120132});
121- ` ` `
133+ \`\`\ `
122134
123135#### Reading Events
124136
125- ` ` ` typescript
137+ \`\`\ `typescript
126138const { data: events, isLoading } = useScaffoldEventHistory({
127139 contractName: "YourContract",
128140 eventName: "GreetingChange",
129141 watch: true,
130142 fromBlock: 31231n,
131143 blockData: true,
132144});
133- ` ` `
145+ \`\`\ `
134146
135- SE - 2 also provides other hooks to interact with blockchain data : ` useScaffoldWatchContractEvent ` , ` useScaffoldEventHistory ` , ` useDeployedContractInfo ` , ` useScaffoldContract ` , ` useTransactor ` .
147+ SE-2 also provides other hooks to interact with blockchain data: \ `useScaffoldWatchContractEvent\ `, \ `useScaffoldEventHistory\ `, \ `useDeployedContractInfo\ `, \ `useScaffoldContract\ `, \ `useTransactor\ `.
136148
137- ** IMPORTANT : Always use hooks from ` packages/nextjs/hooks/scaffold-eth ` for contract interactions . Always refer to the hook names as they exist in the codebase .**
149+ **IMPORTANT: Always use hooks from \ `packages/nextjs/hooks/scaffold-eth\ ` for contract interactions. Always refer to the hook names as they exist in the codebase.**
138150
139151### UI Components
140152
141- ** Always use ` @scaffold-ui/components ` library for web3 UI components :**
153+ **Always use \ `@scaffold-ui/components\ ` library for web3 UI components:**
142154
143- - ` Address ` : Display ETH addresses with ENS resolution , blockie avatars , and explorer links
144- - ` AddressInput ` : Input field with address validation and ENS resolution
145- - ` Balance ` : Show ETH balance in ether and USD
146- - ` EtherInput ` : Number input with ETH / USD conversion toggle
147- - ` IntegerInput ` : Integer - only input with wei conversion
155+ - \ `Address\ `: Display ETH addresses with ENS resolution, blockie avatars, and explorer links
156+ - \ `AddressInput\ `: Input field with address validation and ENS resolution
157+ - \ `Balance\ `: Show ETH balance in ether and USD
158+ - \ `EtherInput\ `: Number input with ETH/USD conversion toggle
159+ - \ `IntegerInput\ `: Integer-only input with wei conversion
148160
149161### Styling
150162
151163**Use DaisyUI classes** for building frontend components.
152164
153- ` ` ` tsx
165+ \`\`\ `tsx
154166// ✅ Good - using DaisyUI classes
155167<button className="btn btn-primary">Connect</button>
156168<div className="card bg-base-100 shadow-xl">...</div>
157169
158170// ❌ Avoid - raw Tailwind when DaisyUI has a component
159171<button className="px-4 py-2 bg-blue-500 text-white rounded">Connect</button>
160- ` ` `
172+ \`\`\ `
161173
162174### Configure Target Network before deploying to testnet / mainnet.
163175
164176#### Hardhat
165177
166- Add networks in ` packages/hardhat/hardhat.config.ts ` if not present .
178+ Add networks in \ `packages/hardhat/hardhat.config.ts\ ` if not present.
167179
168180#### Foundry
169181
170- Add RPC endpoints in ` packages/foundry/foundry.toml ` if not present .
182+ Add RPC endpoints in \ `packages/foundry/foundry.toml\ ` if not present.
171183
172184#### NextJs
173185
174- Add networks in ` packages/nextjs/scaffold.config.ts ` if not present . This file also contains configuration for polling interval , API keys . Remember to decrease the polling interval for L2 chains .
186+ Add networks in \ `packages/nextjs/scaffold.config.ts\ ` if not present. This file also contains configuration for polling interval, API keys. Remember to decrease the polling interval for L2 chains.
175187
176188## Code Style Guide
177189
178190### Identifiers
179191
180192| Style | Category |
181193| ---------------- | ---------------------------------------------------------------------------------------------------------------------- |
182- | ` UpperCamelCase ` | class / interface / type / enum / decorator / type parameters / component functions in TSX / JSXElement type parameter |
183- | `lowerCamelCase ` | variable / parameter / function / property / module alias |
184- | `CONSTANT_CASE ` | constant / enum / global variables |
185- | `snake_case ` | for hardhat deploy files and foundry script files |
194+ | \ `UpperCamelCase\ ` | class / interface / type / enum / decorator / type parameters / component functions in TSX / JSXElement type parameter |
195+ | \ `lowerCamelCase\ ` | variable / parameter / function / property / module alias |
196+ | \ `CONSTANT_CASE\ ` | constant / enum / global variables |
197+ | \ `snake_case\ ` | for hardhat deploy files and foundry script files |
186198
187199### Import Paths
188200
189- Use the `~~` path alias for imports in the nextjs package :
201+ Use the \ `~~\ ` path alias for imports in the nextjs package:
190202
191- `` `tsx
203+ \`\`\ `tsx
192204import { useTargetNetwork } from "~~/hooks/scaffold-eth";
193- `` `
205+ \`\`\ `
194206
195207### Creating Pages
196208
197- `` `tsx
209+ \`\`\ `tsx
198210import type { NextPage } from "next";
199211
200212const Home: NextPage = () => {
201213 return <div>Home</div>;
202214};
203215
204216export default Home;
205- `` `
217+ \`\`\ `
206218
207219### TypeScript Conventions
208220
209- - Use ` type ` over ` interface ` for custom types
210- - Types use ` UpperCamelCase ` without ` T ` prefix (use ` Address ` not ` TAddress ` )
221+ - Use \ `type\ ` over \ `interface\ ` for custom types
222+ - Types use \ `UpperCamelCase\ ` without \`T\ ` prefix (use \ `Address\ ` not \ `TAddress\ `)
211223- Avoid explicit typing when TypeScript can infer the type
212224
213225### Comments
214226
215227Make comments that add information. Avoid redundant JSDoc for simple functions.
216-
228+ ${ extraSections . filter ( Boolean ) . join ( "\n" ) }
217229## Documentation
218230
219231Use **Context7 MCP** tools to fetch up-to-date documentation for any library (Wagmi, Viem, RainbowKit, DaisyUI, Hardhat, Next.js, etc.). Context7 is configured as an MCP server and provides access to indexed documentation with code examples.
@@ -222,4 +234,12 @@ Use **Context7 MCP** tools to fetch up-to-date documentation for any library (Wa
222234
223235Use these specialized agents for specific tasks:
224236
225- - ** ` grumpy-carlos-code-reviewer ` ** : Use this agent for code reviews before finalizing changes
237+ - **\`grumpy-carlos-code-reviewer\`**: Use this agent for code reviews before finalizing changes
238+ ` ;
239+ } ;
240+
241+ export default withDefaults ( contents , {
242+ extraProjectOverview : "" ,
243+ extraSections : "" ,
244+ fullContentOverride : "" ,
245+ } ) ;
0 commit comments