You are working on PolicyVault, a bounded ERC-20 spending MVP for wallet and service-style charging flows.
Read this file before doing any work. For non-trivial work, also read SPEC.md, PLANS.md, plans/ROADMAP.md, and the active ExecPlan in plans/.
-
Prefer modular code.
Keep interfaces, core state logic, UI components, and scripts separated. Do not collapse unrelated concerns into one file. -
Use an ExecPlan for meaningful work.
If the task spans multiple files or is likely to take more than 45 minutes, create or update an ExecPlan first. FollowPLANS.mdexactly.
2a. Invoke the right skill bundle up front.
For any non-trivial thread, use the relevant bundle from .agents/skills/README.md so scope, tests, docs, and chain boundaries stay explicit.
-
Preserve repo boundaries.
contracts/: Solidity contracts and interfaces onlytest/: contract tests onlyscripts/: deploy, seed, demo, and ABI sync tooling onlyapp/src/components: UI panels and presentationapp/src/lib: chain config, ABI wiring, formatting, and client helpersdocs/: architecture, operations, and decisionsplans/: executable plans and roadmap
-
Keep the contract easy to explain.
If a design choice makes the interview story worse, cut it or defer it. -
State changes require tests.
Every new state-changing behavior must have at least one happy-path test and one failure-path test. -
Token movement must be explicit and safe.
UseSafeERC20, keep checks-effects-interactions ordering, and useReentrancyGuardon external mutating functions. -
No hidden policy.
If a workflow rule matters, encode it in code,SPEC.md,WORKFLOW.md, or a plan. -
Simulate before write.
Scripts and UI interactions should use transaction simulation before sending writes where practical. -
Narrow scope beats diluted scope.
Prefer one strong vertical slice over three half-built features. -
Keep repo hygiene explicit.
Never commit generated artifacts, local env files,.next,artifacts, orcache.
A milestone is not done until all of the following are true:
- code exists in the right module boundaries
- tests exist for the touched behavior
- the relevant docs are updated if behavior changed
- the active ExecPlan progress section is updated
- there is an explicit acceptance check a human can run
- event emission is documented for user-visible state changes
Use these patterns by default:
interfaces/for public Solidity contracts and event / error contracts- small internal helpers in the main contract instead of giant functions
scripts/helpers/for script formatting and reusable helperscomponents/for UI cards and formslib/for ABI/config/client helpersdocs/architecture/for system reasoningdocs/ops/for commands, demo flow, and runbooks
- Solidity
0.8.34 - OpenZeppelin Contracts
SafeERC20ReentrancyGuard- custom errors
uint128packing forcapandspent- viem for scripts and frontend interaction
- wagmi for the frontend wallet flow
- minimal but clean styling
- deterministic, readable console output in scripts
Skills live in .agents/skills.
Read .agents/skills/README.md before starting a non-trivial thread.
Core skills already included in the base scaffold:
$execplan-orchestratorfor any multi-file milestone$modular-architecture-guardwhen implementing or refactoring$solidity-security-guardfor any token transfer or policy logic$demo-proof-auditorwhen shipping the demo script, README, or screenshots
Additional skills added for tighter Codex behavior:
$scope-lock-enforcerto prevent milestone drift$hardhat-test-first-driverto keep contract work driven by focused tests$policy-state-machine-guardto protect vault and policy invariants$abi-surface-sync-guardwhen the public contract surface changes$viem-wagmi-integration-guardfor scripts, ABI wiring, and UI chain interaction$permit-path-guardfordepositWithPermit$interview-readability-guardto optimize the code for technical explanation$docs-runbook-keeperto keep the demo and docs truthful
-
Contract core (
M1.1toM1.4):
$execplan-orchestrator $scope-lock-enforcer $modular-architecture-guard $solidity-security-guard $hardhat-test-first-driver $policy-state-machine-guard $interview-readability-guard -
Permit (
M2.1):
$execplan-orchestrator $scope-lock-enforcer $modular-architecture-guard $solidity-security-guard $hardhat-test-first-driver $policy-state-machine-guard $permit-path-guard $abi-surface-sync-guard $interview-readability-guard -
Scripts and ABI (
M2.2):
$execplan-orchestrator $scope-lock-enforcer $modular-architecture-guard $abi-surface-sync-guard $viem-wagmi-integration-guard $demo-proof-auditor $docs-runbook-keeper -
UI (
M2.3):
$execplan-orchestrator $scope-lock-enforcer $modular-architecture-guard $viem-wagmi-integration-guard $interview-readability-guard $demo-proof-auditor $docs-runbook-keeper
Avoid these unless an ExecPlan explicitly approves them:
- adding proxy or upgrade logic
- adding admin roles "just in case"
- multi-token support in v1
- off-chain authorizations before the on-chain policy model is green
- route or UI files containing contract ABI hand-edit churn across multiple places
- skipping event assertions
- burying important trade-offs in chat instead of checked-in docs
At each stopping point:
- update the active ExecPlan
Progresssection - record any design changes in the
Decision Log - mention exactly what remains
- mention the exact next submilestone
The first compelling proof point is not visual polish.
It is this:
a user deposits
MockUSDC, creates a bounded policy, a beneficiary charges within the cap, the policy can be revoked, unused funds can be withdrawn, and the full flow is supported by tests, scripts, and explainable events.