---
name: xahau-hooks-dev
description: Design, write, build, test, review, debug, deploy, and upgrade C/WASM Hooks on Xahau, including direct RPC state reads, transaction-based writes, and optional explorer ABI/manifest preparation. Use for Hook C safety, guards, binary state layouts, emitted transactions, callbacks, and deployment failures. Includes guidance for developers new to C; excludes building application SDKs and indexers.
metadata:
  version: "1.6.1"
title: xahau-hooks-dev
canonical_url: https://skilld.dev/gh/xrpdomains/xahau-hooks-dev
last_updated: 2026-11-01T12:11:28.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> 128 supporting files sit beside this SKILL.md. When the Skill refers to one, fetch https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/PATH with PATH replaced.
>
> If the user asked to install this Skill, run `npx skilld install xrpdomains/xahau-hooks-dev/xahau-hooks-dev`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/xahau-hooks-dev`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/xrpdomains/xahau-hooks-dev/xahau-hooks-dev) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/xahau-hooks-dev`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/xahau-hooks-dev --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/xahau-hooks-dev --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# 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](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/environment-setup.md#source-only-mode-no-compiler-required), or the [prebuilt minimal sample](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/assets/examples/prebuilt/README.md) 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](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/agent-workflow.md#agents-in-sandboxed-environments); 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](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/compatibility.md) 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](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/architecture.md) |
| First working build/install/write/readback | [Quickstart](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/QUICKSTART.md) |
| Windows PowerShell, Cursor discovery, first local build + guard | [First Hook on Windows](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/windows-first-hook.md) |
| Cached testnet wallet, custom Invoke, UTF-8 reports or configured pipeline | [Agent workflow](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/agent-workflow.md) |
| No Node/npm, missing dependencies, restricted/offline machine | [Environment setup](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/environment-setup.md) |
| Missing compiler/cleaner/checker; npm, Docker or WSL setup | [Toolchain setup](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/toolchain-setup.md) |
| C beginner, pointer/length, overflow, byte handling | [C essentials](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/c-essentials.md) |
| Hook API return values, invocation, accept/rollback, slots | [Runtime and API contracts](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/runtime.md) |
| Compiler, guards, memory, block nesting, performance | [Build and resources](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/build.md) |
| Key derivation, binary layout, deletion, migration | [State](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/state.md) |
| Emission, callback, pending, failure and recovery | [Emit and recovery](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/emit.md) |
| RPC reads, Invoke/Payment writes, result interpretation | [Read and write](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/read-write.md) |
| SetHook, bootstrap, smoke, state-preserving upgrade | [Deployment](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/deployment.md) |
| Activation masks and directional fields | [HookOn](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/hookon.md) |
| Testnet funding, fee quotes, reserve, mainnet boundaries | [Funding and fees](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/funding-and-fees.md) |
| NFT/URIToken or issued-currency issuer policy and readback | [Issuer examples](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/issuer-examples.md) |
| First-run failure symptoms | [First-run errors](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/first-run-errors.md) |
| Audit, regression, fault injection, error investigation | [Testing and debugging](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/testing.md) |
| Offline WASM fixtures, schema codecs, generated unsigned Invoke, guard diagnostics | [Offline framework](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/offline-framework.md) |
| Explorer-readable HookState ABI/manifest, exact-once projections and publication handoff | [Optional explorer ABI](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/explorer-abi.md) |
| Runtime-pinned emitted Payment, callback, confirmed-failure retry | [Auto-forward walkthrough](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/auto-forward.md) |

For a beginner, start with C essentials and the minimal examples in [examples](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/assets/examples/README.md). 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 `reason` is 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-only` reports 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](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/environment-setup.md).
- `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](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/testing.md).
- `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.mjs` uses 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 FILE` or `--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 saved `tx` response 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.mjs` and `scripts/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](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/toolchain-setup.md). 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](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/assets/README.md). 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](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/deployment.md#project-submitter-template). For strings/URLs, use the [variable-length state example](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/state.md#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](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/references/agent-workflow.md). 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](https://skilld.dev/api/skills-raw/xrpdomains/xahau-hooks-dev/xahau-hooks-dev/assets/report-template.md). 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.
