Quick rules for AI agents working with this ICP + React + Vite template.
- Use
pnpmfor JS tasks; prefer small, focused edits and PRs. - Use generated canister bindings (
src/backend/declarations,src/frontend/declarations) for all canister calls. - Keep frontend build output in
src/frontend/dist(Vite config). - After
.didor Rust changes, regenerate bindings withdfx generate(ordfx deploy). - Run file-scoped checks/tests on changed files before proposing large changes.
- Do not hardcode canister IDs or secrets (use
.env/CANISTER_vars). - Do not add heavy dependencies without approval.
- Do not start/stop
dfxor run network deploys without explicit user permission.
- Type check single file:
pnpm exec tsc --noEmit path/to/file.tsx - Lint single file:
pnpm exec eslint --fix path/to/file.tsx - Format single file (if configured):
pnpm exec prettier --write path/to/file.tsx - Run a single test:
pnpm exec vitest run path/to/file.test.ts
- Install deps:
pnpm install - Full build:
pnpm run build - Start local replica (USER must run):
dfx start --background - Deploy canisters:
dfx deploy
- Allowed without prompt: read/list files; run file-scoped
tsc,eslint,vitest. - Ask first:
pnpm install,git push,dfx start,dfx deploy, deleting files, changing identities.
- Canisters & env:
dfx.json,.env - Backend:
src/backend/(Cargo.toml,backend.did,lib.rs,declarations/) - Frontend:
src/frontend/(routes/,routeTree.gen.ts,declarations/,dist/) - Vite config:
vite.config.ts(outDir, proxy to127.0.0.1:4943,CANISTER_/DFX_env) - Example canister usage:
src/frontend/hooks/use-greet.tsx(uses generatedbackendbinding)
- Good: use generated
backendbinding (declarations) in hooks/components. - Bad: raw fetch to hardcoded URLs or embedding canister IDs in code.
- File-scoped lint & type check: green
- Unit tests for new behavior: added/green
- Small, focused diff with a short summary
- Ask a clarifying question or propose a short plan/draft PR instead of guessing.
- For new features or regressions: add tests first, then implement until green.
Notes
- Key upgrades in this repo:
@dfinity/*→ v3,vite→ v7,ic-cdk→ 0.18.7. Regenerate bindings and runpnpm run buildwhen verifying changes.
If you want, I can (choose one):
- Add shell scripts for common tasks (
dev,build,deploy), - Add a short link to this file in
README.md, or - Make a minimal PR template / checklist file.