Grimoire CLI Skill
This skill is the base operating playbook for Grimoire.
When To Use
Use this skill when the task includes:
- install/setup of Grimoire tooling
- creating or editing
.spell files
- syntax questions about DSL capability
- advisory (
advise) authoring, debugging, and replay workflows
- setup/compile/validate/simulate/cast/resume workflows
- debugging spell compile/runtime failures
Mandatory Loading Rules
All references/ and docs/ paths below are relative to this skill directory (skills/grimoire/). These rules are required — they solve syntax coverage gaps that cause authoring errors.
STOP — read this first: Do NOT search the codebase, grep for syntax patterns, or rely on memory for DSL syntax. The reference files bundled with this skill are the single source of truth. IMMEDIATELY use the Read tool on the files listed below before writing or editing any spell content.
- For any
.spell authoring/editing task — IMMEDIATELY read these files using the Read tool before doing anything else:
references/syntax-capabilities.md
references/authoring-workflow.md
- For CLI flag details — IMMEDIATELY read using the Read tool:
references/cli-quick-reference.md
- For any advisory task (
advise, advisors, replay) — IMMEDIATELY read using the Read tool:
docs/how-to/use-advisory-decisions.md
docs/explanation/advisory-decision-flow.md
- For local fork preview workflows — IMMEDIATELY read using the Read tool:
references/anvil-cheatsheet.md
docs/how-to/simulate-on-anvil-fork.md
- For wallet setup and execution key flows — IMMEDIATELY read using the Read tool:
docs/how-to/use-wallet-commands-end-to-end.md
- For RPC/signer/transaction diagnostics — IMMEDIATELY read using the Read tool:
references/cast-cheatsheet.md
Installation Resolution
Select the first working invocation and reuse it for the session.
- Global:
npm i -g @grimoirelabs/cli
- command prefix:
grimoire
- No-install:
- command prefix:
npx -y @grimoirelabs/cli
- Repo-local:
- command prefix:
bun run packages/cli/src/index.ts --
If one path fails, move to the next path automatically.
If grimoire venue doctor ... fails with Unknown venue adapter "doctor", prefer repo-local invocation (bun run packages/cli/src/index.ts) or upgrade global CLI.
When using repo-local Bun execution, always keep the trailing -- so Bun forwards flags to Grimoire instead of consuming them.
Fast Start (Immediate Success Path)
Use this sequence before writing custom spells:
<grimoire-cmd> --help
<grimoire-cmd> setup (guided interactive execute onboarding)
<grimoire-cmd> validate spells/compute-only.spell
<grimoire-cmd> simulate spells/compute-only.spell --chain 1
If all three pass, proceed to spell authoring.
Setup security/runtime expectations:
- setup prompts for hidden passwords and never echoes input
- blank RPC input falls back to chain default public RPC
- setup may write
.grimoire/setup.env unless --no-save-password-env is used
- CLI auto-loads nearest
.grimoire/setup.env at startup without overriding existing env vars
Authoring and Execution Policy
- Read syntax references first (mandatory rule above).
- Author/update spell.
- Run
format to canonicalize layout before validation.
- Run
validate (use --strict for advisory-heavy spells).
- Fix errors/warnings and re-run until validation passes.
- Run
simulate.
- Before venue metadata queries or value-moving runs, execute
venue doctor for the target adapter/chain.
- Example:
<grimoire-cmd> venue doctor --adapter uniswap --chain 1 --rpc-url <rpc> --json
- Before value-moving runs on EVM venues, verify endpoint and signer state with Foundry Cast quickchecks (
chain-id, block-number, balance, nonce).
- Do not apply Anvil/Cast checks to offchain venues such as
hyperliquid.
- For advisory steps intended for deterministic execution, record and then use
--advisory-replay <runId> in dry-run/live cast.
- If spell includes irreversible actions, require
cast --dry-run before any live cast.
- Ask for explicit user confirmation before live value-moving
cast.
- For cross-chain mode, require explicit per-chain RPC mappings:
--rpc-url <sourceChainId>=<url>
--rpc-url <destinationChainId>=<url>
- For cross-chain Morpho actions, require explicit market mapping via:
--morpho-market-id <actionRef>=<marketId> (repeatable), or
--morpho-market-map <path>
- For Morpho supply-only strategies, prefer
vault_deposit / vault_withdraw (explicit vault address).
- If vault address is missing, list candidate vaults and require user to pick one; never auto-select.
- For Morpho market strategies (borrow/collateral/lend), require explicit
market_id and use explicit actions:
morpho_blue.supply_collateral(asset, amount, market_id)
morpho_blue.withdraw_collateral(asset, amount, market_id)
- Use bare
0x... address literals in action token fields; quoted address-like strings trigger QUOTED_ADDRESS_LITERAL.
- For Morpho doctor readiness checks, set wallet env explicitly (
GRIMOIRE_WALLET_ADDRESS preferred, fallback WALLET_ADDRESS).
- If a cross-chain run is left waiting, continue with
resume <runId> (use --watch to poll settlement).
- Never place passwords/private keys in agent prompts or inline command assignments.
- Prefer keystore +
--password-env over --private-key for dry-run/live casts.
- Treat
.grimoire/setup.env as plaintext secret material: keep local-only and rotate/remove when no longer needed.
- For commands run outside the project tree, set
GRIMOIRE_SETUP_ENV_FILE=/abs/path/to/.grimoire/setup.env when needed.
Command Surface (Core)
init
setup
format
compile
compile-all
validate
triggers
simulate
cast
venues
venue
venue doctor
history
log
resume
wallet (generate, address, balance, import, wrap, unwrap)
Use references/cli-quick-reference.md for concise command signatures and safety-critical flags.
Runtime Behavior Model
- One runtime semantics: preview first, commit only for execute paths.
simulate and cast --dry-run are preview-only flows.
- Live
cast can commit irreversible actions when policy and runtime checks pass.
simulate supports explicit --rpc-url, with precedence: --rpc-url -> RPC_URL_<chainId> -> RPC_URL.
- Phase 1 cross-chain execution uses two-spell orchestration (
--destination-spell) with one logical run id and resume support.
- Use
triggers <spell> to discover stable handler ids natively before targeted execution.
simulate and cast support selected-trigger execution via --trigger-id, --trigger-index, and legacy --trigger.
- For multi-handler spells, prefer
--trigger-id; --trigger is label-based and can be ambiguous.
- Cross-chain
simulate / cast must forward the same selected trigger into per-chain execution.
- In
--json mode, parse stdout only; progress and spinner output can still appear on stderr.
Query Functions (price / balance / apy / metric)
Always prefer query functions over advisory for structured data fetching. These are deterministic, fast, and don't require LLM calls.
price(BASE, QUOTE[, SOURCE]) — live token price via query provider (requires Alchemy RPC URL)
balance(ASSET[, ADDRESS]) — on-chain token balance via RPC (any RPC URL)
apy(VENUE, ASSET[, SELECTOR]) — venue-backed APY surface (for example Aave and Morpho)
metric(SURFACE, VENUE[, ASSET[, SELECTOR]]) — generic protocol metric surface
- Selector guidance:
- market/vault id selector:
apy(morpho, USDC, "wbtc-usdc-86")
- vault selector (Morpho):
metric("vault_net_apy", morpho, USDC, "vault=0xVaultAddress")
- Morpho
vault_apy / vault_net_apy require explicit selector; do not rely on implicit defaults.
- key/value selector:
metric("quote_out", uni_v3, USDC, "asset_out=WETH,amount=1000000,fee_tier=3000")
- Never use an advisory (
advise) just to fetch prices, balances, APYs, or other structured metrics
Use advisory only when the task requires LLM judgment, reasoning, or interpretation.
Advisory Operating Rules
- Advisory must be explicit statement form:
x = advise advisor: "prompt" { ... }.
- Treat advisory outputs as typed contracts; enforce schema with
output.
- Require
timeout and fallback in every advisory block.
- Prefer
validate --strict when advisory logic gates value-moving actions.
- Use replay for determinism when moving from preview/dry-run to live execution.
- For runtime debugging, use
--advisory-trace-verbose (non-JSON mode) to stream detailed advisory traces.
Venue Metadata and Snapshots
Use venue skills for snapshot parameters and market metadata:
grimoire-aave
grimoire-uniswap
grimoire-morpho-blue
grimoire-hyperliquid
grimoire-pendle
grimoire-polymarket
Formatting policy for venue CLI output:
- prefer
--format json for automation or nested payloads
- use
--format table for human-readable summaries
References
references/syntax-capabilities.md
references/authoring-workflow.md
references/anvil-cheatsheet.md
references/cast-cheatsheet.md
references/cli-quick-reference.md
docs/how-to/simulate-on-anvil-fork.md
docs/how-to/use-wallet-commands-end-to-end.md
docs/how-to/use-advisory-decisions.md
docs/how-to/compare-protocol-metrics.md
docs/explanation/advisory-decision-flow.md
docs/reference/cli.md
docs/reference/spell-syntax.md
docs/reference/grimoire-dsl-spec.md
docs/reference/compiler-runtime.md
1---
2name: grimoire
3description: Install and operate Grimoire, author .spell files with full syntax coverage (including advisory decision logic), and run compile/validate/simulate/cast safely. Use when users ask to create, edit, debug, validate, simulate, execute, or explain Grimoire strategies.
4compatibility: "Requires one of: global grimoire CLI, npx access to @grimoirelabs/cli, or repo-local Bun execution."
5metadata:
6 source: https://skillmd.com/skills/om-scogo/grimoire
7 version: "2.6"
8 focus: "installation usage syntax advisory execution"
9---
10
11# Grimoire CLI Skill
12
13This skill is the base operating playbook for Grimoire.
14
15## When To Use
16
17Use this skill when the task includes:
18
19- install/setup of Grimoire tooling
20- creating or editing `.spell` files
21- syntax questions about DSL capability
22- advisory (`advise`) authoring, debugging, and replay workflows
23- setup/compile/validate/simulate/cast/resume workflows
24- debugging spell compile/runtime failures
25
26## Mandatory Loading Rules
27
28All `references/` and `docs/` paths below are relative to this skill directory (`skills/grimoire/`). These rules are **required** — they solve syntax coverage gaps that cause authoring errors.
29
30**STOP — read this first:** Do NOT search the codebase, grep for syntax patterns, or rely on memory for DSL syntax. The reference files bundled with this skill are the single source of truth. IMMEDIATELY use the Read tool on the files listed below before writing or editing any spell content.
31
321. For any `.spell` authoring/editing task — IMMEDIATELY read these files using the Read tool before doing anything else:
33 - `references/syntax-capabilities.md`
34 - `references/authoring-workflow.md`
352. For CLI flag details — IMMEDIATELY read using the Read tool:
36 - `references/cli-quick-reference.md`
373. For any advisory task (`advise`, `advisors`, replay) — IMMEDIATELY read using the Read tool:
38 - `docs/how-to/use-advisory-decisions.md`
39 - `docs/explanation/advisory-decision-flow.md`
404. For local fork preview workflows — IMMEDIATELY read using the Read tool:
41 - `references/anvil-cheatsheet.md`
42 - `docs/how-to/simulate-on-anvil-fork.md`
435. For wallet setup and execution key flows — IMMEDIATELY read using the Read tool:
44 - `docs/how-to/use-wallet-commands-end-to-end.md`
456. For RPC/signer/transaction diagnostics — IMMEDIATELY read using the Read tool:
46 - `references/cast-cheatsheet.md`
47
48## Installation Resolution
49
50Select the first working invocation and reuse it for the session.
51
521. Global:
53 - `npm i -g @grimoirelabs/cli`
54 - command prefix: `grimoire`
552. No-install:
56 - command prefix: `npx -y @grimoirelabs/cli`
573. Repo-local:
58 - command prefix: `bun run packages/cli/src/index.ts --`
59
60If one path fails, move to the next path automatically.
61
62If `grimoire venue doctor ...` fails with `Unknown venue adapter "doctor"`, prefer repo-local invocation (`bun run packages/cli/src/index.ts`) or upgrade global CLI.
63
64When using repo-local Bun execution, always keep the trailing `--` so Bun forwards flags to Grimoire instead of consuming them.
65
66## Fast Start (Immediate Success Path)
67
68Use this sequence before writing custom spells:
69
701. `<grimoire-cmd> --help`
712. `<grimoire-cmd> setup` (guided interactive execute onboarding)
723. `<grimoire-cmd> validate spells/compute-only.spell`
734. `<grimoire-cmd> simulate spells/compute-only.spell --chain 1`
74
75If all three pass, proceed to spell authoring.
76
77Setup security/runtime expectations:
78
79- setup prompts for hidden passwords and never echoes input
80- blank RPC input falls back to chain default public RPC
81- setup may write `.grimoire/setup.env` unless `--no-save-password-env` is used
82- CLI auto-loads nearest `.grimoire/setup.env` at startup without overriding existing env vars
83
84## Authoring and Execution Policy
85
861. Read syntax references first (mandatory rule above).
872. Author/update spell.
883. Run `format` to canonicalize layout before validation.
894. Run `validate` (use `--strict` for advisory-heavy spells).
905. Fix errors/warnings and re-run until validation passes.
916. Run `simulate`.
927. Before venue metadata queries or value-moving runs, execute `venue doctor` for the target adapter/chain.
93 - Example: `<grimoire-cmd> venue doctor --adapter uniswap --chain 1 --rpc-url <rpc> --json`
948. Before value-moving runs on EVM venues, verify endpoint and signer state with Foundry Cast quickchecks (`chain-id`, `block-number`, `balance`, `nonce`).
95 - Do not apply Anvil/Cast checks to offchain venues such as `hyperliquid`.
969. For advisory steps intended for deterministic execution, record and then use `--advisory-replay <runId>` in dry-run/live cast.
9710. If spell includes irreversible actions, require `cast --dry-run` before any live cast.
9811. Ask for explicit user confirmation before live value-moving `cast`.
9912. For cross-chain mode, require explicit per-chain RPC mappings:
100 - `--rpc-url <sourceChainId>=<url>`
101 - `--rpc-url <destinationChainId>=<url>`
10213. For cross-chain Morpho actions, require explicit market mapping via:
103 - `--morpho-market-id <actionRef>=<marketId>` (repeatable), or
104 - `--morpho-market-map <path>`
10514. For Morpho supply-only strategies, prefer `vault_deposit` / `vault_withdraw` (explicit vault address).
106 - If vault address is missing, list candidate vaults and require user to pick one; never auto-select.
10715. For Morpho market strategies (borrow/collateral/lend), require explicit `market_id` and use explicit actions:
108 - `morpho_blue.supply_collateral(asset, amount, market_id)`
109 - `morpho_blue.withdraw_collateral(asset, amount, market_id)`
11016. Use bare `0x...` address literals in action token fields; quoted address-like strings trigger `QUOTED_ADDRESS_LITERAL`.
11117. For Morpho doctor readiness checks, set wallet env explicitly (`GRIMOIRE_WALLET_ADDRESS` preferred, fallback `WALLET_ADDRESS`).
11218. If a cross-chain run is left waiting, continue with `resume <runId>` (use `--watch` to poll settlement).
11319. Never place passwords/private keys in agent prompts or inline command assignments.
11420. Prefer keystore + `--password-env` over `--private-key` for dry-run/live casts.
11521. Treat `.grimoire/setup.env` as plaintext secret material: keep local-only and rotate/remove when no longer needed.
11622. For commands run outside the project tree, set `GRIMOIRE_SETUP_ENV_FILE=/abs/path/to/.grimoire/setup.env` when needed.
117
118## Command Surface (Core)
119
120- `init`
121- `setup`
122- `format`
123- `compile`
124- `compile-all`
125- `validate`
126- `triggers`
127- `simulate`
128- `cast`
129- `venues`
130- `venue`
131- `venue doctor`
132- `history`
133- `log`
134- `resume`
135- `wallet` (`generate`, `address`, `balance`, `import`, `wrap`, `unwrap`)
136
137Use `references/cli-quick-reference.md` for concise command signatures and safety-critical flags.
138
139## Runtime Behavior Model
140
141- One runtime semantics: preview first, commit only for execute paths.
142- `simulate` and `cast --dry-run` are preview-only flows.
143- Live `cast` can commit irreversible actions when policy and runtime checks pass.
144- `simulate` supports explicit `--rpc-url`, with precedence: `--rpc-url` -> `RPC_URL_<chainId>` -> `RPC_URL`.
145- Phase 1 cross-chain execution uses two-spell orchestration (`--destination-spell`) with one logical run id and resume support.
146- Use `triggers <spell>` to discover stable handler ids natively before targeted execution.
147- `simulate` and `cast` support selected-trigger execution via `--trigger-id`, `--trigger-index`, and legacy `--trigger`.
148- For multi-handler spells, prefer `--trigger-id`; `--trigger` is label-based and can be ambiguous.
149- Cross-chain `simulate` / `cast` must forward the same selected trigger into per-chain execution.
150- In `--json` mode, parse stdout only; progress and spinner output can still appear on stderr.
151
152## Query Functions (price / balance / apy / metric)
153
154**Always prefer query functions over advisory for structured data fetching.** These are deterministic, fast, and don't require LLM calls.
155
156- `price(BASE, QUOTE[, SOURCE])` — live token price via query provider (requires Alchemy RPC URL)
157- `balance(ASSET[, ADDRESS])` — on-chain token balance via RPC (any RPC URL)
158- `apy(VENUE, ASSET[, SELECTOR])` — venue-backed APY surface (for example Aave and Morpho)
159- `metric(SURFACE, VENUE[, ASSET[, SELECTOR]])` — generic protocol metric surface
160- Selector guidance:
161- market/vault id selector: `apy(morpho, USDC, "wbtc-usdc-86")`
162- vault selector (Morpho): `metric("vault_net_apy", morpho, USDC, "vault=0xVaultAddress")`
163- Morpho `vault_apy` / `vault_net_apy` require explicit selector; do not rely on implicit defaults.
164- key/value selector: `metric("quote_out", uni_v3, USDC, "asset_out=WETH,amount=1000000,fee_tier=3000")`
165- Never use an advisory (`advise`) just to fetch prices, balances, APYs, or other structured metrics
166
167Use advisory only when the task requires LLM judgment, reasoning, or interpretation.
168
169## Advisory Operating Rules
170
171- Advisory must be explicit statement form: `x = advise advisor: "prompt" { ... }`.
172- Treat advisory outputs as typed contracts; enforce schema with `output`.
173- Require `timeout` and `fallback` in every advisory block.
174- Prefer `validate --strict` when advisory logic gates value-moving actions.
175- Use replay for determinism when moving from preview/dry-run to live execution.
176- For runtime debugging, use `--advisory-trace-verbose` (non-JSON mode) to stream detailed advisory traces.
177
178## Venue Metadata and Snapshots
179
180Use venue skills for snapshot parameters and market metadata:
181
182- `grimoire-aave`
183- `grimoire-uniswap`
184- `grimoire-morpho-blue`
185- `grimoire-hyperliquid`
186- `grimoire-pendle`
187- `grimoire-polymarket`
188
189Formatting policy for venue CLI output:
190
191- prefer `--format json` for automation or nested payloads
192- use `--format table` for human-readable summaries
193
194## References
195
196- `references/syntax-capabilities.md`
197- `references/authoring-workflow.md`
198- `references/anvil-cheatsheet.md`
199- `references/cast-cheatsheet.md`
200- `references/cli-quick-reference.md`
201- `docs/how-to/simulate-on-anvil-fork.md`
202- `docs/how-to/use-wallet-commands-end-to-end.md`
203- `docs/how-to/use-advisory-decisions.md`
204- `docs/how-to/compare-protocol-metrics.md`
205- `docs/explanation/advisory-decision-flow.md`
206- `docs/reference/cli.md`
207- `docs/reference/spell-syntax.md`
208- `docs/reference/grimoire-dsl-spec.md`
209- `docs/reference/compiler-runtime.md`