Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CLI guide

Reference for project.yaml, every subcommand, and editor / LSP integration.

MarkSpec follows the Command Line Interface Guidelines. Every command supports --help. Commands that produce structured output support --format json for machine-readable output to stdout (diagnostics always go to stderr).

Exit codes: 0 success, 1 error, 2 warnings only (check, lint, lock, and image warnings from book build).

Global options (available on every command):

FlagDescription
-h, --helpShow help
-V, --versionShow version
-q, --quietSuppress non-error output

Project configuration

project.yaml

Every MarkSpec project requires a project.yaml in the project root. MarkSpec discovers it by walking up from the current directory. check, fmt, and lint also accept a .markspec.yaml as the project root when no project.yaml is found, and they resolve the project of each file argument from that file’s directory; see Which project a file belongs to. project.yaml follows the org project-manifest contract — the closed schema published at https://driftsys.github.io/schemas/project/v1.json — shared with other DriftSys tooling, not a MarkSpec-only format.

Minimal example

name: my-project
version: "1.0.0"

Complete example

name: io.acme.braking-system
version: "2.3.0"

dependencies: # projects this project uses (git repositories)
  - url: git@github.com:acme/aeb-icd.git
    name: icd # short id: cache dir, lock rows, badges
    version: "v2.1.0" # frozen baseline (exact tag)

references: # citation sources (published sites)
  - url: https://driftsys.github.io/refhub
    name: refhub

Fields

FieldTypeRequiredDescription
namestringyesProject name. Must match ^[a-z][a-z0-9.-]*$ (lowercase, digits, ., -). Reverse-DNS convention recommended.
versionstringyesProject version. Quote in YAML to avoid number coercion.
dependenciesprojectRef[]noNon-empty list of distinct project references when present. Projects this project uses (git repositories).
referencesprojectRef[]noNon-empty list of distinct project references when present. Registries and external sources this project cites.

name and version are required — a project.yaml missing either is rejected before any MarkSpec command runs. The schema is closed: an unrecognized key is an error, not a silent no-op. A handful of org-owned fields MarkSpec accepts but never acts on (description, license, keywords, labels, authors, homepage, repository, process, …) are metadata for other org tooling, not MarkSpec configuration — notably, labels: here is inert project metadata and does not constrain which Labels: values entries may carry.

MarkSpec retains two tested exceptions to the org schema’s version rule: version: "" is rejected with ConfigError, and numeric versions are converted to strings with a warning. Other non-string values are rejected with ConfigError.

markspec-specific tool config lives in .markspec.yaml, not project.yaml. exclude: and caption-conventions: moved there — see below.

The projectRef shape

dependencies: and references: are both lists of the same shape:

KeyTypeRequiredDescription
urlstringyesGit repository URL (dependencies:) or published-site base URL (references:; file:// accepted).
versionstringnoVersion intent: an exact tag freezes a baseline, a branch name tracks its head, absent or empty means auto (latest release tag, else default-branch head).
namestringnoUpstream id — cache-directory name, lockfile row id, origin badge. Must match [A-Za-z0-9][A-Za-z0-9._-]*. Derived from the URL when absent.

Omit either key when there are no entries. An empty list, null, an empty YAML key, or duplicate objects in the same list is an error. Object key order does not affect duplicate detection.

An explicitly empty projectRef version: "" means auto, as when absent. A projectRef name: must remain a safe cache-directory name even though the org schema accepts any string. URLs must satisfy the org schema’s URI format. For dependencies:, local paths (./, ../, /, or Windows drive C:\ prefixes) and scp-style Git URLs such as git@github.com:acme/demo.git are supported exceptions.

  • dependencies: — other projects this project builds on (git repositories). markspec lock resolves the declared version: intent against the repo, acquires the tree at the resolved sha (a shallow git fetch, no clone, no history), compiles it in-process, and pins the result as an [[upstream.dependency]] lockfile row. A pin that resolves to a branch or bare sha rather than a tag is an unreleased state — advisory by default, promoted to a hard error under markspec check --strict (MSL-L215; see lock below).
  • references: — registries or external sources this project cites, such as another project’s published compile output. markspec lock fetches and pins these against a cache — see lock below. The declared version: is recorded but not yet consulted when resolving a references: entry — lock currently fetches the site’s latest published snapshot regardless of an exact tag or branch name; version-selecting resolution is planned for a future release.

Upstream entries resolve in the graph

Once markspec lock has pinned a references: or dependencies: entry, its entries join this project’s own traceability graph as read-only, origin-tagged citizens — not just cached files on disk:

  • Trace links resolve across the repo boundary. A Satisfies: (or any other trace attribute) value that names an upstream display ID resolves exactly like a same-project reference. check, show, context, dependents, and report all see the upstream entry, tagged with an Origin: line / column showing <upstreamId>@<version> — see show and report below.
  • MSL-T014 replaces MSL-L006 for a trace value that still doesn’t resolve once the project declares any dependencies:/references:: the warning names every upstream searched, e.g. not found in project or upstreams: producta, icd. A project with no declared upstreams keeps the plain MSL-L006 behavior.
  • A project entry that reuses an upstream’s display ID or Id: fails check with MSL-R014, naming the colliding upstream origin — the same shape as the collision that fires when a profile delivers a corpus (ADR-030), generalized to cover upstream origins too. Fix it by renaming the project entry; upstream entries are read-only.
  • references: entries are traceability leaves. report coverage never reports one as an orphan or unsatisfied gap — a citation isn’t something your own project is expected to cover. dependencies: entries participate in coverage like a project entry — a product requirement with no component coverage is a reported gap.
  • Upstream entries are validation-exempt, not edge-inert. No structural checks or prose lint run against them — that already happened in their own repo’s check — but they remain full resolution targets: a project entry’s trace link to one still resolves, and so does an edge between two upstream entries once both are hydrated into the same graph.

Root/program project pattern. A root or program repository that references every member repo aggregates the whole program’s graph for free: each member’s entries hydrate into the root’s compile, cross-repo trace edges resolve there, and report, dependents, and context run against the entire program from the root — both ends of every cross-repo edge are present. A repo referenced through more than one path (a diamond — e.g. the root references both a component and something that itself references that component) is still counted exactly once: an upstream snapshot’s own re-exported entries are skipped in favor of that entry’s authoring repo, so aggregating never double-counts or collides.

.markspec.yaml

.markspec.yaml carries markspec’s own tool configuration: profile binding (covered in the Profile guide) plus two file-discovery / rendering settings that used to live in project.yaml:

FieldTypeDefaultDescription
excludestring[][]Gitignore-syntax patterns excluded from project-wide file discovery (bare check/lint/fmt), anchored at the project root. Applied after .gitignore rules.
caption-conventionsmap<string, above|below>{}Per-keyword caption-position convention (Figure, Table, Listing, Feature, Equation, List) enforced by MSL-C072.

Each exclude: pattern must be a non-empty string. Editor validation and autocomplete use the .markspec.yaml schema. project.yaml rejects exclude:; configure it in .markspec.yaml.

For exclude: and caption-conventions:, null or an empty YAML key uses the default empty list or mapping.

exclude: example — skip a directory of example entry blocks that aren’t real requirements, plus a generated-file pattern:

# .markspec.yaml
exclude:
  - skills/
  - "*.gen.md"

Discovery precedence. Hidden directories are always skipped. For other paths, rules apply in this order at every directory level: built-in build-output skips, enclosing and root .gitignore files, nested .gitignore files, then the project’s .markspec.yaml exclude: list. The last matching rule wins, so exclude: overrides even a conflicting nested .gitignore. Patterns use the project root as their base; a leading / anchors a pattern there, while a bare name such as secrets/ matches at any depth.

Built-in skips. File discovery always skips hidden directories (names starting with .); negations in .gitignore or exclude: cannot re-include them. The common build-output / dependency directories node_modules, target, dist, and build are skipped by default as the lowest-precedence rules. Re-include one with a negated entry in .gitignore or exclude: (e.g. exclude: ["!target/"]). An exclude: negation wins even when .gitignore also ignores that directory. An ignored parent is pruned before its contents are visited: !target/keep.md alone cannot restore a file under an ignored target/; also add !target/.

These rules apply to bare check/lint/fmt, explicit directory arguments within a project, LSP indexing, lockfile entry collection, and nested-project discovery for the CLI, LSP, and MCP. Nested-root discovery uses the outer project’s exclusions for its initial walk, then scans each discovered project with its own exclude: list and inherited .gitignore rules. A child’s negations can restore non-hidden descendants pruned by the initial walk, but hidden folders are never re-included. An enclosing project’s exclusions still apply to its entire subtree. Explicit file arguments are taken as-is.

Nested projects and .gitignore. The walk of a nested project also applies the .gitignore files of the folders between the outermost project root and the nested project, whether the command runs from the outermost project or from inside the nested one. A nested project therefore skips the files that an enclosing project’s .gitignore ignores. No .gitignore above the outermost project root is read. markspec lock walks a nested project the same way.

caption-conventions: example — require every Table caption above its block and every Figure caption below:

# .markspec.yaml
caption-conventions:
  Table: above
  Figure: below

See the Profile guide for the profile-binding keys (profiles:, default-profile:) this file also carries.

Directory conventions

MarkSpec does not enforce a directory layout. By convention:

  • docs/ — Markdown files containing requirements and design documentation
  • src/ — source code with doc-comment entries (Rust ///, Kotlin /**)
  • project.yaml — project root marker

The compile and report commands accept explicit paths or globs:

markspec compile "docs/**/*.md"
markspec compile docs/requirements.md src/main.rs features/brake.feature

A .feature file contributes entries only through its # [ID] header comments (see Entries in .feature files).

Profile configuration (.markspec.yaml and profile manifests) is covered in the Profile guide.


Commands

Project setup

init

Scaffold a new MarkSpec project — writes project.yaml, .markspec.yaml, and (unless opted out) client MCP configs and skills.

markspec init [target-dir]
FlagTypeDefaultDescription
--clientstring—Force write for the named client (repeatable): claude, opencode
--all-clientsboolfalseWrite configs for claude + opencode regardless of detection
--no-mcpboolfalseSkip all MCP scaffolding
--no-skillsboolfalseSkip upskill add
--profilestring—Profile spec (conflicts with --no-profile)
--no-profileboolfalseCore-only mode (default-profile: false)
--binary-pathstring—Absolute path to the markspec binary for MCP configs
--dry-runboolfalseReport decisions, write nothing
--forceboolfalseOverwrite skip-on-exists files; required for a non-empty dir or non-TTY
--formatstringtextSummary format: json, text

Examples:

markspec init                                             # scaffold in cwd
markspec init ./my-project                                # scaffold in a new subdir
markspec init --profile git+https://github.com/org/profile
markspec init --all-clients --binary-path /opt/markspec/bin/markspec
markspec init --dry-run --format json                     # report, write nothing

Authoring

fmt

Stamp ULIDs, fix indentation, normalize attributes, and format the whole Markdown document — entry mechanics and surrounding prose in one pass (ADR-029).

# the whole project's markdown — what you run before committing
markspec fmt

# one file
markspec fmt docs/requirements.md

# check mode for CI — reports but doesn't modify
markspec fmt --check
markspec fmt [...files]
markspec fmt --check [...files]
FlagTypeDefaultDescription
--checkboolfalseReport changes without writing. Exit 1 if changes needed

Bare invocation = whole-project Markdown and .feature scope. With no file arguments, fmt discovers every .md and .feature file under the project root (gitignore + .markspec.yaml exclude: honored) and prints a one-line scope header to stderr (formatting N file(s) under <root>), suppressed by -q. Bare invocation requires a project root above the current directory (a project.yaml or a .markspec.yaml); outside a project it errors rather than silently scanning the cwd. fmt never rewrites source files, unlike check/lint which also cover source doc comments. In a .feature file fmt only inserts a missing # Id: line into a # [ID] header; a file with no header, or one that does not parse, is left unchanged (see Entries in .feature files). The scope line counts every .feature file, with or without a header.

Whole-document formatting (ADR-029). Beyond entry-block mechanics, fmt formats the entire Markdown document — headings, lists, tables, and prose — through an embedded dprint-markdown plugin, with one fixed style: always-wrap prose, underscore emphasis, asterisk strong, and dash bullet lists. The line width and the line ending come from .editorconfig, with the same rules as prim fmt.

  • Line width: max_line_length, default 80. fmt reads the .editorconfig files from the file’s directory upward, until a file with root = true; nearer files override farther ones. max_line_length = off, or no value, gives 80. Entry bodies wrap at the line width minus their indent.
  • Line ending: end_of_line. lf or crlf sets the line ending that fmt writes (cr gives lf). When end_of_line is not set, or there is no .editorconfig, fmt writes LF, so a CRLF file becomes LF. check uses the same values, and when the only difference is the line ending, its MSL-F010 message says so. Editor formatting through markspec lsp uses the line width but keeps the line ending of the buffer; set the editor line ending (VS Code files.eol) to match, or run markspec fmt.
  • Recommended: * text=auto eol=lf in .gitattributes. Without it, a Windows checkout with core.autocrlf=true has CRLF files, and unless end_of_line = crlf is set, every file is reported as drift.
  • The line width is a soft target, not a hard cap. Table rows, links and reference definitions, and inline code spans are never split to fit — they may exceed the line width when they can’t be broken.
  • <!-- dprint-ignore --> and <!-- dprint-ignore-start/end --> work as a per-block opt-out, same as external dprint. An ignore-start/end pair MUST NOT span an entry block — entry blocks and surrounding prose format as separate segments, so a range that straddles both is not honored across the boundary.
  • Files that must stay unformatted (long attribute-value lines in showcase docs, generated files) use .markspec.yaml exclude: — the same mechanism check/lint use, not a new flag.
  • Every rewrite is safety-gated. If reformatting an entry body would change its meaning, fmt keeps the original text for that entry and reports an advisory MSL-F012 instead of silently doing nothing or corrupting content.

Empty trailer placeholders are dropped. A trailer line with no value (Id:, Satisfies:) is not a valid trailer — markspec check reports it as MSL-P021. fmt removes such lines from an entry’s trailing attribute block (reported as MSL-F001 info) so the rest of the block stays trailers, then stamps Id: as usual. To get an Id:, omit the line; don’t leave it blank.

Tabs after entry list markers. fmt rewrites the marker and its following whitespace to a dash followed by one space only when the whole document keeps the same CommonMark structure, including list nesting, body and trailer containment, and existing entry identities. If normalization would change that structure, fmt emits MSL-F013 (warning), preserves the entry byte-for-byte, and does not stamp an Id: into it. Other entries are formatted as usual. A parent that holds the refused child as a nested entry (MSL-P024) is left unformatted and unstamped too, apart from the tab marker rule above and the trace-value canonicalization that fmt does for the whole file. An entry with content after an Id: trailer block (MSL-P025), indented or a git-style paragraph (for example a Key: Value line that a tab indents less than 4 columns past the list-item content), is left unformatted and unstamped in the same way: move the content above the trailer. A child’s attributes are not copied into its parent. The surrounding list layout and following indented blocks are preserved where needed so that repeated formatting gives the same result. This includes paragraphs that CommonMark places outside the refused list item, and later indented trailers associated with that entry. Trace reference canonicalisation also preserves those trailers.

Explicit arguments scope exactly to what’s named; a directory argument expands to the files a bare invocation of its project finds below that directory, so .gitignore, the built-in hidden-directory skip, and the .markspec.yaml exclude: patterns all apply (see Which project a file belongs to):

# a subtree
markspec fmt docs/

# multiple files
markspec fmt docs/*.md

Project-aware trace canonicalisation (requires a project root):

When a Markdown file that markspec fmt formats belongs to a project, it also canonicalises and heals trace reference values (a .feature file only gets its missing # Id: lines):

  • Canonicalise — any ULID written directly in a trace attribute (Satisfies:, Derived-from:, Verifies:, etc.) is rewritten to the target entry’s current display ID, except inside a refused entry.
  • Heal — if a target’s display ID was renamed, the edge ledger in markspec.lock records the stable target-ulid; fmt uses it to rewrite the stale display ID to the target’s new name, except inside a refused entry.
  • Unresolved references are left as-is — markspec check reports them via MSL-L006, or MSL-T014 when the project declares dependencies:/ references: (see Upstream entries resolve in the graph above).

Neither action is performed for a file that has no project.yaml or .markspec.yaml above it. fmt reads the edge ledger but never writes markspec.lock; the ledger is owned by markspec lock.

check

The composite traceability and hygiene gate — structure, traceability, format drift, lockfile drift, and advisory prose, merged into one diagnostics stream.

# the whole project — what you wire into CI and the pre-push hook
markspec check

# one file, fast — what editors and per-file hooks run
markspec check docs/requirements.md

# a subtree
markspec check docs/
markspec check [...files]
FlagTypeDefaultDescription
--strictboolfalsePromote warnings to errors
--formatstringtextOutput format: json, text

Bare invocation = whole-project gate. With no file arguments, check discovers every relevant file (markdown, .feature files and source doc comments) under the project root (gitignore + .markspec.yaml exclude: honored) and prints a one-line scope header to stderr (checking N file(s) under <root>), suppressed by -q and in --format json mode. Bare invocation requires a project root above the current directory (a project.yaml or a .markspec.yaml); outside a project it errors rather than silently scanning the cwd.

The composite gate is project-wide only. Bare markspec check runs every gate below over the whole corpus in one pass, merging findings into a single diagnostics stream (one text renderer, one --format json array, one exit-code computation):

GateSeverityWhat it checks
Parse + structure + attributesas todayMalformed entry blocks, missing Id:, duplicate display IDs, malformed attributes.
Traceability (incl. MSL-L006)as today (MSL-L006 = warning)Broken Satisfies:/Derived-from:/etc. references; MSL-L006 flags a trace value that doesn’t resolve to any entry — or MSL-T014 when the project declares dependencies:/references: (see Upstream entries resolve in the graph).
Listing documentsas todayListing-file conventions (e.g. SUMMARY.md structure).
Format drift (MSL-F010)errorThe file’s whitespace/attribute form differs from what markspec fmt would produce — i.e. it wasn’t formatted before commit.
Reference-canon drift (MSL-F011)errorA trace value is a ULID or stale display ID that markspec fmt would rewrite to its canonical display ID (ADR-026 canonicalization). Distinct from MSL-F010 so you know which fmt concern to fix.
Lockfile drift (MSL-L212)error (only when markspec.lock exists)Traceability edges have changed since markspec lock last ran. Checked offline against the on-disk markspec.lock (no network).
Prose lint (MSL-Q*)advisory warningThe same rules markspec lint runs (modal verbs, EARS, passive voice, INCOSE lexicon, …).

markspec check <file> (file-local) runs structural validation only. The format-drift, lockfile, and prose-lint gates, the MSL-L006 trace-existence warning, and cross-entry TYPL-009/010/011 and UXIL-016/017/018 diagnostics are project-wide-only — they need the full corpus (or the whole file’s formatted form) to be meaningful, so they don’t fire when you pass explicit file arguments. The DSL validation codes are suppressed even when their cause is entirely inside the subset. Parser diagnostics remain active, including TYPL-010 for a relative declaration without a namespace base. This is the fast, editor/per-file-hook path; the canonical agent write loop is insert → fmt → check per file, then a project-wide check before commit/CI catches everything else.

Which project a file belongs to

check, fmt, and lint resolve the project of a file the same way as the LSP server and the MCP server, so the same file is processed with the same project, profile, and markspec.lock on every surface.

  • Project root order. From a directory, walk up to the nearest project.yaml, else to the nearest .markspec.yaml.
  • Configs that an enclosing project hides. When that config file lies in a folder that an enclosing project hides — a folder listed in the enclosing project’s .markspec.yaml exclude:, a gitignored folder, or a hidden folder (name starting with .) — it is not a project root, as in the LSP. The file then belongs to the enclosing project. An explicit file argument in such a folder prints one warning per hidden config (unless -q) that names the enclosing project and how to keep the folder a project: exclude: negations for an excluded or gitignored folder (every excluded parent folder must be re-included too), or renaming a hidden folder, which is never a project root even when exclude: re-includes it.
  • Explicit arguments. The project of each file is resolved from the file’s own directory, not from the current directory. Running markspec check docs/req.md from the project root, from docs/, or from outside the project with an absolute path gives the same result. A directory argument expands to the files a bare invocation of its project would find below that directory (so .markspec.yaml exclude: applies, and markspec check . at a project root checks the same files as a bare markspec check).
  • Several projects in one invocation. Files are grouped by project. Each group is processed with its own profile, its own .markspec.yaml tool config, and its own markspec.lock: fmt reads it for reference healing, lint reads it to load locked upstream entries, and a bare check reads it for the project-wide gates. Validation of a group sees only that group’s files, so a display ID declared once in each of two projects is not a duplicate. The output of all groups is printed together, as one stream (one --format json document; lint reports one score over all groups), and the exit code is the worst across the groups. Diagnostics are reported group by group, in the order the first file of each project appeared in the arguments.
  • Files with no project. Files with neither config file above them form one group that is processed without a profile. For example, lint <file> on a file outside any project lints it without a profile, instead of exiting with no project.yaml found.
  • Bare invocation. The project root is resolved from the current directory. A project that has a .markspec.yaml and no project.yaml is a valid root. When neither file is found, the command exits 1 with error: no project root found and a hint that a project.yaml or .markspec.yaml marks a project root. Projects nested below the root (found as the LSP finds them from the outermost project root) are processed as their own groups, each with its own profile, exclude: list, markspec.lock, and project-wide gates. The scope header then names the number of projects: checking N file(s) under <root> (K projects). With one project, the header is unchanged: checking N file(s) under <root>.

Exit codes: 0 clean, 1 any error, 2 warnings only (no errors). --strict promotes every warning (including advisory prose findings) to an error, so a project-wide check --strict is a stricter CI gate than the default.

Examples:

# Whole project, JSON output for tool integration
markspec check --format json

# Strict mode — warnings become errors (useful for CI)
markspec check --strict

# One file, strict mode
markspec check --strict docs/requirements.md

Querying

show

Show details of a single entry by display ID or ULID.

markspec show <id> <paths...>
FlagTypeDefaultDescription
--formatstringtextOutput format: json, text

Examples:

markspec show STK_PRJ_0001 "docs/**/*.md"
markspec show --format json STK_PRJ_0001 docs/requirements.md

When the active profile delivers a corpus (ADR-030), the entry prints an extra Origin: line and its Source: renders as <profile-id>@<version>:<path>:<line>:<column> instead of a raw filesystem path:

PLT_0001  Platform core service
  Type: platform-component
  Shape: Authored
  Origin: platform-arch@1.2.0
  ...
  Source: platform-arch@1.2.0:reference/platform.md:1:1

An entry that hydrates from a locked references:/dependencies: upstream (see Upstream entries resolve in the graph) also prints an Origin: line; its Source: gives the entry’s location in the upstream repo’s own tree.

context

Walk the Satisfies chain upward from an entry to see what it ultimately satisfies.

markspec context <id> <paths...>
FlagTypeDefaultDescription
--depthnumber10Maximum depth to walk
--formatstringtextOutput format: json, text

Examples:

markspec context SRS_PRJ_0001 "docs/**/*.md"
markspec context --depth 3 SRS_PRJ_0001 docs/requirements.md

dependents

List all entries that depend on (satisfy) a given entry.

markspec dependents <id> <paths...>
FlagTypeDefaultDescription
--formatstringtextOutput format: json, text

Examples:

markspec dependents STK_PRJ_0001 "docs/**/*.md"

Building

compile

Parse files, build traceability graph, output compiled result.

markspec compile <paths...>
FlagTypeDefaultDescription
--formatstringtextOutput format: json, text

With --frozen, compilation checks lockfile drift first. It reads sync mappings from the same folder walk as lock, including folders without a project config. Mapping file and directory read errors (MSL-S001) and parse diagnostics are printed to stderr, and compilation continues to the drift check. Missing sync directories are ignored.

The diagnostics that compile prints to stderr, and that compile and export put in the diagnostics array of their JSON output, come from the same validator pipeline that bare markspec check runs on the whole project. They include the traceability diagnostics MSL-L006 and MSL-T014. They do not include the check-only gates: format drift, lockfile drift, the MSL-L215 unreleased-pin advisory, listing-document checks, and prose lint. With explicit paths that are only part of the project, the pipeline checks only those files and reports MSL-L006 for a target in a file outside them.

Diagnostics never change the exit code of compile, export, show, context, dependents, or report. These commands exit 1 for input errors, for --frozen lockfile drift, and for an error-severity diagnostic from a profile-delivered document (for example PROFILE-DELIVERS-001).

The hash that markspec lock stores for a dependencies: upstream (a git repository that markspec compiles itself) covers the entries, links, forward and reverse link maps, and type registry of the upstream tree. It does not cover diagnostics, so a change to the validator does not move a pin. A pin recorded by an earlier markspec version, whose snapshot also covered diagnostics, no longer matches when the cache is missing or damaged: the restore then warns MSL-L213 and keeps the old pin. With an intact cache, the old pin is kept. Run markspec lock --update to re-pin. For a references: upstream, the hash is of the entries data file that the site’s manifest names (manifest.entries.file), exactly as published.

Examples:

# Summary output
markspec compile "docs/**/*.md"

# Full JSON output for downstream tools
markspec compile --format json "docs/**/*.md" > compiled.json

report

Generate a traceability matrix or coverage report.

markspec report <kind> <paths...>

kind is one of: traceability, coverage.

FlagTypeDefaultDescription
--formatstringmdOutput format: md, json, csv
--scopestring—Filter by domain abbreviation
--labelstring—Filter by label value
--outputstring—Write to file instead of stdout

Examples:

# Traceability matrix in Markdown
markspec report traceability "docs/**/*.md"

# Coverage report as CSV
markspec report coverage --format csv "docs/**/*.md"

# Write to file
markspec report traceability --output matrix.md "docs/**/*.md"

# Filter by label
markspec report traceability --label ASIL-B "docs/**/*.md"

The traceability matrix carries an Origin column: project for a project-authored entry, or <profile-id>@<version> / <upstream-id>@<version> for an entry injected from a profile’s delivered corpus (ADR-030) or a locked references: upstream (see Upstream entries resolve in the graph). All three formats (md, json, csv) include it.

The coverage report treats a references: upstream entry as a traceability leaf — it never appears in the orphan/unsatisfied gap lists, since a citation isn’t something your own project is expected to cover.

When a reported Requirement or Contract entry has scenarios in a fenced feature block, the coverage report adds a criteria section that shows which scenarios a test verifies. The section is absent when no reported entry has scenarios, so the output of a project without feature blocks does not change. See Scenario locators for how to write the locators.

## Criteria

```text
REQ_BRK_0010  Emergency braking for close obstacles  1/2 criteria verified
  ✓ Brake at 20 m           ← TST_BRK_0012
  ✗ No braking beyond 40 m  ← no verifier
```

In json, the section is the top-level criteria key. Each entry has a state (full, partial or none) and one row per scenario:

"criteria": {
  "total": 2,
  "verified": 1,
  "entries": [
    {
      "displayId": "REQ_BRK_0010",
      "title": "Emergency braking for close obstacles",
      "state": "partial",
      "verified": 1,
      "total": 2,
      "criteria": [
        { "name": "Brake at 20 m", "addressable": true, "verifiedBy": ["TST_BRK_0012"] },
        { "name": "No braking beyond 40 m", "addressable": true, "verifiedBy": [] }
      ]
    }
  ]
}

In csv, two rows follow the other metrics: Criteria total and Criteria verified.

The counting rules:

  • Only Verifies links count. A Satisfies locator never counts as verification.
  • Only a verifier whose type is, or extends, the core Test type counts (the active profile’s extends: chain is followed). An entry never verifies itself.
  • Upstream (federated) entries get no criteria rows and do not count in the totals.
  • A Verifies value without a locator covers every scenario of its target.
  • A Verifies value with a locator covers the scenario it names, when the locator resolves to an addressable scenario. A locator that does not resolve covers nothing.
  • A scenario with an empty name, or a name used more than once in the entry, is not addressable. Only a whole-entry Verifies covers it.
  • A hand-written Verified-by: attribute is not counted. It is also an error (MSL-A030), because Verified-by is computed. Write the link as Verifies: on the test.

export

Emit the compiled traceability graph in a portable format.

markspec export <format> <paths...>

Supported formats: json, yaml, csv.

Examples:

# JSON export
markspec export json "docs/**/*.md" > compiled.json

# CSV — one row per entry: display ID, title, type, shape, id, file, line, origin
markspec export csv "docs/**/*.md" > entries.csv

# YAML
markspec export yaml "docs/**/*.md"

All three formats carry provenance (ADR-030): in json and yaml, a corpus entry has an origin: { kind: "profile", profileId, profileVersion } field and a federated-upstream entry (see Upstream entries resolve in the graph) has origin: { kind: "upstream", upstreamId, version } (project-authored entries omit it); in csv, every row has an origin column holding <profile-id>@<version> for corpus entries, <upstream-id>@<version> for upstream entries, or project for project-authored ones.

insert

Append a scaffolded entry block to a file. This is the agent write path — use it from scripts or AI agents rather than hand-authoring new blocks.

markspec insert <type> <file>
FlagTypeDefaultDescription
--printboolfalseEcho the inserted block to stdout as well
--scopestring—Value for the {scope} placeholder of the type’s ID pattern

The command:

  1. Finds the highest existing display ID for <type> among the entries of <file> and of the other files in its project, the delivered-corpus entries and the locked upstream entries (for a scoped type, in the --scope scope).
  2. Computes the next sequential display ID, skipping any display ID that already exists.
  3. Generates a fresh ULID.
  4. Appends the block with a blank separator.

Example:

markspec insert requirement docs/requirements.md --print
# → appends SRS_PRJ_0003, prints block to stdout

The project of <file> is resolved from the folder of <file> by the same resolver that check, fmt and lint use for an explicit file (see Which project a file belongs to): the nearest project.yaml, else the nearest .markspec.yaml, unless an enclosing project hides that config, in which case the enclosing project owns the file. Its files are the files that a bare markspec check of that project reads: .gitignore entries, .markspec.yaml exclude: patterns and the files of nested projects are skipped, so an ID that exists only in an excluded file can be minted again. insert parses every one of these files, as a bare check does. When no project.yaml or .markspec.yaml is at or above the folder of <file>, only the entries of <file>, the delivered-corpus entries and the locked upstream entries count. The profile, the corpus that it delivers and the locked upstreams still come from the project.yaml found from the current directory. insert exits 1 when a discovered file of the project of <file> cannot be read, or when the .markspec.yaml of that project is malformed, as check, fmt, lock and compile --frozen do; a file whose content does not parse does not stop it. Only <file> is written.

Follow with markspec fmt to normalize indentation and markspec check to confirm no broken references.

create

Print a scaffolded entry block without writing it to any file.

markspec create <type> <paths...>
FlagTypeDefaultDescription
--scopestring—Value for the {scope} placeholder of the type’s ID pattern

Example:

markspec create requirement "docs/**/*.md"

next-id

Print the next available display ID for a profile-declared type without creating an entry.

markspec next-id <type> <paths...>
FlagTypeDefaultDescription
--formatstringtextOutput format: json, text
--scopestring—Value for the {scope} placeholder of the type’s ID pattern

Example:

markspec next-id requirement "docs/**/*.md"
# → SRS_PRJ_0004

markspec next-id requirement "docs/**/*.md" --format json
# → {"type":"requirement","displayId":"SRS_PRJ_0004"}

For a named (counter-less) type — one whose display-id-pattern has no {n} counter, e.g. sw-component: "SWC_{name}" (ADR-025) — there is no number to mint. next-id, create, and insert instead emit an upper-case NAME placeholder template for you to fill in by hand (slug-valid, so the scaffold still passes markspec check):

markspec next-id sw-component "docs/**/*.md"
# → SWC_NAME   (with a note on stderr: author the identifier yourself)

For a scoped type — a numbered display-id-pattern with a {scope} placeholder, e.g. software-requirement: "SRS_{scope}_{n:04d}" — next-id, create, and insert need --scope <value>. The value replaces {scope}, and the number is the highest number in that scope plus one; IDs of other scopes do not count. When the ID of that number already exists, the number goes up until the ID is free. This can happen when nothing separates {scope} from the counter: for G_{scope}{n:02d}, G_BR100 reads as scope BR1, so with G_BR99 and G_BR100 present, --scope BR gives G_BR101. A scope is one or more ASCII letters or digits ([A-Za-z0-9]+). A counter-less pattern such as SWC_{scope} is a named type, not a scoped type: it takes no --scope. As for any type, the IDs that count are those of the files the command reads (the paths you pass for next-id and create, every file of the target file’s project for insert), plus any entries that the profile delivers (delivers:) or that a locked upstream provides (markspec.lock).

# docs/requirements.md holds SRS_BRK_0001 and SRS_ENG_0007
markspec next-id software-requirement "docs/**/*.md" --scope BRK
# → SRS_BRK_0002

markspec insert software-requirement docs/requirements.md --scope ENG
# → appends SRS_ENG_0008 (the IDs in every file of the project count, plus
#   any delivered-corpus and locked-upstream entries)

markspec next-id software-requirement "docs/**/*.md"
# → exit 1: error: display-id-pattern 'SRS_{scope}_{n:04d}' has a {scope}
#   placeholder; pass --scope <value> (scopes in use: BRK, ENG)

Each command exits 1 with an error, and insert writes nothing, when --scope is missing for a scoped type, when --scope is given for a type that is not a scoped type, or when the value is not letters and digits. The missing-flag error lists the scopes in use in those same IDs (for insert, the target file, the other files of its project, and any delivered-corpus and locked-upstream entries).

lint

Run prose-quality analysis on entries (INCOSE lexicon, modal keywords, structural checks). Returns MSL-Q and MSL-M codes.

# the whole project — same rules bare `check` runs as an advisory gate
markspec lint

# one file or subtree
markspec lint docs/requirements.md
markspec lint docs/
markspec lint [...paths]
FlagTypeDefaultDescription
--formatstringtextOutput format: json, text
--strictboolfalsePromote warnings to errors

Bare invocation = whole-project scope, same discovery rules (gitignore + .markspec.yaml exclude:) as check/fmt, with a scope header on stderr suppressed by -q / --format json.

A project-wide markspec check already runs these same prose rules as an advisory (warning-level) gate — lint is useful on its own as a focused, review-time surface with its own score roll-up and band summary, and for running on an explicit file or subtree without pulling in the other check gates.

Examples:

markspec lint --strict
markspec lint --format json
markspec lint docs/requirements.md

score

Score a single piece of requirement prose against the PA-3 rule catalog. Unlike lint, which walks a file’s entries, score takes prose directly — useful for a review-time or editor-integration check of one requirement.

markspec score --text "The system shall …"
FlagTypeDefaultDescription
--textstring—Inline prose to score
--idstring—Identifier to echo back in the result
--formatstring—Output format: json, text (default: text on a TTY, json piped)

Examples:

markspec score --text "The controller shall respond within 200 ms."
markspec score --id SRS_BRK_0001 --text "The system shall be fast." --format json

Lockfile and external sync

lock

Generate or refresh markspec.lock. The lockfile pins upstream profile and language-pack versions, resolves references: projectRefs (see project.yaml above) against their published compile output, and records sync mappings discovered under .markspec/sync/.

markspec lock
FlagTypeDefaultDescription
--checkboolfalseCI mode: read-only, exit 1 on drift.
--updatestring—Force re-resolve every dependencies: and references: upstream, or one by id (--update=<id>).
--formatstringtextOutput format: json, text.

Examples:

markspec lock                      # write or refresh markspec.lock
markspec lock --check              # CI gate: fail if lockfile is stale
markspec lock --update             # force re-resolve every upstream
markspec lock --update=refhub      # force re-resolve one upstream by id

Which project. lock and sync find the project root from the current directory the same way a bare check does: the nearest project.yaml, else the nearest .markspec.yaml, unless an enclosing project hides that config. Run from any folder of a project, markspec lock writes the lockfile at the project root. A project with a .markspec.yaml and no project.yaml is locked with the default settings (no dependencies: or references:). Outside any project, lock and sync exit 1 with no project root found.

What the lockfile pins. A markspec.lock pins the trace edges of its own project only. The files of a project nested below it are pinned by that project’s own lockfile. The files are the ones a bare check of the project walks: its exclude: list applies, and so do the .gitignore files from the outermost project root down. check (MSL-L212), compile --frozen and doctor read the lockfile at the same root and compare against the same files, from any folder of the project. (compile and doctor still need a project.yaml above the current folder.) The External-id: bindings of a nested project’s entries are recorded in that project’s lockfile. Its sync mappings come from .markspec/sync/ in each folder from the outermost project root down to the project root, including folders without a project config. A valid mapping in a deeper folder replaces one for the same system higher up. If any mapping file in this walk cannot be read, has an error-severity parse diagnostic or returns no mapping, lock and lock --check print its diagnostics to stderr and exit 1 before writing any files. This applies even if a deeper mapping would replace the invalid file. Mapping validation also runs before profile acquisition, so these failures do not populate .markspec/cache/ or change .gitignore. A mapping validation error also exits 1 before any writes. Missing sync directories are ignored; any other error reading a sync directory produces MSL-S001 and also exits 1 before any writes. An invalid child mapping does not fall back to the parent’s mapping.

references: resolution — three flows. Only markspec lock touches the network; check, compile, the LSP, and the MCP server resolve entirely offline from the pinned cache under .markspec/cache/upstreams/<id>/. markspec lock keeps that directory gitignored automatically — it appends .markspec/cache/ to .gitignore the first time it runs, so nothing has to be done by hand.

FlowWhenBehavior
First lockA references: entry has no lockfile row yet.Fetch the published snapshot, cache it, write a pinned [[upstream.registry]] row.
RestoreA row is already pinned but its cache is missing or broken (fresh clone, CI, a cleaned tree).Re-fetch the pinned content and verify its hash still matches the lockfile, then repopulate the cache. The pin itself never moves on restore.
Updatemarkspec lock --update (every upstream) or --update=<id> (one).Re-fetch and move the pin to whatever the source currently serves.

Diagnostic codes:

CodeWhenMeaning
MSL-L213markspec lockA declared references: or dependencies: entry could not be locked — no derivable id, a fetch failure, a malformed manifest/tree, or a schema-version mismatch. Warn-and-write: markspec lock still writes every pin that did resolve.
MSL-L213 / MSL-L214markspec lock (restore flow)The cache needed restoring, but the re-fetched content’s hash no longer matches the pinned snapshot — the source changed. Dependencies report MSL-L213; references report MSL-L214. Run markspec lock --update=<id> to move the pin deliberately.
MSL-L212markspec check (offline)Also covers upstream cache drift in this release: fires when a locked reference’s cache under .markspec/cache/upstreams/<id>/ is missing or its hash no longer matches markspec.lock, in addition to the existing traceability-edge-drift case. Run markspec lock for edge drift or to restore the cache; if cache restoration fails, run markspec lock --update=<id> to re-pin.
MSL-L215markspec checkA dependencies: pin resolved to a branch or bare sha rather than a tag — an unreleased state. Advisory by default; markspec check --strict promotes it to a hard error, so a release build cannot pass against an unbaselined dependency.
MSL-L216markspec lockA dependencies: entry derives the same upstream id as a references: entry. The dependency is skipped — the reference snapshot owns the shared .markspec/cache/upstreams/<id>/ namespace — so set a distinct name: on one of them. Warn-and-write: every other pin still locks.

Exit codes. markspec lock exits 0 when every upstream resolved cleanly. Following the clig.dev convention (2 for warnings only), it exits 2 — while still writing markspec.lock (warn-and-write) — when any upstream could not be cleanly locked (MSL-L213/MSL-L214/MSL-L216), so a bare markspec lock in CI surfaces a dropped or stale pin. A hard error (e.g. an invalid project.yaml or sync mapping) exits 1. markspec lock --check still exits 1 on drift. Both lock commands also exit 1 on a malformed or unreadable mapping file, or an unreadable sync directory (except a missing directory), in any folder of the mapping walk, even when a deeper valid mapping overrides it and the lockfile has not changed. Mapping reading, parsing and validation run before profile acquisition and drift checking, and these failures write nothing.

dependencies: are acquired and compiled during lock. For each declared dependencies: entry, markspec lock resolves the declared version intent (auto, an exact tag, or a branch name) against the upstream repo, acquires the tree at the resolved sha via a shallow git fetch (no clone, no history), compiles it in-process, and writes the result to .markspec/cache/upstreams/<id>/ alongside a pinned [[upstream.dependency]] row. Use markspec check --strict to enforce that every dependency is tag-pinned before release (MSL-L215 above).

CI caching. .markspec/cache/upstreams/ is safe to cache between CI runs — key it on markspec.lock’s contents so a job only re-acquires an upstream when its pin actually moved:

# .github/workflows/ci.yml (excerpt)
- uses: actions/cache@v4
  with:
    path: .markspec/cache/upstreams/
    key: markspec-upstreams-${{ hashFiles('markspec.lock') }}

Upgrade note. markspec lock now indexes source-file doc-comment entries in addition to Markdown. A project that pinned its lockfile with an older MarkSpec and has trace links in source files will see a one-time MSL-L212 edge-drift error from bare markspec check until you run markspec lock once to refresh the pin — the requirements didn’t change, only the set of files the lockfile indexes did. markspec check, markspec lock --check, markspec compile --frozen, and markspec doctor share an edge-drift message that includes the locked and current edge counts, the markspec lock remedy, and this possible upgrade cause. markspec doctor surfaces the same drift as a non-blocking warning (exit 2), so you can spot and clear it with markspec lock before check blocks on it in CI.

sync

Read-only commands surfacing bound-entry state from markspec.lock and the per-system NDJSON sync log under .markspec/sync/<system>/log.ndjson, at the project root markspec lock uses (see lock). push / pull / resolve / init are connector-side and ship in per-tool ADRs.

markspec sync status [system]
markspec sync log    [system]
markspec sync show   <displayId>

sync status — group bound entries by remote_state:

FlagTypeDefaultDescription
--statestring—Filter to one remote_state (ok, behind, ahead, conflict, unreachable, deleted-upstream, unbound).
--formatstringtextOutput format: json, text.

sync log — tail the per-system sync log (NDJSON). Without a system argument, it lists each system once from the .yaml mapping filenames in the same folder walk as lock, including inherited mappings and folders without a project config. It reads logs only from <project-root>/.markspec/sync/<system>/log.ndjson; logs in enclosing folders are not read.

FlagTypeDefaultDescription
--tailnumber20Number of lines from the end.
--opstring—Filter to one op: push, pull, conflict, resolve.
--sincestring—Filter to entries at or after this RFC 3339 timestamp.
--formatstringtextOutput format: json, text.

sync show — full sync state for one bound entry:

FlagTypeDefaultDescription
--formatstringtextOutput format: json, text.

Examples:

markspec sync status                     # all systems, grouped by state
markspec sync status jira                # one system
markspec sync status --state conflict    # only conflicting entries
markspec sync log jira --tail 50 --op conflict
markspec sync show STK_BRK_0001

Documents

doc build

Generate a single-document PDF via Typst.

markspec doc build <file>
FlagTypeDefaultDescription
-o, --outputstring<file>.pdfOutput file path

Examples:

markspec doc build docs/spec.md
markspec doc build -o output/spec.pdf docs/spec.md

Books

book build

Generate a multi-chapter static HTML site from a SUMMARY.md.

Not currently used to build the published MarkSpec docs site — that still builds via mdBook until the native renderer reaches chrome parity (sidebar navigation, search, syntax highlighting, a print stylesheet, and a light/dark theme toggle). See #804 for the tracking issue and exit criteria.

markspec book build
FlagTypeDefaultDescription
-o, --outputstring_siteOutput directory
-s, --summarystringSUMMARY.mdSUMMARY.md path

Examples:

markspec book build
markspec book build -o dist -s docs/SUMMARY.md

Each chapter’s output filename is derived from its SUMMARY.md-declared path: .md is stripped and nested directory separators flatten to hyphens (recipes/deploy.md → recipes-deploy.html). A Markdown link (or link reference definition) in one chapter that points at another chapter’s source path — resolved relative to the linking chapter’s own directory, not the flattened output layout — is rewritten to that chapter’s output filename, preserving any #fragment. Links to files outside the book (external URLs, absolute paths, or a chapter declared in SUMMARY.md with no backing file) are left untouched.

Chapter images render with their normal Markdown alt text and optional title. Standalone figures use the italic Figure: caption that follows the image, or fall back to its alt text. The build copies chapter-relative image files from within the project to _assets/ in the output directory, preserving their project-relative paths so identical filenames can coexist. The generated image URLs keep any query string or fragment. External and root-relative image URLs pass through. When a local image is missing, unreadable, or outside the project, the build preserves its URL, writes the site, and exits with status 2 after reporting the warning.

If two distinct chapters flatten to the same output slug (e.g. recipes/deploy.md and recipes-deploy.md both → recipes-deploy.html), the build fails with error[MSL-K001] and writes nothing rather than silently overwriting one chapter with the other — rename one chapter to disambiguate.

Profile and diagnostics

profile show

Show the active profile chain and effective configuration.

markspec profile show
FlagTypeDefaultDescription
--formatstringtextOutput format: json, text

When the active profile delivers documents (ADR-030), the text output gains a Delivered documents block listing each file’s path, role (corpus with an entry count, or doc with its description), and providing tier — plus any missing-file issue (PROFILE-DELIVERS-001/-002):

Delivered documents (2):
  - reference/platform.md   corpus   1 entries   [platform-arch]
  - reference/guide.md   doc      Integration guide (read-only reference)   [platform-arch]

--format json includes the same list under a delivers key.

profile new

Scaffold a new profile directory with a starter manifest.

markspec profile new <id>

<id> must be lowercase alphanumeric with hyphens, optionally scoped (@org/name).

markspec profile new my-profile
markspec profile new @acme/iso26262

Creates <id>/markspec.yaml and <id>/README.md.

profile add

Add a profile to the project’s .markspec.yaml.

markspec profile add <spec>

<spec> is a local path or a scoped package name.

markspec profile add ./profiles/my-profile
markspec profile add @acme/compliance-profile

profile publish

Validate a profile manifest for publishability and print any issues.

markspec profile publish [--dir <dir>] [--format json|text]

Checks required fields (id, version), warns about missing description and license, and reports any manifest validation errors. Exits 0 when the manifest is publish-ready.

profile describe

Show full details for a profile element (type, attribute, relation, label, or convention).

markspec profile describe <kind> <name>

kind is one of: type, attribute, relation, label, convention.

markspec profile describe type requirement
markspec profile describe attribute ASIL
markspec profile describe relation Satisfies

doctor

Project health check: verifies project.yaml, profile configuration, and project structure.

markspec doctor
FlagTypeDefaultDescription
--formatstringtextOutput format: json, text

When the active profile delivers documents (ADR-030), doctor reports the document count, corpus entry count, and any health issue (declared-but-missing file, corpus parse failure):

Delivered documents: 2 (1 corpus entries)

When a markspec.lock is present, doctor also reports whether the project’s traceability edges still match the pin, using the same offline comparison check’s MSL-L212 gate performs. Drift is a warning (exit 2) here — the proactive onramp so a stale lockfile is surfaced before a markspec check goes red on it (check keeps the hard MSL-L212 error, exit 1):

⚠ Lockfile: traceability edges drifted from markspec.lock: locked 12 edge(s), current 15 — run `markspec lock` to refresh. (After upgrading MarkSpec this can also fire once because traceability inputs now include source-file doc comments; re-running `markspec lock` clears it.)

--format json adds a lockfile block:

{
  "lockfile": {
    "present": true,
    "edgeDrift": true,
    "lockedEdges": 12,
    "currentEdges": 15
  }
}

present is false when the project has no markspec.lock. The edgeDrift/lockedEdges/currentEdges fields appear only when the lockfile parses; a present-but-malformed lockfile reports present: true with the drift fields omitted. A malformed lockfile is unhealthy: doctor reports the lockfile parser’s diagnostic codes and messages (for example, MSL-L001) as warnings in text output and in the JSON diagnostics array, and exits 2. It skips the edge comparison rather than claiming the edges are in sync. check reports the same parse failures as errors and exits 1. The drift warning uses the non-MSL doctor code lockfile-edge-drift, listed in the shared diagnostics array. See the lock Upgrade note for the one-time post-upgrade drift and how to clear it.

Maintenance

self-upgrade

Download and atomically replace the running markspec binary with the latest release (or a pinned version).

markspec self-upgrade
FlagTypeDefaultDescription
--checkboolfalseCheck only; exit 1 if a newer release is available
--versionstring—Pin a specific release (downgrade allowed)
--formatstringtextOutput format: json, text

Examples:

markspec self-upgrade              # upgrade to the latest release
markspec self-upgrade --check      # CI/cron: exit 1 when an update exists
markspec self-upgrade --version 0.10.2

AI agent integration

mcp

Start the MarkSpec MCP server. Communicates over stdio JSON-RPC. Exposes every MarkSpec project it finds as MCP resources and tools to any MCP-capable AI client (Claude Code, Claude Desktop, GitHub Copilot in VS Code, OpenCode).

markspec mcp
Project discovery

markspec mcp resolves its start folder from the first of these that contains a project.yaml or .markspec.yaml (walking upward from each):

  1. --root <path> — pass the flag once per candidate root.
  2. MARKSPEC_PROJECT_ROOT — colon-separated list of candidate roots.
  3. CLAUDE_PROJECT_DIR — injected automatically by Claude Code (v2.1.139+); no configuration needed.
  4. The server’s launch working directory.

From that folder the server also searches downward and serves every project it finds below it, each as a separate project. A monorepo opened at a parent directory therefore needs no extra configuration. See Several projects in one folder.

If none resolves, every MarkSpec tool replies with a message that begins “No MarkSpec project found …” and names the directories it searched. Set --root or MARKSPEC_PROJECT_ROOT to point the server at your project — this is the reliable fix when it is launched from outside the project tree (for example a user-scoped MCP install, whose working directory is the plugin cache).

markspec mcp --root /path/to/your/markspec-project
Resources
  • markspec://profile — distilled profile manifest (types, attributes, link kinds, labels).
  • markspec://entries — index of all project entries, grouped by type.
  • markspec://entry/{displayId} — one entry per resource, with attributes, body, outgoing/incoming links.
Tools
  • entry_search { query, limit? } — rank-search entries by display ID and title.
  • entry_context { id, depth? } — walk the satisfies chain upward.
  • validate { files? } — run the validator, return a Markdown diagnostics report. The report holds the same pipeline diagnostics as bare markspec check, including MSL-L006 and MSL-T014, but not its format drift, lockfile drift, MSL-L215 pin advisory, listing-document, or prose lint gates.
  • markspec_refresh — force-invalidate the compile cache and search for projects again (call after agent edits to guarantee freshness).
  • project_list — list each discovered project with its label, root, profile, and entry count.

With several projects, every tool except project_list accepts an optional project argument (a label from project_list) that limits the answer to that project.

Claude Desktop config

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "markspec": {
      "command": "markspec",
      "args": ["mcp"],
      "cwd": "/path/to/your/markspec-project"
    }
  }
}

Restart Claude Desktop. The MarkSpec resources and tools appear in the attach menu.

Claude Code
claude mcp add markspec --command markspec --args mcp --cwd /path/to/project
VS Code (Copilot)

The markspec-ide extension auto-registers the MarkSpec MCP server with VS Code 1.101+ — install the extension and the server appears in Copilot’s MCP picker. See Editor and LSP integration — VS Code below.

For users who don’t run the extension, the manual recipe still works. Add a .vscode/mcp.json in your project:

{
  "servers": {
    "markspec": {
      "command": "markspec",
      "args": ["mcp"]
    }
  }
}

Copilot does not support MCP resource subscriptions today, but the markspec:// resources still work — the server runs a fresh staleness check on every read, so a re-read after an edit returns up-to-date content.

mcp install

Print MCP server configuration for a client. The output is the client’s native config snippet — pipe it to the client’s settings file or copy-paste it.

markspec mcp install --client <client>
FlagTypeDefaultDescription
--clientstring—Client ID: claude, cursor, opencode, vscode, copilot.
--scopestringclient defaultConfig scope: user or workspace. Honoured by copilot; other clients are fixed to one scope.
--binary-pathstringinvoked binary nameExplicit path to the markspec binary. Default writes the invoked name (resolves via PATH, surviving package upgrades).

Examples:

markspec mcp install --client claude                  # → .mcp.json (workspace)
markspec mcp install --client cursor
markspec mcp install --client vscode
markspec mcp install --client copilot                 # → .github/mcp.json
markspec mcp install --client copilot --scope user     # → ~/.copilot/mcp-config.json
markspec mcp install --client claude --binary-path /opt/markspec/bin/markspec

lsp install

Print LSP server configuration for an editor. The output is the editor’s native config snippet (JSON for VS Code, Lua for Neovim, JSON for Zed) — pipe it to the editor’s settings file or copy-paste it.

markspec lsp install --editor <editor>
FlagTypeDefaultDescription
--editorstring—Editor ID: vscode, neovim, zed.
--binary-pathstringinvoked binary nameExplicit path to the markspec binary. Default writes the invoked name (resolves via PATH, surviving package upgrades).

Examples:

markspec lsp install --editor vscode
markspec lsp install --editor neovim
markspec lsp install --editor zed
markspec lsp install --editor vscode --binary-path /opt/markspec/bin/markspec

Install timeout (never hang)

mcp install and lsp install read the target config file before writing. Under extreme host load — many concurrent markspec processes, a contended filesystem, or a locked config file — that read can stall. Rather than hang silently, both commands run under a watchdog: if the work does not finish within a deadline, they print a diagnostic to stderr and exit non-zero (1).

The deadline defaults to 10 seconds (normal runs finish in well under one). Override it with the MARKSPEC_INSTALL_TIMEOUT_MS environment variable — for example MARKSPEC_INSTALL_TIMEOUT_MS=30000 to wait 30 seconds on a slow host. A missing, blank, or non-positive value keeps the 10-second default.

Limitation. The watchdog runs inside the process, so it can only fire once the runtime has started. If a launch wedges even earlier — in the operating system’s process loader, which can happen under heavy fork/exec pressure — no in-process timer can catch it. In that case, supervise the command externally (timeout 15 markspec mcp install …) or register the server through your client directly, e.g. claude mcp add markspec -- markspec mcp.

Not yet implemented

These commands are registered but print an error and exit:

CommandIntended purpose
book devLive preview with hot reload
deck buildSlides → PDF via Touying/Typst
deck devLive slide preview

Editor and LSP integration

MarkSpec ships a built-in Language Server Protocol (LSP) server. Run it with:

markspec lsp

The server communicates over stdio JSON-RPC — the standard transport that every LSP-capable editor supports.

Features

Diagnostics — broken references, missing IDs, duplicate display IDs, and malformed entries appear as inline errors and warnings as you type. File-local checks run immediately; cross-file validation runs on save. The traceability diagnostics (MSL-L006, MSL-T014) need a profile, as in markspec check: the bundled default profile applies unless default-profile: false is set. MSL-T014 also needs dependencies: or references: in project.yaml.

Entry block completion — type - [ at the start of a line to get a pre-filled entry block scaffold with the next available display ID for each type defined in your profile. For a type whose numbered pattern has a {scope} placeholder, you get one scaffold per scope already in the project, with the next number in that scope, plus one scaffold with a SCOPE tab stop. Typing the scope after the bracket (- [SRS_BRK_) offers the next number in that scope.

ID reference completion — after a trace attribute keyword (Satisfies:, Derived-from:, Verifies:, Tests:, etc.) the server suggests all known display IDs in the project.

Document links — the Source: value of an entry is clickable, in Markdown files and in source doc comments. Source holds one value, and the whole value is one link target. An http:// or https:// value opens as is. Any other value is a file path: it resolves against the project root, or is used as is when it is absolute. A Windows drive path such as C:\x\y.rs is absolute only when the server runs on Windows; on other systems it is joined to the project root. A trailing :<line> or :<line>:<col> opens the file at that line. A path gets a link only when it names an existing file, so a value such as a display ID gets none. Entries delivered by a profile or an upstream have no links.

Source file context guard — in source files (Rust, Kotlin, Java, C, C++, TypeScript, TSX, JavaScript, C#), completions only activate near entry markers or trace keywords. The server won’t interfere with your language’s native LSP (rust-analyzer, kotlin-lsp, etc.).

Project resolution

The server validates each document against the project that owns it:

  • Primary project. From the editor’s workspace root, the server walks up to the nearest project.yaml. If there is none, it walks up to the nearest .markspec.yaml. If there is neither, the workspace root itself is the primary project and the bundled default profile applies. The MCP server and the CLI use the same order, so project.yaml, markspec.lock, and the upstream cache are read from the same folder in every surface. A workspace opened on a subfolder such as docs/ therefore still loads the profile declared above it. In the CLI, check, fmt, and lint resolve the project of each file argument from the file’s own directory, and a bare invocation resolves it from the current directory (see Which project a file belongs to). The CLI, the LSP server, and the MCP server therefore load the same profile for the same file.
  • Nested projects. Every directory below the primary project that a document walk-up would resolve to — a directory with a project.yaml, or a directory with a .markspec.yaml and no project.yaml between it and the primary project — is a separate project with its own profile, index, and markspec.lock. The search honors .gitignore, the primary project’s exclude: list, and the exclude: list of each nested project for the folders below it: a directory covered by the exclude: list of a nested project above it is not a project of its own. A workspace opened on a parent folder of several projects validates each project against its own profile.
  • Ownership. A file belongs to its nearest project. A parent project does not index the files of a nested project, so a display ID that is declared once in each of two projects is not reported as a duplicate. Completion, hover, go-to-definition, references, and rename stay inside the project that owns the document. Workspace symbol search covers every project.
  • Open buffers. While a file is open in the editor, the server indexes the editor buffer, not the file on disk, including during the startup index.
  • Startup. A document opened before the startup index has finished is routed only once every nested project is known. Its first diagnostics therefore wait for the whole startup index; the trade-off avoids validating the document against the wrong project.
  • Files outside the workspace. A document that lies outside every known project walks up to its own project.yaml (else .markspec.yaml); that project is loaded and indexed when the document opens. With no config above it, the document joins the primary project. Config files of such a project are not watched: edit them, then restart the language server.
  • Changes. Editing a .markspec.yaml, project.yaml, or markspec.lock reloads only the project that owns that file: the profile, the tool config, the lockfile, and the delivered and upstream corpora. Creating or deleting a project.yaml or .markspec.yaml, or changing an exclude: list, re-discovers all projects and indexes them again.
  • Primary root above the workspace folder. Editors watch files only inside the workspace folder by default. When the primary project root lies above it, the server asks the editor to also watch that root’s .markspec.yaml, project.yaml, and markspec.lock with an LSP 3.17 relative watch pattern. An editor that does not support relative watch patterns does not report changes to those three files; restart the language server after you edit them. The server logs a warning once in that case.

VS Code

Install the MarkSpec extension from the editors/vscode/ directory in this repository. The extension requires VS Code 1.101 or newer (the version that introduced the stable MCP extension API).

The extension provides two integrations in one install:

  • LSP — diagnostics, completions, and entry-block scaffolding in the editor.
  • MCP — registers a markspec MCP server with VS Code so Copilot (and any other MCP-aware client) can use the project’s resources and tools without a separate .vscode/mcp.json.

Both point at the same markspec binary, resolved from markspec.server.path.

From source

cd editors/vscode
npm install
npm run compile

Then in VS Code: Extensions → ⋯ → Install from VSIX or press Ctrl+Shift+P → Extensions: Install from VSIX… and select the .vsix file, or use the development host:

code --extensionDevelopmentPath=editors/vscode

Configuration

SettingDefaultDescription
markspec.server.path"markspec"Path to the markspec binary (used by both LSP and MCP).
markspec.server.args["lsp"]Arguments passed to start the LSP server.
markspec.mcp.enabledtrueRegister the MarkSpec MCP server with VS Code.
markspec.mcp.args["mcp"]Arguments passed to start the MCP server.
markspec.trace.server"off"Trace level: off, messages, or verbose.

If markspec is not on your PATH, set the full path:

{
  "markspec.server.path": "/home/you/.local/bin/markspec"
}

MCP server

Once the extension is installed, the MarkSpec MCP server appears in Copilot’s MCP picker — no .vscode/mcp.json required. To disable the registration:

{
  "markspec.mcp.enabled": false
}

The manual .vscode/mcp.json recipe in mcp — VS Code (Copilot) remains supported for editors that don’t run the extension.

Neovim

Neovim’s built-in LSP client works out of the box. Add this to your init.lua:

vim.api.nvim_create_autocmd("FileType", {
  pattern = { "markdown" },
  callback = function()
    vim.lsp.start({
      name = "markspec",
      cmd = { "markspec", "lsp" },
      root_dir = vim.fs.root(0, { "project.yaml", ".git" }),
    })
  end,
})

For source files (Rust, Kotlin, etc.) where MarkSpec entry blocks appear in doc comments, add the relevant file types to the pattern list:

pattern = { "markdown", "rust", "kotlin", "java", "c", "cpp" },

The server’s context guard ensures it only activates near MarkSpec entry markers, so it won’t conflict with rust-analyzer or other language servers running on the same buffer.

With nvim-lspconfig

If you use nvim-lspconfig, add a custom server definition:

local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")

if not configs.markspec then
  configs.markspec = {
    default_config = {
      cmd = { "markspec", "lsp" },
      filetypes = { "markdown", "rust", "kotlin", "java", "c", "cpp" },
      root_dir = lspconfig.util.root_pattern("project.yaml", ".git"),
    },
  }
end

lspconfig.markspec.setup({})

Other editors

Any editor with LSP support can use markspec lsp. The server expects:

  • Transport: stdio (stdin/stdout JSON-RPC)
  • Trigger characters: [ (block scaffold) and : (ID reference)
  • Document sync: full text on each change

Point your editor’s LSP client at markspec lsp and it should work. If your editor needs a specific configuration example, please open an issue.