CLI Reference

Complete reference for the standalone engrams command-line interface.

Global Usage

engrams [options] <command> [args]

Global Options

OptionDefaultDescription
--db <PATH>Auto-detectedDirect path to the SQLite .db file.
--workspace <PATH>Closest workspace rootDirectory to treat as the workspace root.
--compactfalseOutput compact JSON on a single line with nulls stripped.
--fields <FIELDS>-Comma-separated list of fields to retain in output.
-h, --help-Print help and usage information.
-V, --version-Print the version number.

Commands

1. init

Initialize the database schema at the resolved database path (creates engrams/context.db if missing).

engrams init

2. migrate

Migrate the database schema to the latest version.

engrams migrate

3. product-context

Manage the product context document.

engrams product-context get
engrams product-context update --content '<JSON>'
engrams product-context update --patch '<JSON>'

4. active-context

Manage named active-context tracks (current tasks, next steps, open questions). Each track is identified by a name — maintain separate tracks per workstream, branch, or focus area. The default track always exists.

engrams active-context get [--name <TRACK>]
engrams active-context update --name <TRACK> --content '<JSON>'
engrams active-context update --name <TRACK> --patch '<JSON>'
engrams active-context list

5. history

View historical revisions of context documents. For active-context, scope to a track with --name or list version counts across every track with --all.

engrams history <product-context|active-context> [--version <N>] [--limit <LIMIT>] [--name <TRACK>] [--all]

6. decision

Log, list, search, update, delete, or consolidate architectural decisions (ADRs). decision log checks for similar existing decisions by default and skips insertion on near-matches unless --force is passed. Always declare --contract when introducing an interface abstraction. Status is validated against a closed vocabulary — active, superseded, rejected, revisited; --force bypasses validation on updates, and decision supersede automatically flips the retired decision to superseded.

# Log a new decision with contract (fails if a similar summary exists)
engrams decision log --summary "Use Postgres" --contract "fn connect() -> Result<Conn>" --rationale "ACID required" --tags "db,sql"

# Log with an explicit initial status (default: active)
engrams decision log --summary "Use Postgres" --rationale "ACID required" --tags "db,sql" --status active

# Log a new decision unconditionally (also bypasses the similarity check)
engrams decision log --summary "Use Postgres" --rationale "ACID required" --tags "db,sql" --force

# List decisions (supports convention-aware --filter)
engrams decision list [--tags "db,sql"] [--filter "postgres"] [--limit 20]

# Search decisions using FTS5 (optionally returning snippets)
engrams decision search "Postgres" [--limit 10] [--snippets]

# Query decision curation stats (access frequency & dead knowledge audit)
engrams decision stats [--most-accessed] [--never-accessed] [--limit 10]

# Retrieve a decision by ID (reinforces access count)
engrams decision get <ID>

# Update a decision (supports --contract update)
engrams decision update <ID> [--status "superseded"] [--summary "New summary"] [--contract "New contract"] [--rationale "New rationale"] [--details "details"] [--tags "new,tags"] [--force]

# Delete a decision
engrams decision delete <ID>

# Consolidate two decisions (merges fields, contracts, repoints links, and deletes source)
engrams decision consolidate <SOURCE_ID> <INTO_ID>

# Supersede a decision with another (auto-sets the retired decision's status to 'superseded')
engrams decision supersede <ID> --by <REPLACEMENT_ID>

7. progress

Log and track tasks and subtasks. Status is validated against a closed vocabulary — Todo, InProgress, InReview, Blocked, Done, Dropped; --force bypasses validation. Use --check-similar to prevent logging duplicate entries for the same status and description.

# Log progress (status must be in the closed vocabulary)
engrams progress log --status "InProgress" --description "Database schema setup" [--parent-id <ID>] [--check-similar] [--force]

# List progress
engrams progress list [--status "Done"] [--parent-id <ID>] [--limit 20]

# Retrieve a task by ID
engrams progress get <ID>

# Update a task (--force bypasses status validation)
engrams progress update <ID> [--status "Done"] [--description "New description"] [--parent-id <ID>] [--force]

# Delete a task
engrams progress delete <ID>

8. pattern

Log and track design patterns and codebase conventions.

# Log a pattern
engrams pattern log --name "API response format" --description "Always return JSON with status code" --tags "api,rules"

# List patterns
engrams pattern list [--tags "api"] [--limit 20]

# Get a pattern by ID
engrams pattern get <ID>

# Delete a pattern
engrams pattern delete <ID>

9. custom

Store arbitrary key-value pairs grouped by category.

# Set a value (string or JSON)
engrams custom set --category "config" --key "api_host" --value "localhost:8080"
engrams custom set --category "config" --key "features" --value '{"auth": true}' --json

# Get a value
engrams custom get --category "config" [--key "api_host"]

# Search custom values using FTS5 (optionally returning snippets)
engrams custom search "localhost" [--category "config"] [--limit 10] [--snippets]

# Delete a value
engrams custom delete --category "config" --key "api_host"

10. link

Create and list relationships (edges) in the workspace knowledge graph. Canonical relationships (e.g. supersedes, depends_on, refines, conflicts_with, implemented_in) are validated against their declared domain/range and algebraic rules; link add rejects violations unless --force is passed. See the Knowledge Graph page for the full relationship vocabulary.

# Link two entities (canonical rels are validated; --force overrides violations)
engrams link add \
  --source-type system_pattern --source-id 1   --target-type decision --target-id 7   --rel implements \
  --description "Verify JWT middleware implements decision 7" [--force]

# List links
engrams link list --item-type decision --item-id 7 [--rel implements] [--linked-type system_pattern]

11. graph

Compute and query the derived knowledge + code graph. Files are nodes; edges are derived automatically from file anchors, co-anchored/tag-overlapping entities, and git co-change history. Declared inverse relationships (e.g. superseded_by, depended_on_by) are materialized on rebuild.

# Recompute all derived edges (run after structural changes or migrations)
engrams graph rebuild

# Incrementally ingest git co-change edges (resumes from the last commit seen)
engrams graph ingest

# Node/edge counts, density, connected components, orphans, degree stats
engrams graph stats

# PageRank centrality ranking of nodes
engrams graph central

# List connected components as clusters
engrams graph clusters

# Nodes with degree <= 1
engrams graph orphans

# Shortest path between two nodes (type:id)
engrams graph path --from decision:7 --to system_pattern:2

# Nodes within N hops of a node (type:id)
engrams graph neighbors --node decision:7 --depth 2

# Transitive closure over a canonical transitive relation
# ('what transitively breaks if I revisit X?')
# rel: supersedes | depends_on | part_of | refines
engrams graph chain --node decision:7 --rel depends_on
engrams graph chain --item-type decision --item-id 7 --rel supersedes

12. activity

Get a summary digest of all modifications across the database.

engrams activity [--hours <N>] [--limit-per-type <LIMIT>]

13. report

Generate a structured project knowledge report of active context, progress, decisions, patterns, and links. Output is always JSON. Can be filtered by a specific topic. Or, open a browser-based HTML dashboard using the open subcommand. The dashboard's knowledge graph draws each confirmed schema as a node twice the size of the others, joined to its members by member_of / has_member edges.

# Generate full report in JSON format
engrams report

# Show only decisions in JSON format
engrams report decisions

# Generate and open the interactive HTML dashboard with knowledge graph
engrams report open

# Generate the dashboard HTML file at a custom path without opening a browser
engrams report open --no-browser --out /path/to/report.html

14. batch

Perform bulk operations in a single atomic transaction.

# From JSON string
engrams batch --type decision --items '[{"summary": "A"}, {"summary": "B"}]'

# From stdin
cat items.json | engrams batch --type custom_data --items -

15. export

Dump the SQLite tables (including schemas/{id}.md with statement/scope_json and schema_proposals/{id}.md) to Markdown files for Git versioning.

engrams export [--path <DIR>]

16. import

Import/update the database using exported Markdown files (including round-tripping schema proposals, schema claims/scopes, and proposal provenance).

engrams import [--path <DIR>]

17. pr

Manage PR URLs and numbers associated with decisions and patterns. Supports automatic host mapping for PR numbers if a git repository is configured, and reverse lookup via pr find.

# Attach PR URLs/numbers
engrams pr add --type decision --id <ID> --pr <PR_NUMBER_OR_URL>

# Reverse lookup: find all decisions/patterns referencing a PR
engrams pr find <PR_NUMBER_OR_URL>

# List PRs attached to an item
engrams pr list --type decision --id <ID>

# Remove a PR URL from an item
engrams pr remove --type decision --id <ID> --url <PR_URL>

18. anchor

Manage file path anchors for decisions and patterns.

# Add file anchors
engrams anchor add --type decision --id <ID> --path <FILE_PATH>

# List anchors
engrams anchor list --type decision --id <ID>

# Remove an anchor
engrams anchor remove --type decision --id <ID> --path <FILE_PATH>

19. relevant

Find decisions and patterns relevant to specified paths or staged git files.

# Query relevant items by path
engrams relevant <PATH>

# Query relevant items using staged files
engrams relevant --staged [--all]

20. prime

Generate a briefing optimized for token budget. Surfaces matching active schemas (with statement, scope, and matched_by) and up to 3 oldest undecided schema proposals in pending_proposals (with ready-to-run confirm_command and reject_command). Lists every active-context track and expands the one matching your current scope, includes a compact graph summary, and demotes superseded decisions into a compact annotated section.

# Generate briefing
engrams prime [--budget <TOKENS>] [--paths <PATHS>] [--tags <TAGS>]

21. doctor

Run database health audits: missing file anchors, dangling links, stale-decision drift detection, unlinked decisions, orphan graph nodes, graph-rebuild recommendations, cycles in canonical transitive relations (supersedes/depends_on/part_of/refines), and non-canonical relationship vocabulary linting.

engrams doctor

22. query

Unified query search across decisions, patterns, and custom data, with FTS5 highlighting and cross-convention matching (snake_case, camelCase, and kebab-case match identically). Pass --full to embed complete payloads. When a search matches 0 items, returns structured miss_guidance.

# Unified query
engrams query <QUERY> [--types decision,pattern,custom] [--tags <TAGS>] [--since <TIMESTAMP>] [--limit <LIMIT>] [--all]

# Full-payload query (kills 1+N decision get calls)
engrams query "auth" --full

23. instructions

Print agent onboarding instructions in raw markdown.

engrams instructions

24. brief

One-call composite architectural brief for a node reference or FTS query in under 200 tokens: returns decision text, contract, tags, PRs, anchors with extracted symbols/docstrings/lines, Git staleness drift, and 1-hop neighbors. For schema:<id|name>, includes statement, scope, origin, and enriched members.

# Brief by query or node reference
engrams brief "payment provider"
engrams brief decision:62 [--depth 2]
engrams brief schema:performance-rules

25. usage

Retrieval telemetry and curation feedback. Tracks call counts, constraints fired, and zero-hit searches.

# Show aggregate retrieval counts
engrams usage [--since <TIMESTAMP|2w>] [--daily]

# Rank zero-hit queries (vocabulary gaps to curate)
engrams usage --misses

26. coverage

Audit anchored-knowledge coverage, dead anchors, and median hop distance for a file set or git diff.

# Audit paths
engrams coverage src/

# Audit changed files on a branch
engrams coverage --diff main...HEAD

27. session

Record session ROI rollups (reads skipped vs required) and enforce PR validation gates.

# Close session with PR validation gate
engrams session close --reads-skipped 14 --reads-required 2 --tokens-saved 70000 --pr 42 [--note "..."] [--lens <LENS>]

# View session history and cumulative savings
engrams session history

The close payload also reports schema_value (guided_retrievals,distinct_schemas, and schemas: [{"id", "name", "guided"}] ordered most-used first) and schema_prompts (up to 3 unexplained storylines from subject-tag threads and gate-passing detector groups, each with lens questions, evidence in reading order, spread, and a ready-to-fill propose_command). Pass --lens <name> to select a built-in lens (general default, fiction, software) or a workspace lens file at<root>/engrams/lenses/<name>.json. SeeCognitive Schemas.

28. schema

Form, propose, review, and manage cognitive schemas (higher-order concepts over knowledge items). Detector groups staged by schema scan are evidence; schemas are created only when a reviewed proposal is confirmed via engrams schema confirm proposal:<id>.

# Stage candidate evidence groups from the knowledge graph (never auto-promotes)
engrams schema scan
# Preview session-close schema prompts without recording notices (lenses: general, fiction, software, or <root>/engrams/lenses/<name>.json)
engrams schema prompts [--lens <LENS>] [--limit <N>]

# Propose a reviewed schema over >=3 current notes across >=2 files or days
engrams schema propose \
  --statement "Mara believes she is broken; that hurt carries with her as she grows into a leader" \
  --trigger "writing Mara under pressure" \
  --rule "she doubts herself aloud and credits others, even as her actions grow stronger" \
  [--members decision:4,decision:7,decision:9 | --from <CANDIDATE_SIG_PREFIX>] \
  [--thread mara] [--lens fiction] \
  [--name mara-broken-leader] \
  [--scope-tags mara] [--scope-paths manuscript] \
  [--contrary decision:15] [--session <KEY>] [--force]

# List schema proposals (status: proposed | confirmed | rejected | all; default: proposed)
engrams schema proposals [--status proposed]

# Confirm a pending proposal (optionally overriding fields inline) or re-confirm an active schema
engrams schema confirm proposal:1 [--name <NAME>] [--statement "<CLAIM>"] [--summary "<SUMMARY>" | --trigger "<COND>" --rule "<RULE>"] [--scope-tags <TAGS>] [--scope-paths <PATHS>]
engrams schema confirm <SCHEMA_ID_OR_NAME>

# Reject a pending proposal (remembered so identical evidence is not re-proposed)
engrams schema reject proposal:1 [--reason "One-off migration notes, not a recurring rule"]

# Refine an existing schema's claim, scope, or agent-authored instruction
engrams schema refine <SCHEMA_ID_OR_NAME> [--statement "<CLAIM>"] [--scope-tags <TAGS>] [--scope-paths <PATHS>] [--summary "<SUMMARY>" | --trigger "<COND>" --rule "<RULE>"]

# List confirmed schemas (agent-authored ranked first; includes statement, scope, kind, guided)
engrams schema list [--status active]

# Inspect a schema's statement, summary, scope, origin, enriched members (cap 20), and centroid
engrams schema show <SCHEMA_ID_OR_NAME>

Engrams CLI automatically checks for new releases in the background (at most once every 24 hours). If a new version is available, a notification is printed to standard error.

To disable these update checks (for example, in CI environments or offline setups), set any of the following environment variables to any value:

  • ENGRAMS_NO_UPDATE_CHECK
  • NO_UPDATE_CHECK
  • CI