Skip to content

Data API CLI

Query delivery process state directly from annotated source code.

For AI coding agents: Start every session with these three commands:

  1. overview — project health
  2. scope-validate <pattern> <session-type> — catches blockers before you start
  3. context <pattern> --session <type> — curated context bundle

Traditional approach: read generated Markdown, parse it mentally, hope it’s current. This CLI queries the same annotated sources that generate those docs — in real time, with typed output.

ApproachContext CostAccuracySpeed
Parse generated MarkdownHighSnapshot at gen timeSlow
Data API CLILowReal-time from sourceInstant

The CLI has two output modes:

  • Text commands (6) — formatted for terminal reading or AI context. Use === section markers for structure.
  • JSON commands (12+) — wrapped in a QueryResult envelope. Pipeable to jq.

Run process-api --help for the full command reference with all flags and 26 available API methods.


The recommended session startup is three commands:

Terminal window
# 1. Project health — progress, active phases, blockers
pnpm process:query -- overview
# 2. Pre-flight check — catches FSM violations before you start
pnpm process:query -- scope-validate MyPattern implement
# 3. Curated context — tailored to your session type
pnpm process:query -- context MyPattern --session implement

Example overview output:

=== PROGRESS ===
318 patterns (224 completed, 47 active, 47 planned) = 70%
=== ACTIVE PHASES ===
Phase 24: ProcessStateAPIRelationshipQueries (1 active)
Phase 25: DataAPIStubIntegration (1 active)
=== BLOCKING ===
StepLintExtendedRules blocked by: StepLintVitestCucumber
=== DATA API — Use Instead of Explore Agents ===
pnpm process:query -- <subcommand>
overview, context, scope-validate, dep-tree, list, stubs, files, rules, arch blocking

The --session flag tailors output to what you need right now:

TypeIncludesWhen to Use
planningPattern metadata and spec file onlyCreating a new roadmap spec
designFull: metadata, stubs, deps, deliverablesMaking architectural decisions
implementFocused: deliverables, FSM state, test filesWriting code from an existing spec

Decision tree: Starting to code? implement. Complex decisions? design. New pattern? planning. Not sure? Run overview first.


These 6 commands output structured text (not JSON). They are designed for terminal reading and AI context consumption.

Executive summary: progress percentage, active phases, blocking patterns, and a CLI cheat sheet.

Terminal window
pnpm process:query -- overview

Highest-impact command. Pre-flight readiness check that prevents wasted sessions. Returns a PASS/BLOCKED/WARN verdict covering: dependency completion, deliverable definitions, FSM transition validity, and design decisions.

Terminal window
pnpm process:query -- scope-validate MyPattern implement

Checks: dependency completion, deliverable definitions, FSM transition validity, design decisions, executable spec location.

Example output:

=== SCOPE VALIDATION: DataAPIDesignSessionSupport (implement) ===
=== CHECKLIST ===
[PASS] Dependencies completed: 2/2 completed
[PASS] Deliverables defined: 4 deliverable(s) found
[BLOCKED] FSM allows transition: completed → active is not valid.
[WARN] Design decisions recorded: No PDR/AD references found in stubs
=== VERDICT ===
BLOCKED: 1 blocker(s) prevent implement session

Valid session types for scope-validate: implement, design.

Curated context bundle tailored to session type.

Terminal window
pnpm process:query -- context MyPattern --session design

Example output:

=== PATTERN: ContextAssemblerImpl ===
Status: active | Category: pattern
## ContextAssembler — Session-Oriented Context Bundle Builder
Pure function composition over MasterDataset.
File: src/api/context-assembler.ts
=== DEPENDENCIES ===
[active] ProcessStateAPI (implementation) src/api/process-state.ts
[completed] MasterDataset (implementation) src/validation-schemas/master-dataset.ts
=== CONSUMERS ===
ContextFormatterImpl (active)
ProcessAPICLIImpl (active)
=== ARCHITECTURE (context: api) ===
MasterDataset (completed, read-model)
ProcessStateAPI (active, service)
...

Dependency chain with status indicators. Shows what a pattern depends on, recursively.

Terminal window
pnpm process:query -- dep-tree MyPattern
pnpm process:query -- dep-tree MyPattern --depth 2

File reading list with implementation paths. Use --related to include architecture neighbors.

Terminal window
pnpm process:query -- files MyPattern
pnpm process:query -- files MyPattern --related

Example with --related:

=== PRIMARY ===
src/cli/process-api.ts
=== ARCHITECTURE NEIGHBORS ===
src/cli/version.ts
src/cli/output-pipeline.ts
src/cli/error-handler.ts

Captures session-end state: deliverable statuses, blockers, and modification date.

Terminal window
pnpm process:query -- handoff --pattern MyPattern
pnpm process:query -- handoff --pattern MyPattern --git # include recent commits
pnpm process:query -- handoff --pattern MyPattern --session my-session-id

Example output:

=== HANDOFF: DataAPIDesignSessionSupport (review) ===
Date: 2026-02-21 | Status: completed
=== COMPLETED ===
[x] Scope validation logic (src/api/scope-validator.ts)
[x] Handoff document generator (src/api/handoff-generator.ts)
=== BLOCKERS ===
None

These commands output JSON wrapped in a QueryResult envelope.

Status counts and completion percentage.

Terminal window
pnpm process:query -- status

Output: { counts: { completed, active, planned, total }, completionPercentage, distribution }

Filtered pattern listing. Composable with output modifiers and list filters.

Terminal window
# All roadmap patterns
pnpm process:query -- list --status roadmap
# Just names
pnpm process:query -- list --status roadmap --names-only
# Count only
pnpm process:query -- list --status active --count
# Specific fields
pnpm process:query -- list --phase 25 --fields patternName,status,file

See Output Modifiers and List Filters below for all options.

Fuzzy name search with match scores. Suggests close matches when a pattern is not found.

Terminal window
pnpm process:query -- search EventStore

Full detail for one pattern including deliverables, dependencies, and all relationship fields.

Terminal window
pnpm process:query -- pattern TransformDataset

Warning: Completed patterns can produce ~66KB of output. Prefer context --session for interactive sessions.

Design stubs with target paths and resolution status.

Terminal window
pnpm process:query -- stubs MyPattern # stubs for one pattern
pnpm process:query -- stubs --unresolved # only stubs missing target files

AD-N design decisions extracted from stub descriptions.

Terminal window
pnpm process:query -- decisions MyPattern

Note: Returns exit code 1 when no decisions are found (unlike list/search which return empty arrays).

Cross-reference patterns mentioning a PDR number.

Terminal window
pnpm process:query -- pdr 1

Note: Returns exit code 1 when no PDR references are found, same as decisions.

Business rules and invariants extracted from Gherkin Rule: blocks, grouped by product area, phase, and feature.

Terminal window
pnpm process:query -- rules
pnpm process:query -- rules --product-area Validation
pnpm process:query -- rules --pattern ProcessGuardDecider
pnpm process:query -- rules --only-invariants

Warning: Unfiltered rules output can exceed 600KB. Always use --pattern or --product-area filters.

Output shape: { productAreas: [{ productArea, ruleCount, invariantCount, phases: [{ phase, features: [{ pattern, source, rules }] }] }], totalRules, totalInvariants }


All architecture queries output JSON. They use @libar-docs-arch-* annotations.

SubcommandDescriptionExample
arch rolesAll arch-roles with pattern countsarch roles
arch contextAll bounded contextsarch context
arch context <name>Patterns in one bounded contextarch context scanner
arch layerAll architecture layersarch layer
arch layer <name>Patterns in one layerarch layer domain
arch neighborhood <p>Uses, usedBy, dependsOn, same-contextarch neighborhood EventStore
arch compare <c1> <c2>Cross-context shared deps + integrationarch compare scanner codec
arch coverageAnnotation completeness across input filesarch coverage
arch danglingBroken references (names that don’t exist)arch dangling
arch orphansPatterns with no relationships (isolated)arch orphans
arch blockingPatterns blocked by incomplete depsarch blocking
Terminal window
# What patterns are stuck?
pnpm process:query -- arch blocking
# How well-annotated is the codebase?
pnpm process:query -- arch coverage
# What does this pattern touch?
pnpm process:query -- arch neighborhood RulesQueryModule

Tag usage report — counts per tag and value across all annotated sources.

Terminal window
pnpm process:query -- tags

File inventory by type (TypeScript, Gherkin, Stubs, Decisions).

Terminal window
pnpm process:query -- sources

TypeScript files missing the @libar-docs opt-in marker. Use --path to scope to a directory.

Terminal window
pnpm process:query -- unannotated
pnpm process:query -- unannotated --path src/types

Execute any of the 26 query API methods directly by name. This is the escape hatch for methods not exposed as dedicated subcommands.

Terminal window
pnpm process:query -- query getStatusCounts
pnpm process:query -- query isValidTransition roadmap active
pnpm process:query -- query getPatternsByPhase 18
pnpm process:query -- query getRecentlyCompleted 5

Integer-like arguments are automatically coerced to numbers. Run process-api --help for the full list of available API methods.


FlagShortDescriptionDefault
--input <pattern>-iTypeScript glob pattern (repeatable)from config or auto-detected
--features <pattern>-fGherkin glob pattern (repeatable)from config or auto-detected
--base-dir <dir>-bBase directorycwd
--workflow <file>-wWorkflow config JSONdefault
--help-hShow help---
--version-vShow version---

Config auto-detection: If --input and --features are not provided, the CLI loads defaults from delivery-process.config.ts in the current directory. If no config file exists, it falls back to filesystem-based detection. If neither works, --input is required.

Composable with list, arch context/layer, and pattern-array query methods.

ModifierDescription
--names-onlyReturn array of pattern name strings
--countReturn integer count
--fields <f1,f2,...>Return only specified fields per pattern
--fullBypass summarization, return raw patterns
--format <fmt>json (default, pretty-printed) or compact

Valid fields for --fields: patternName, status, category, phase, file, source.

Precedence: --count > --names-only > --fields > default summarize.

Note on summarization: By default, pattern arrays are summarized to ~100 bytes per pattern (from ~3.5KB raw). Use --full to get complete pattern objects.

For the list subcommand. All filters are composable.

FilterDescription
--status <status>Filter by FSM status (roadmap, active, completed, deferred)
--phase <number>Filter by roadmap phase number
--category <name>Filter by category
--source <ts|gherkin>Filter by source type
--arch-context <name>Filter by architecture context
--product-area <name>Filter by product area
--limit <n>Maximum results
--offset <n>Skip first n results

All JSON commands wrap output in a QueryResult envelope:

{
"success": true,
"data": { ... },
"metadata": {
"timestamp": "2026-02-21T04:31:31.633Z",
"patternCount": 318
}
}

On error:

{
"success": false,
"error": "Pattern not found: \"Orchestrator\"\nDid you mean: OrchestratorPipelineFactoryMigration?",
"code": "PATTERN_NOT_FOUND"
}
CodeMeaning
0Success
1Error (with message on stderr)

pnpm outputs a banner line to stdout (> @libar-dev/...). For clean JSON piping, use npx tsx src/cli/process-api.ts directly:

Terminal window
npx tsx src/cli/process-api.ts list --status roadmap --names-only | jq '.data[]'

Terminal window
pnpm process:query -- overview # project health
pnpm process:query -- scope-validate MyPattern implement # pre-flight
pnpm process:query -- context MyPattern --session implement # curated context
Terminal window
pnpm process:query -- list --status roadmap --names-only # available patterns
pnpm process:query -- arch blocking # stuck patterns
pnpm process:query -- stubs --unresolved # missing implementations
Terminal window
pnpm process:query -- search EventStore # fuzzy name search
pnpm process:query -- dep-tree MyPattern --depth 2 # dependency chain
pnpm process:query -- arch neighborhood MyPattern # what it touches
pnpm process:query -- files MyPattern --related # file paths
Terminal window
pnpm process:query -- context MyPattern --session design # full context
pnpm process:query -- decisions MyPattern # design decisions
pnpm process:query -- stubs MyPattern # existing stubs
Terminal window
pnpm process:query -- handoff --pattern MyPattern # capture state
pnpm process:query -- handoff --pattern MyPattern --git # include commits