# quire-cli
[](https://discord.gg/k8DVhuYBR2) [](https://github.com/agent-ix/agent-plugins)
[](https://github.com/agent-ix/quire-spec-language)
`quire-cli` is a static command-line wrapper around
[`quire-rs`](https://github.com/agent-ix/quire-rs). It gives agents and
humans one fast binary for parsing, extracting, looking up, editing,
validating, inspecting the input contract of Markdown artifacts, and exporting
source-grounded assurance facts.
validating, inspecting Markdown contracts, and evaluating module-supplied
clause sets.
The crate is intentionally a thin process boundary: Markdown parsing,
extraction, and structural validation live in `quire-rs`.
## Setup
If this plugin is uninitialized or a command fails, follow the [plugin setup guide](setup.md) for its required CLIs, configuration, and local diagnosis.
## Community help
If the setup checks leave a reproducible Agent IX quire-cli bug that blocks progress, [join the Agent IX Discord](https://discord.gg/k8DVhuYBR2). Community help is a last resort for Agent IX product bugs, not a help desk for local credentials, machine setup, third party tools, or unrelated projects. See [setup.md](setup.md#community-help) for what to include.
## Commands
```bash
quire assurance --scope --module --repository \
--revision --expect-module \
[--expect-schema ]...
quire check-lock ...
quire parse
quire lookup (--heading [--level <1..6>] | --id | --block-id ) [--content]
quire edit (--heading | --block-id ) --content [--out ]
quire extract --module [--archetype ]
quire validate ... [--scope ] [--module ] [--archetype ]
quire validate --okf [--scope ] [--module ]
quire schema --module
quire clauses evaluate --module [--module ]... --authority --set --version [--context KEY=VALUE]...
quire clauses diff --module [--module ]... --authority --set --before-version --after-version
quire matrix [--scope | --repo =...] [--module ]... [--format human|markdown|json|tsv] [--strict]
quire trace (--id [--prefix] | --symbol | --file ) --module ... \
[--scope ] [--exclude-path ]... [--format human|json|tsv]
```
The clause commands require one or more explicit module roots. They load only
those roots as a closed set and merge the active vocabulary across them; they do
not discover additional modules from the environment or default search paths.
Global flags:
| Flag | Default | Purpose |
|------|---------|---------|
| `--diagnostics-format ` | `human` | stderr diagnostic encoding |
| `--pretty` | off | indented JSON output for JSON-emitting commands, including `assurance` |
Exit codes:
| Code | Meaning |
|------|---------|
| 0 | success |
| 1 | complete report with partial or strict-coverage failure |
| 2 | path, permission, or domain-policy refusal |
| 3 | invalid arguments, malformed input, missing or wrongly typed paths |
| 4 | internal, serialization, or output I/O failure |
| 134 | panic, never expected |
`check-lock` checks each supplied lock independently, without fetching sources or
changing files. It rejects duplicate agent-ix Git package names and split resolved
commits within one canonical GitHub agent-ix repository. Aligned locks print one
summary on stdout; policy refusals use exit 2 and stderr, invalid input uses 3,
and unexpected I/O uses 4. It honours global diagnostic formatting and color.
## Install
### npm (prebuilt binary — recommended)
Published on the public npm registry as [`@agent-ix/quire-cli`](https://www.npmjs.com/package/@agent-ix/quire-cli).
A per-platform optional dependency carries the prebuilt binary, so no Rust
toolchain and no `quire-rs` checkout is needed — just install:
```bash
npm install -g @agent-ix/quire-cli # or: npx @agent-ix/quire-cli --help
quire --help
```
Prebuilt targets: linux-x64, linux-arm64 (musl/static), darwin-arm64, win32-x64.
Linux x64 covers Intel and AMD; win32-x64 covers Intel and AMD Windows.
### Prebuilt tarball
Each [release](https://github.com/agent-ix/quire-cli/releases) attaches a
`quire--.tar.gz` (`.zip` on Windows) plus `SHA256SUMS.txt`.
Download, verify, and drop `quire` on your `PATH`.
### From source
`quire-cli` builds on [`quire-rs`](https://github.com/agent-ix/quire-rs), fetched
from GitHub at build time, so configure `cargo` with `net.git-fetch-with-cli = true`.
```bash
cargo install --git https://github.com/agent-ix/quire-cli quire-cli
# or, from a checkout:
cargo build --release && target/release/quire --help
```
During development, `target/debug/quire` is fine for local testing.
## Usage Instructions
### Parse And Outline Markdown
Parse a document into a `QuireDocument` JSON envelope:
```bash
quire --pretty parse spec/functional/FR-001.md
```
Print a compact outline:
```bash
quire parse spec/functional/FR-001.md \
| jq -r '.. | objects | select(has("heading") and has("level")) | "\(.level) \(.heading) id=\(.id) block_id=\(.block_id // "-") lines=\(.start_line)-\(.end_line)"'
```
Inspect frontmatter:
```bash
quire parse spec/functional/FR-001.md | jq '.frontmatter'
```
### Lookup One Section
Fetch one parsed section as JSON:
```bash
quire lookup spec/functional/FR-001.md --heading Behavior
quire lookup spec/functional/FR-001.md --heading "Document Title" --level 1
quire lookup spec/functional/FR-001.md --id behavior-L14
quire lookup spec/functional/FR-001.md --block-id blk-behavior
```
Fetch only section body bytes:
```bash
quire lookup spec/functional/FR-001.md --heading Acceptance --content
quire lookup spec/functional/FR-001.md --block-id blk-behavior --content
```
`--id` is generated as `-L` and can change when lines move.
For stable machine addressing, author headings with Pandoc block IDs:
```markdown
## Behavior {#blk-behavior}
```
Then use:
```bash
quire lookup doc.md --block-id blk-behavior
```
### Edit One Section
Replace a single section's body (or a full block) without rewriting the rest of
the document — frontmatter and every untouched section stay byte-identical:
```bash
# Replace the Acceptance Criteria body in place (new content from stdin)
quire lookup FR-001.md --heading "Acceptance Criteria" --content # read current
quire edit FR-001.md --heading "Acceptance Criteria" --content new-ac.md --out FR-001.md
# Replace a full stable block (heading line + body) from stdin
quire edit FR-001.md --block-id blk-behavior --content - < new-block.md
```
`--heading` content is the section BODY (everything after the heading line);
`--block-id` content is the FULL block (heading line, with its `{#blk-id}`
attribute, plus the body). Omit `--out` to write the updated document to stdout.
### Extract Records And Links
Run an archetype's `body_extraction` DSL and collect edges:
```bash
quire extract spec/objects/EX-001.md --module ./extract-mod
```
Override archetype inference when needed:
```bash
quire extract EX-001.md --module ./extract-mod --archetype ExtractSample
```
Show only harvested edges:
```bash
quire extract EX-001.md --module ./extract-mod | jq '.edges'
```
`extract` does not auto-validate. Run `validate` separately for context
JSON schema checks.
### Export Source-Grounded Assurance Facts
Emit quire-rs's closed `quire-assurance` v1 envelope over a bounded repository:
```bash
quire assurance \
--scope . \
--module ./.ix/modules/spec-artifacts-process \
--repository agent-ix/example \
--revision 0123456789abcdef0123456789abcdef01234567 \
--expect-module spec-artifacts-process@0.1.0 \
--expect-schema spec-artifacts-process/FR
```
Documents come only from `/spec`; source symbols come from ``
with `spec/` and module-declared source exclusions omitted. The module path,
repository identity, full revision, module version, and complete active-schema
set are explicit. A missing, extra, or mismatched premise exits non-zero
before stdout. A successful corpus may contain empty arrays; an unreadable
document remains explicit as an `unknown` observation with a reason.
The command performs static parsing and extraction only. It invokes no Git,
test, proof, solver, package manager, consumer, or network operation, adds no
verdict, and does not append the CLI's ordinary provenance object to the closed
upstream payload. Compact JSON is deterministic; global `--pretty` re-indents
the already validated compact bytes and changes whitespace only. Diagnostics
always use stderr.
### Validate A Markdown Document
Structurally validate an authored document against its archetype. The archetype
is resolved from the frontmatter `type` unless `--archetype` overrides
it. Relative document globs are resolved under `--scope`; in scoped mode Quire
loads modules from that scope, `--scope ./.ix/modules` style plugin roots, and
`IX_SCHEMA_PATH`. quire-rs runs the archetype's `body_extraction` asserts (required-section
presence, non-placeholder content, table columns/rows, list items, id patterns)
plus frontmatter-schema and per-level heading uniqueness:
```bash
quire validate --scope . "spec/**/*.md"
quire validate --scope . "spec/functional/*.md" "spec/usecase/*.md"
quire validate ./spec/functional/FR-001.md --module ./iso
quire validate ./FR-001.md --module ./iso --archetype FR
cat FR-001.md | quire validate - --module ./iso --archetype FR
```
On success `validate` exits 0 with no output. On invalid input it exits 3 and writes
the line-numbered quire-rs diagnostics (naming the archetype, section/assert, and
reason: `missing`/`empty`/`placeholder`/`assert`/`frontmatter`/`duplicate-heading`)
to stderr — verbatim, the CLI adds no validation logic of its own.
Every document also satisfies the base **concept** contract before its archetype
runs: `type` is required and non-empty (the OKF discriminator), and the optional
OKF fields `description` (string) and `tags` (string array) are type-checked when
present.
### Validate An OKF Bundle (`--okf`)
`--okf` reads a *foreign* OKF bundle directory under a permissive posture for
portability. `type` is still required and non-empty, but unknown types, broken
`ix://` links, and `index.md` completeness gaps (every sibling artifact must be
listed; the bundle-root `index.md` must carry `okf_version`) are reported as
**warnings** (exit 0) rather than hard errors. An untyped document is still a
hard error.
```bash
quire validate --okf path/to/bundle --module ./iso
quire validate --okf --scope path/to/repo # bundle root is path/to/repo/spec
```
With no positional bundle the root is **`/spec`**, not `--scope` itself
(quire-rs CR-045 two roots): the corpus is walked from `spec/` while the
module's path-bound declarations keep resolving against the scope. A `--scope`
with no `spec/` directory is an error, never a silent repository-wide crawl —
pass the bundle as the positional argument when it is self-contained.
The two forms resolve a module's path-bound declarations differently on
purpose: `--scope` keeps them repository-relative, while a positional bundle
is treated as self-contained and resolves them against itself. Use `--scope`
when the module declares paths like `document: spec/matrix.md`.
Without `--okf`, bundle directories validated via `--scope "spec/**/*.md"` keep
the strict per-file posture (archetype conformance, resolvable references,
complete indexes are all hard requirements).
### Inspect An Archetype's Input Contract
Emit the archetype input contract — the frontmatter JSON Schema plus the
`body_extraction` asserts (required headings, table columns, id-patterns) that
`validate` enforces — as deterministic JSON. This is the same contract an
authoring agent fills; there is no template-variable list (templates were
removed):
```bash
quire schema FR --module ./iso
quire --pretty schema FR --module ./iso
```
Unknown archetypes exit 3 with `UnknownArchetype` on stderr.
## Agent Skills
This repository ships Codex-style agent skills under `skills/`. They are
intended to be packaged with or installed from `quire-cli` so agents can use
the CLI consistently without relearning command patterns.
For Claude Code and Codex, register the [Agent IX marketplace](https://github.com/agent-ix/agent-plugins)
from `agent-ix/agent-plugins`, then install `quire-cli@agent-ix`. Install the
`quire` executable separately using the instructions above.
Available skills:
| Skill | Slash-style name | Purpose |
|-------|------------------|---------|
| `explore-markdown` | `/explore-markdown` | Outline Markdown and fetch targeted sections with `parse` and `lookup`. |
| `write-markdown` | `/write-markdown` | Author Markdown artifacts against an archetype's input contract via `schema` + `validate`. |
| `validate-markdown` | `/validate-markdown` | Check authored Markdown structure with `validate`, `parse`, and `lookup`. |
| `link-markdown` | `/link-markdown` | Inspect relationships, `ix://` links, and blast radius with `extract`. |
| `trace` | `/trace` | Structural forward/inverse trace lookup — "what backs this id" / "what does this file verify" — with `trace`, never a hand-rolled grep pipeline. |
Each skill has:
```text
skills//SKILL.md
skills//agents/openai.yaml
```
When adding a new shipped skill, keep it general, command-oriented, and
domain-neutral. Domain review guidance belongs in domain-specific skills,
not here.
Validate skills with:
```bash
python3 path/to/quick_validate.py skills/explore-markdown
python3 path/to/quick_validate.py skills/write-markdown
python3 path/to/quick_validate.py skills/validate-markdown
python3 path/to/quick_validate.py skills/link-markdown
python3 path/to/quick_validate.py skills/trace
```
## Safety
Path safety is part of the CLI contract:
- `--module`, `--out`, `--content`, and positional document paths reject `..`
traversal where the command applies path safety.
- Symlink escapes are rejected.
- A positional `-` reads from stdin by design (path-safety-exempt).
- The CLI makes no network calls in normal operation; tests audit this with
`strace`.
## Development
```bash
make build # release build
make test # cargo test, including integration tests and audits
make lint # clippy -D warnings
make fmt-check # rustfmt --check
make deny # cargo deny check licenses
make deny-bans # cargo deny check bans
make audit-unsafe # every unsafe block carries a // SAFETY: comment
make audit-thin-boundary # src/ stays a thin wrapper over quire-rs
make dist-test # release tooling tests (verify-binary)
make ci # local CI gauntlet
```
The release binary is audited to link only baseline system libraries on
Linux. See `tests/audit_ldd.rs`.
## Releasing
The manually dispatched `.github/workflows/release.yml` builds the four target
binaries, creates the GitHub Release, and publishes to public npm through the
shared `agent-ix/nodejs-actions/publish-native-npm` action (ADR-0003). The
action owns package layout, the `npm publish` calls and the post-publish
registry check; this repository carries no npm packaging code. Set the version
in `Cargo.toml`, refresh the lock with `cargo update --workspace`, commit, and
dispatch the workflow with `publish` left false for a dry run first. Each built
binary is checked with `quire-dist verify-binary --version X.Y.Z --binary `.
## Spec And Plan
Requirements live in `spec/`; the implementation plan and task index live in
`plan/`. The traceability matrix is computed, not hand-kept: `quire matrix` maps each
acceptance criterion to the tests whose `#[trace(...)]` tags name it.
## License
AGPL-3.0-or-later