Ref Format
A ref is the identifier that akm search returns for items and akm show
consumes.
Agents should not parse refs or construct them by hand. The intended flow is:
search -> pick a hit -> pass its ref to show
This document is the normative ref grammar.
Item Refs
Item refs use this wire format:
[bundle//]conceptId[#fragment]
| Part | Required | Description |
|---|---|---|
bundle |
no | Workspace bundle slug (e.g. personal, team-catalog) that owns the item. Separated from the rest of the ref by //. When omitted, CLI input resolves against defaultBundle first and then the remaining bundles in installation-priority order. |
conceptId |
yes | Adapter-defined path within the bundle, /-separated and canonicalized by that adapter. Examples: knowledge/http-caching, skills/code-review, scripts/db/migrate/run.sh, tables/customers. |
fragment |
no | Selects a section of a Markdown item. On any other item akm show warns and shows the whole item. See Fragments. |
type is not part of a ref. Identity is a path, not a type:name pair, and a
conceptId is an opaque path — akm does not parse meaning out of its
segments. skills/deploy and workflows/deploy are distinct concepts because
their paths differ, not because their first segment is a recognized word.
An item's type is an attribute of the resolved item, supplied by the
selected adapter, not a predicate parsed out of the ref string. The okf
adapter reads it from OKF frontmatter; the akm adapter derives it from its
native matcher and placement rules. This is why a ref into any bundle —
okfbundle//tables/customers, wiki//pages/attention — is just as addressable
as personal//memories/vpn-note. See okf-support.md.
Refs are parsed by parseBundleRef in src/core/asset/asset-ref.ts. The
grammar is:
ref := [ bundle "//" ] concept-id [ "#" fragment ]
bundle := any run of non-space chars excluding : . # /
concept-id := adapter-canonical path within the bundle, / -separated, NFC, case-sensitive
fragment := section slug (Markdown items)
The bundle slug excludes :, ., #, /, and whitespace so a bundle//conceptId
token is lexically distinct from a URL (whose scheme carries a : before //) and
so the first // unambiguously bounds the bundle.
AKM concept ids and adapter layouts
A ref is the item's path inside its bundle minus the type's own file suffix
(.md, /SKILL.md, .env, .yml; scripts and secrets keep their name). That
holds for a file under its type's folder and for one anywhere else:
knowledge/auth.md is knowledge/auth, tools/agents/foo.md is
tools/agents/foo, projects/openpalm/knowledge/auth.md is
projects/openpalm/knowledge/auth, and reports/data.js is reports/data.js.
The type folder is where akm places a new asset, not part of how it names an
existing one: an existing asset's type is the one its index entry records, never
read from the ref's first folder. (akm remember, akm import --type and the
other commands that create an asset still pick its folder from the type you
name.) Two files that give the same ref (tasks/x.md and tasks/x.yml) are
reported as a collision.
Earlier releases gave a file outside its type's folder the ref
<type folder>/<its path> (reports/x.md was knowledge/reports/x). That
spelling is still in links, memories and scripts, so a ref that misses is tried
once without its first folder when that folder is a type folder, resolves to the
asset, and warns once that the ref is outdated. The first akm index after the
upgrade carries the history stored under the old spelling to the new one.
The subdirectory prefix is the item's placement directory:
| Subdir | Holds | Example conceptId |
|---|---|---|
scripts/ |
Executable scripts | scripts/deploy.sh |
skills/ |
Skill directories (SKILL.md) |
skills/code-review |
commands/ |
Slash-command templates | commands/release |
agents/ |
Agent definitions | agents/reviewer |
knowledge/ |
Reference documents | knowledge/api-guide |
workflows/ |
Workflow documents / programs | workflows/ship-release |
memories/ |
Recalled context fragments | memories/deployment-notes |
lessons/ |
Distilled feedback lessons | lessons/retry-backoff |
facts/ |
Durable bundle-level facts | facts/team/tool-stack |
sessions/ |
Indexed agent sessions | sessions/claude/2026-07-24-abc |
env/ |
.env configuration groups |
env/prod |
secrets/ |
Single sensitive values | secrets/deploy-token |
tasks/ |
Scheduled / on-demand tasks | tasks/nightly-sync |
These are the subdirs the akm adapter places into and interprets according
to its own matcher rules. Other bundles use whatever paths their adapters
declare — an OKF bundle emits tables/customers, an LLM wiki emits
pages/attention, and a website snapshot emits its crawled path. Every one of
those is an equally valid conceptId; the core does not require the leading
segment to be an AKM placement directory.
Examples
scripts/deploy.shskills/code-reviewknowledge/api-guidecommands/releaseagents/reviewermemories/deployment-notesenv/prodpersonal//knowledge/http-cachingteam-catalog//workflows/releaseknowledge/api-guide#authentication(section selector)
Not item refs
viking://skills/deploy(a URI scheme — a:before//is not a bundle slug)skills/../../../etc/passwd(..segments)github:owner/repo(an install ref, parsed elsewhere)- the old
<type>:<name>spelling; only the frozen migrator parses it
Fragments
akm show is the only command that accepts a #fragment. Every other ref
boundary routes through parseRefInput, which rejects a fragment with
INVALID_FLAG_VALUE.
Markdown-document items — section selector. For an item whose adapter presents it as a markdown document, the fragment names a section:
akm show knowledge/api-guide#authentication
Resolution is: slugify each heading in the document (lowercase, non-alphanumeric
runs collapsed to -, trimmed) and match the fragment against those slugs;
fall back to a case-insensitive match against raw heading text. The selected
region runs from that heading to the next heading of the same or higher level.
A fragment that matches no heading is an error that lists the available
fragment slugs, which is how a caller discovers them; akm show <ref> --outline
returns the outline (toc, each heading with the slug that selects it) without the body. Opaque
#akm-fragment-... selectors resolve against the indexed revision; see
Architecture: Show Resolution.
Every other item. akm show ignores the fragment, warns, and shows the whole
item.
Fragments are input-only. Durable state — index rows, state keys, proposal targets, bindings — does not store a fragment, and a stored ref carrying one is invalid.
Ref-prefix enumeration (browse)
Browsing a subtree uses a conceptId prefix, matching the grammar refs are emitted in:
akm search "memories/" # every memory in scope
akm search "memories/projecta/" # one subtree
akm search "team-catalog//" # every item in one bundle
akm search "team-catalog//skills/" # one subtree of one bundle
A trailing / is required for a non-empty prefix, giving exact /-boundary
subtree semantics (projecta/ cannot match a sibling projectalpha/). A query
with interior whitespace is prose, not a prefix — it stays an ordinary keyword
search.
Enumeration is prefix-matching over conceptIds, so it covers every adapter's items uniformly, and a prefix copied out of search output works as typed.
Asset types are free-form
type is adapter-supplied metadata that presents, ranks, and filters — it
does not execute and does not identify. The OKF adapter reads the open OKF type
field and defaults it according to OKF adapter rules; other adapters derive a
type from their native formats. IndexDocument.type is an open string by
contract, and adapters emit types outside the akm adapter's placement set
(website, wiki-source, an LLM-wiki page's pageKind, instruction, and
anything an OKF bundle author writes).
Consequently akm search --type <t> is an exact string match against an open
set, deliberately unvalidated: an unrecognized type returns zero hits rather
than an error, because "unrecognized" is not a decidable property. Callers that
want a closed set should filter on conceptId prefix instead (see above).
The closed set still applies where a type must select a write placement —
akm proposal new <type> <name> — because that needs a directory to write to.
Reserved structural files
For the OKF adapter, index.md (directory listing / progressive disclosure)
and log.md (update history) are reserved structural files at every level and
are never concepts. The akm and llm-wiki adapters independently reserve
the same names as part of their own format contracts. Other adapters own their
reserved-name rules; the cross-format ref grammar does not impose OKF
structure on them. Item writes must follow the selected adapter's rules.
Install Refs (distinct grammar)
akm bundle add and one-shot akm import --asset-ref accept a different ref grammar. Install
refs locate an upstream kit to fetch; they are not item refs and are
parsed by parseRegistryRef in src/registry/resolve.ts.
install-ref := github-ref | git-url | npm-pkg | https-url | skills-sh-slug | local-path
Examples: github:owner/repo#v1.2.3, git+https://gitlab.com/org/kit,
@scope/kit, https://docs.example.com,
./path/to/kit.
The two parsers are intentionally distinct — each rejects the other's inputs.
Item refs do not carry URI schemes; install refs are not addressable through
akm show.
Bundle prefix
When a ref includes a bundle prefix, akm show narrows lookup to that bundle:
team-catalog//scripts/deploy.sh
personal//knowledge/my-notes
When absent, a short ref from CLI/API input resolves to defaultBundle if the
conceptId exists there, otherwise to the first bundle containing it in installation
priority order (first match wins, deterministically). akm does not resolve refs
found inside bundle content. The one place it checks them is akm lint's
missing-ref scan, which looks a ref up among that bundle's own files (see
Refs in prose). To pin lookup to a single bundle programmatically, use
resolveRef(input, { only: bundleId }) — there is no ref spelling for "primary
only".
Refs in prose
Refs embedded in prose must use the fully-qualified bundle//conceptId form —
the bundle-slug charset makes such a token lexically anchored — or a native
link form owned by the adapter (OKF links, wiki links). Bare short refs in
prose are not refs: memories/foo in a sentence is ordinary text, and no
tool rewrites it. akm lint's missing-ref scan checks fully-qualified refs in
body text, and bare refs in the frontmatter ref fields (xrefs, supersededBy,
contradictedBy), against the bundle's own files.
Renames and moves
A rename or move is a plain filesystem move: mv, git mv or a file manager, of a
file or of a folder. There is no move command. When akm index next runs, a file
that is gone from one path while the same content is at another path, in the same
bundle or in another indexed bundle, is the same asset: its index row, vector
and utility are kept, and the learned state keyed by its old ref (usage,
feedback, proposals, events, improve ledger, salience, outcomes) and its cached model
results follow it to the new ref. The index result reports the moves
(moves.moved), and each is recorded as a moved event on the new ref.
A file whose content also changed is a new asset, and so is one whose content
matches more than one vanished or new file and cannot be paired one to one by file
name; the index says so (moves.unpaired, and a warning) and its history stays
with the old ref.
mv ~/akm/memories/old-note.md ~/akm/memories/new-note.md
akm index
akm lint # a link to memories/old-note is a missing-ref that names its new ref
akm lint --fix # rewrites links to a moved ref, and no other link
Links to the old ref in other assets are not rewritten by the index. akm lint
reports each as a missing-ref carrying movedFrom and movedTo, and --fix
rewrites it (frontmatter and prose, outside code fences); a missing-ref with no
recorded move is never rewritten. The record of a move is the moved event, which
the events table keeps for 90 days.
Moving an item between bundles is the same filesystem move into the other bundle's folder. The bundle prefix of the ref changes, the history follows, and a bare link stays bare unless the asset moved to another bundle.
A move that also edits the file, or whose pairing was ambiguous, can still carry
its learned state by hand: run bun scripts/rekey-asset-ref.ts <old-ref> <new-ref>
from a source checkout before akm index. See
v0.9.0-troubleshooting.md for the
walkthrough.
Renaming a bundle is separate: akm bundle rename <old> <new> is the one
command that changes a bundle id. It rewrites the config bundles key,
defaultBundle and defaultWriteTarget, scheduler.enabled refs, the lockfile
entry, and the stored bundle// refs in index entries, proposals, task history,
workflow runs, recorded feedback and usage, and the improve ledger, salience, and
outcome rows, so search and improve keep counting the bundle's feedback. Refs
inside bundle content are reported, not rewritten. See
the bundle rename entry in the CLI reference.
Usage Notes
Pass the ref from search output back to show unchanged as the lookup
token.
Canonical Form
Refs are emitted in canonical form: the bundle slug (when qualified), the
adapter-canonical conceptId, and an optional #fragment. The adapter decides
whether an on-disk extension is stripped: OKF and AKM Markdown items strip
.md, scripts retain executable extensions, and directory-items such as
skills resolve on the directory path (skills/<dir>, not
skills/<dir>/SKILL).