okfreq CLI reference

okfreq creates and maintains the requirements subset. Commands accept either a project root or a requirements-bundle root; bundle discovery finds .agents/requirements/ or requirements/ where applicable.

okfreq COMMAND --help

Setup and authoring

Command

Purpose

okfreq init [PATH] [--force]

Create or merge the default requirements scaffold. Existing files are not replaced, except with --force, which replaces guidelines/requirements.guidelines.md with the packaged text. The command prints whether that guideline was installed, kept, replaced or already up to date.

okfreq new strs TITLE --description TEXT --project TEXT [--scope NAME] [--origin NAME] [--derives-from ID]... [--user-need TEXT] [--lifecycle draft|proposed] [--path PATH]

Create a stakeholder requirement with a stable allocated ID and UUID. --lifecycle proposed marks a requirement delivered with its implementation; the default is draft.

okfreq new swrs TITLE --description TEXT --project TEXT --derives-from ID [--derives-from ID]... [--scope NAME] [--origin NAME] [--lifecycle draft|proposed] [--path PATH]

Create a software requirement derived from one or more configured parent requirements. --user-need is rejected for derived tiers. --lifecycle works as for StRS.

okfreq import SOURCE [--path PATH]

Merge configuration while preserving destination values on conflicts and preserving unknown keys.

okfreq config-merge SOURCE [--path PATH]

Explicit spelling of the same conflict-preserving configuration merge.

The configured id_policy controls allocation. The current implementation supports scope-prefix-sequence; it never renumbers existing documents.

Inspect and validate

Command

Purpose

okfreq validate [PATH] [--json] [--prose] [--check-links] [--project-root DIR]

Validate metadata, configuration, IDs, hierarchy, exemptions, derivation, supersession and relates_to links, and optionally annotated file targets. Prose and skipped-root findings are advisory. Requirement schema files that are unparsable or not mappings produce W17; empty ones produce informational I1, and a legacy single-ID superseded_by produces I2 (listed, never counted as errors, and --json has an infos list). Also reports a status that disagrees with the lifecycle, an approved_at without a UTC offset, malformed projection annotations, and the base OKF findings of okf-schema validate on tiers/ (except W3, W4 and W7).

`okfreq lint [PATH] [–prose] [–check-links] [–project-root DIR] [–check

–diff]`

okfreq index [PATH]

Print the stable requirement ID index.

okfreq search QUERY [PATH]

Search IDs, titles, and descriptions.

okfreq in-file FILE

Print one requirement document.

okfreq scope [PATH]

Print configured scope-to-source/test mappings as JSON.

okfreq graph [PATH] [--json]

Show computed derived_by links; --json adds authored derives_from, superseded_by, relates_to and computed supersedes. Exit non-zero for broken targets.

okfreq trace [PATH] [--json]

Scan configured source and test locations for markers.

okfreq status [PATH]

Print lifecycle counts and structural health.

trace separates valid leaf coverage, unknown IDs, non-leaf markers, and scan warnings. The same ID may be marked several times in one file, for example beside distinct tests; the file is listed once. The duplicates key remains in the JSON reports for compatibility and is always empty. Marker spellings and the ID regular expression come from config.yml.

Every non-reserved Markdown document under tiers/ must have mapping frontmatter and a non-empty string id. Missing or malformed documents fail with their file path before indexing or reporting; they are never silently omitted from requirement counts. Repair them rather than deleting them to make validation pass. index.md, log.md, schemas and guidelines are excluded.

Maintain requirement navigation and history

okfreq lint requirements validates first, then creates or refreshes tiers/index.md, every configured tier’s index, and every scope/ancestor index needed to reach the requirements. For example, tiers/swrs/okfreq/index.md lists the scope’s requirements with their IDs, titles and descriptions; parent indexes link to child indexes.

okfreq lint requirements --diff   # preview, no writes
okfreq lint requirements          # refresh generated navigation
okfreq lint requirements --check  # fail if navigation is missing or stale

The generator owns only the block between <!-- okfreq:index:start --> and <!-- okfreq:index:end -->. It preserves all authored content outside the block, including frontmatter and existing introductions. A new block is appended to an existing index without replacing its content. Broken delimiters fail before any index is written. Requirement mutations and coverage generation remain separate. okfreq index continues to print requirement IDs; it does not generate files.

An optional requirements/index.md is a human-authored overview and is preserved. Agents maintain dated change records in requirements/tiers/log.md (singular): affected requirements, rationale, decisions and verification evidence, under exact ## YYYY-MM-DD headings, newest first, with any topic in a ### Topic sub-heading. Lint never rewrites logs or invents change history, but --check fails on a non-conforming heading (W5, W18).

Check annotated file targets

okfreq init writes x-okf-link annotations into the generated requirement schemas. The defaults include filename-stem links for requirement relationships, project-relative links for generated source and test evidence, marker navigation hints, requirement description hints for tooltips/previews, and line-number hints for source/test markers. These presentation hints are advisory: okfreq does not render the UI. Existing schemas are preserved and are not migrated. Checking targets is deliberately opt-in:

okfreq validate . --check-links --project-root .

The --project-root option controls project-relative source and test paths. Without it, the containing Git root of each requirement document is used. The checker does not use the current working directory or an editor workspace as an implicit root. Requirement relationships use case-sensitive Markdown filename stems; source and test evidence uses exact project-relative paths. E10 reports malformed annotations, missing exact files, root escapes, and ambiguous stems. W15 reports a skipped check when a required root or filename-stem workspace is unavailable. A missing stem in a known bundle is E10. Warnings do not make okfreq lint fail on their own.

Generated coverage and reports

Command

Purpose

`okfreq update-coverage [PATH] [–check

–diff]`

okfreq generate-report [PATH] [--output-json FILE] [--output-summary-md FILE]

Generate a detailed JSON report and concise Markdown summary with SwRS source/test-link coverage, configured StRS test coverage, and combined leaf traceability coverage. StRS source coverage is not applicable. Each requirement record also lists derives_from, superseded_by, the computed supersedes and relates_to.

Without output options, the command writes JSON, JSON Schema and Markdown under the resolved bundle’s parent directory in dist/ and prints their paths. Use explicit output paths when reports must live in the project root’s dist/. Generated artifacts should be regenerated rather than edited manually.

Lifecycle changes

Command

Purpose

okfreq archive TARGET [--path PATH] --yes

Set the target lifecycle to deprecated without deleting it.

okfreq supersede TARGET REPLACEMENT [REPLACEMENT...] [--path PATH] --yes

Set the target to superseded and write superseded_by as the list of replacements, replacing any previous value. Every ID must exist, a replacement must not be the target or repeat, and the replacements must not make superseded_by cyclic; otherwise nothing is written. Run okfreq update-coverage afterwards to refresh supersedes.

Lifecycle mutations require explicit --yes. They preserve the requirement body, stable ID, UUID, and unrelated frontmatter. Like okfreq new, they also write the generated OKF status mapped from the new lifecycle and refresh the generated Links section at the end of the body.

Retire a draft

Command

Purpose

okfreq retire TARGET [--path PATH] [--reason TEXT] --yes

Delete a never-published draft, add its ID to retired_ids in config.yml and append an entry to tiers/log.md.

Use retire for a draft that was never published, for example one merged into another requirement. A published requirement is archived or superseded instead, because other documents, commits and reviews may cite it.

retire changes nothing and exits non-zero when --yes is absent, the ID is unknown, the requirement is not a draft, another requirement lists it in derives_from, depends_on or relates_to or in superseded_by, or a configured source or test marker still names it. The error says which. After a successful retirement, run okfreq update-coverage and okfreq lint to refresh generated fields and indexes of the parents that lost a child.

okfreq new allocates one more than the highest number ever used for the tier prefix and scope, counting existing requirements and retired IDs, so the retired number, and any number freed by a deletion below the highest, is never handed out again:

$ okfreq new swrs "Palette search" … --scope palette    # SwRS-…-PALETTE-140
$ okfreq retire SwRS-…-PALETTE-140 --reason "Merged into 139" --yes
Retired SwRS-…-PALETTE-140; its number will not be reused
$ okfreq new swrs "Palette filters" … --scope palette   # SwRS-…-PALETTE-141

Deleting a file by hand records nothing: a number freed below the highest is still skipped, but the highest one would be allocated again. Use retire. okfreq validate reports an error for a requirement whose ID is in retired_ids.

See also