Xahau Hooks development
Work within the requested project and operation. Inspect its instructions, authoritative protocol, source, tests, build pipeline, and deployment evidence first. Preserve the user's authorized scope: using this skill does not authorize a network deployment, signing, source rewrite, or external publication.
Quick path for agents without native skill discovery
For Grok or another file/terminal-enabled host, read this file directly; no special installation directory is required. Load one task reference first, then expand as needed: C essentials for pointer/length review, State for codecs, Environment setup for missing tools. A useful request is: Read SKILL.md. Review hook.c for pointer/length safety and guard budget. Do not deploy. Report findings with evidence.
Start with node scripts/doctor.mjs --source-only. Local-only helpers include lint-source.mjs, hookon.mjs, fixed-layout decoding and schema codecs. init-project.mjs creates a fresh scaffold when requested; unsigned preparation writes drafts without signing or RPC. Source review and planning do not require a compiler. See source-only commands and readiness, or the prebuilt minimal sample for compiler-free artifact inspection. Keep compile/guard NOT_RUN for the user's source until actually executed; sample producer evidence does not verify modified project code.
Agents in sandboxed environments
Cowork, Claude Code and other agent hosts may run in containers/VMs with an outbound allowlist: npm/GitHub can work while the intended RPC or faucet (for example xahau-test.net) is unreachable. Check the actual host restrictions and bounded connection result; do not spend repeated turns retrying a denied endpoint or label it a Hook defect. With available local dependencies, continue lint/source review, tests, production WASM build/guard and unsigned transaction/contract preparation. If downloads are also blocked, use trusted existing tools with recorded provenance or mark the missing stage NOT_RUN.
For live steps, hand off the exact artifact, hashes, inspection evidence, public network/account configuration, reviewed project contract and unsigned transactions to an authorized machine with node access and a funded disposable wallet. Keep seeds/private caches on the signing machine. “One command” covers configured local build/guard/review; live deploy additionally requires connectivity, funding, project assertions and submission authorization. Follow sandbox and connected-machine handoff; report network stages BLOCKED/NOT_RUN until actual validated evidence is returned.
Establish the target
Record network identity, node/API capabilities, enabled amendments, headers, compiler/optimizer/cleaner versions, validator revision, and final artifact hash. Treat RPC URLs and protocol limits as configuration, not universal constants. Read compatibility and sources when selecting tools or resolving conflicting documentation.
Distinguish protocol requirements, project conventions, and locally observed workarounds. Never turn a workaround from one compiler or application into a universal rule.
Route by task
Read only relevant references:
| Task | Reference |
|---|---|
| New project, operations, authorization, state machine | Architecture |
| First working build/install/write/readback | Quickstart |
| Windows PowerShell, Cursor discovery, first local build + guard | First Hook on Windows |
| Cached testnet wallet, custom Invoke, UTF-8 reports or configured pipeline | Agent workflow |
| No Node/npm, missing dependencies, restricted/offline machine | Environment setup |
| Missing compiler/cleaner/checker; npm, Docker or WSL setup | Toolchain setup |
| C beginner, pointer/length, overflow, byte handling | C essentials |
| Hook API return values, invocation, accept/rollback, slots | Runtime and API contracts |
| Compiler, guards, memory, block nesting, performance | Build and resources |
| Key derivation, binary layout, deletion, migration | State |
| Emission, callback, pending, failure and recovery | Emit and recovery |
| RPC reads, Invoke/Payment writes, result interpretation | Read and write |
| SetHook, bootstrap, smoke, state-preserving upgrade | Deployment |
| Activation masks and directional fields | HookOn |
| Testnet funding, fee quotes, reserve, mainnet boundaries | Funding and fees |
| NFT/URIToken or issued-currency issuer policy and readback | Issuer examples |
| First-run failure symptoms | First-run errors |
| Audit, regression, fault injection, error investigation | Testing and debugging |
| Offline WASM fixtures, schema codecs, generated unsigned Invoke, guard diagnostics | Offline framework |
| Explorer-readable HookState ABI/manifest, exact-once projections and publication handoff | Optional explorer ABI |
| Runtime-pinned emitted Payment, callback, confirmed-failure retry | Auto-forward walkthrough |
For a beginner, start with C essentials and the minimal examples in examples. Explain the relevant C concept alongside each fix; avoid an unrelated C course.
Essential invariants
- Account for every pointer's capacity and every API's returned byte count. An error must never become an unsigned length. Validate input before irreversible workflow transitions.
- Define byte order, lengths, units, key preimages, and schema versions explicitly. Check every significant state write and deletion; distinguish not-found from other failures.
- Derive guard budgets from worst-case invocation counts including helper reuse. Validate the cleaned production WASM; probe exports and mocked hosts are not production validation. Do not weaken the checker or inflate guards to hide a failure.
- Only use exports, imports, helper calls, and APIs accepted by the selected validator and network. Adding WASM helper exports is not a default solution to excessive inlining.
- Model originating transaction, emitted transaction, callback, and business completion separately. Inspect the actual runtime's callback contract; do not assume
reasonis an engine result or that an ordinary transaction slot contains result metadata. - Resolve asset rights from protocol semantics. An issuer's ledger-level authority can differ from application ownership. State checks alone may not constrain transactions that never trigger the hook.
- A lost connection after submission is an unknown outcome, not permission to replay a payment. Recover by transaction hash and ledger evidence.
Deterministic helpers
Node.js 20+; core scripts have no third-party dependencies. The optional compiler and signing/WebSocket references have separate pinned npm locks; install them only for those tasks. Run commands with --help after installing a reference's required dependencies.
scripts/doctor.mjs:--source-onlyreports Node-based source readiness without subprocesses or dependency/native probes; unexamined compile tools are null/NOT_CHECKED. Full mode reports npm, local compilers and optional dependency metadata; WSL probes only with--wsl DISTRO, Docker daemon only with--docker. Prerequisite readiness is not build/validation evidence. Follow environment setup.scripts/lint-source.mjs: lexical C review hints for discarded API results, direct unsigned API conversions and loops without recognized local guards. No preprocessing, type or control-flow proof; no findings is not an audit PASS. See testing.scripts/mock-hook.mjs: worker-isolated offline WASM fixtures with bounded memory, timeout, state overlay, guards and fault injection. Unsupported imports fail; prepare/emit are explicit fixture adapters, callback tests do not simulate native weak semantics.scripts/generate-client.mjs: package-specific schema v1 -> standalone byte codec and unsigned Invoke builder. No RPC/signing; independently verify schema against C, version and production artifact hash. This narrow helper does not extend scope to application SDK development.scripts/profile-guards.mjs: source budgets/lines, input-specific mock visits and optional real checker totals. No exact per-loop instruction cost or automatic guard reduction.scripts/export-explorer-abi.mjs: export supported fixed state layouts from our interface schema to optional XahauWin projections/manifest drafts.scripts/check-explorer-abi.mjsuses a separately installed pinned upstream decoder to check exact-once coverage and expected values. Inventory all state writers/namespaces, verify endian/padding and actual HookHash, and keep synthetic/offline/published evidence separate; no automatic publication.scripts/init-project.mjs: create a new project source layout from the teaching example and contract template; refuse an existing destination. Does not install tools or create a deployment.scripts/inspect-artifact.mjs: WASM structure, exact imports/exports policy, byte budget, SHA-256; optionally execute a supplied guard checker without a shell. Does not implement a replacement guard checker.scripts/decode-state.mjs: validate a fixed binary layout and decode bytes/BE unsigned integers. Does not discover unknown state keys or verify project C layouts automatically.scripts/read-state.mjs: read-only HTTP JSON-RPC via--config FILEor--endpoint URL --network-id ID; verify network ID, pin a validated ledger, paginate a namespace, reject repeated markers. Never signs or submits.scripts/summarize-tx.mjs: summarize a savedtxresponse with validated status and HookExecutions. Does not infer completion of emitted workflows.scripts/hookon.mjs: calculate masks with the active-high SetHook exception; validate directional field combinations for HookOnV2_1.scripts/setup-guard.mjs: download/checksum pinned checker sources, then build using the existing C++ compiler or explicit WSL distribution.scripts/prepare-sethook.mjsandscripts/prepare-setting.mjs: generate offline unsigned first-install/example-write transactions.scripts/agent-pipeline.mjs: lint, explicit tests, compile and guard-check with evidence; optionally perform a fresh testnet install and self-Invoke/readback using a reviewed JSON contract. Offline by default; never invent an arbitrary hook's smoke input or replay an existing work directory.
For beginner builds use assets/toolchain/compile.mjs and setup. Optional assets/examples/deploy/ provides a restricted testnet signer and WebSocket state reader, not a project SDK. Its signing path refuses mainnet, existing-hook replacement, deletion flags and unrelated writes; it needs explicit submit authorization, fee cap and new journal. Never silently expand it to deploy an existing multi-hook application. Core read-only tools may read an explicitly configured mainnet; local doctor has no RPC target.
Policy/layout examples are under assets. Require explicit project-specific values; the supplied artifact policy is only for the minimal pass-through example.
For application writes beyond the teaching setting, adapt the separate project Invoke submitter. For strings/URLs, use the variable-length state example and native round-trip template. These examples need project protocol checks and do not certify application correctness.
For arbitrary codec-valid Invoke payloads use the generic Invoke path. Self-Invoke omits Destination. Load existing testnet seeds with the wrapper that checks algorithm/address. Use CLI --out for JSON reports rather than shell redirection; directory-generating commands retain their directory --out semantics.
Evidence and completion
Use the report template. Label static inspection, native helper tests, mocked WASM probes, node validation, live validated transactions, and failure recovery separately. Record commands, versions, artifact hashes, and untested paths. Compile or static PASS never means production readiness.
For a fix, reproduce the narrow failure, patch its cause, run meaningful regressions, and report remaining limits. For deploy, stop on an unexplained compile/checker/SetHook/bootstrap failure instead of continuing with an uncertain artifact. Resume only after the cause is understood and the task still authorizes it. Never silently retry a fee-bearing submission.