UNPKG

akm-cli

Version:

akm (Agent Knowledge Manager) — a portable, local-first capability library for AI agents. Discover, load, share, and improve reusable skills, scripts, workflows, and knowledge across any shell-capable coding agent, including Claude Code, OpenCode, and Cur

178 lines (140 loc) • 8.89 kB
# Use AKM With Any Agent AKM works from any shell-capable coding agent — Claude Code, OpenCode, Cursor, Windsurf, Aider, and others. No plugins or SDKs are required for the core workflow: a three-line system prompt block plus shell access is all an agent needs to start using your bundle. ## AGENTS.md / CLAUDE.md snippet Add this block to your `AGENTS.md`, `CLAUDE.md`, or system prompt. It tells the agent that `akm` is available and how to discover it. ```markdown ## Resources & Capabilities You have access to a searchable library of scripts, skills, commands, agents, knowledge, workflows, env files, secrets, lessons, memories, tasks, sessions, and facts via the `akm` CLI. Use `akm -h` for details. ``` That is the minimum. The agent can then run `akm curate <task>` at the start of any complex task to pull the most relevant assets into context, and `akm show <ref>` to load any asset by ref. For a longer, agent-facing instruction block — usage patterns, flag guidance, the full ref format — generate one instead of hand-writing it: ```sh akm hints >> AGENTS.md ``` The output is written for agents rather than humans: it describes the lookup workflow (`curate` → `show` → `feedback`) and explains how refs work. It prints the short guide. ## The retrieval loop: curate, show, feedback Once an agent knows `akm` is available, the working pattern is always the same three calls: ```sh # 1. Curate assets for the current task akm curate "deploy to production" --limit 3 # 2. Load the best match by ref from the curate output akm show workflows/deploy-to-prod # 3. Record outcome akm feedback workflows/deploy-to-prod --positive --reason "Completed without issues" ``` **Get refs from search.** Agents should call `akm search` or `akm curate` to discover refs rather than guess them. Both return a `ref` at the default detail level; pass it to `akm show`. `--detail agent` additionally returns each hit's `path` and `editable` flag, for agents that read or edit the file directly. For a long document, `akm show <ref> --outline` returns its outline (`toc`, no body), and `akm show <ref>#<slug>` then loads only the sections the task needs. Feedback closes the loop. Record `--negative` only when the asset's content is wrong or stale; a note that simply did not fit the task is not negative feedback, so record nothing for it. `akm feedback <ref> --negative --reason "<what is wrong and what should change>"` flags the asset, and the next improve run may repair its description, title or `when_to_use` from your reason. Once you have verified the correct fact, attach the exact fix with `--replace`, `--with` and `--source`. `--positive` records that an asset helped (it raises its ranking) and does not trigger a rewrite. See [Improve the Library](improve-the-library.md) for what happens to feedback after it's recorded. ## Compatibility matrix Not every agent surface integrates with AKM the same way. The table below sets expectations by environment. | Environment | Core support | Optional/extended support | | --- | --- | --- | | Shell-capable coding agent | `curate` / `show` / `feedback` via the CLI | Generated prompt block (`akm hints`) or a platform plugin | | Claude/OpenCode project layout | Indexed in place through a `BundleAdapter` — no migration needed | `akm import --asset-ref` selected assets into a writable bundle for editing | | IDE assistant without shell access | Not a direct core integration | Requires a plugin, an `akm task`, or an external bridge that can shell out on the assistant's behalf | A Claude Code `.claude` directory or an OpenCode `.opencode` directory is recognized and indexed automatically once added as a source — see [Bundle Types](../reference/bundle-types.md) for the full adapter list and which formats are read-only versus writable in the current release. The native directory remains the source of truth: AKM translates recognized assets while reading the bundle and does not synchronize, copy, or write them back. Execution of these translated agents and commands is described in [Architecture: Connections and Harnesses](../architecture/architecture.md#connections-and-harnesses). ## AKM complements, rather than replaces AKM is not a competitor to assistant-native rules/skills or to MCP — it fills a different layer. Assistant-native rules and skills give a specific tool built-in, tool-specific activation. MCP exposes live tools and resources over a protocol. AKM manages portable, versionable capability assets — and the retrieval loop that finds and loads them — across whichever tool you're sitting in. In short, AKM complements MCP and assistant-native skills rather than replacing either. ## Also available - **Tab completion.** `akm completions --install` sets up shell completions for subcommands and flags. See [CLI Reference](../reference/cli.md#completions). - **Dispatching a bundle agent asset.** `akm run agents/<name> --harness <harness> --prompt "..."` runs a bundle `agents/<name>` persona and model default on a harness (or on akm's own runtime over a connection, with `--connection <name>`), with the aliases `fast`, `balanced` and `reasoning` resolved on whichever you select. See [Configuration](../reference/configuration.md#aliases) for the aliases and [Architecture](../architecture/architecture.md#connections-and-harnesses) for how dispatch reaches each harness. The harness runs as you would run it by hand ([how](../reference/configuration.md#how-akm-runs-a-harness)). - **Install refs vs. asset refs.** `npm:@scope/pkg` and `github:owner/repo` are install refs, accepted only by `akm bundle add`/`akm import --asset-ref`, and are a different grammar from the `[bundle//]conceptId` refs `show`/`search` use. See [Refs](../reference/refs.md) for the full grammar. - **Plugin integrations.** For tighter editor and agent integrations, platform-specific plugins are available in [akm-plugins](https://github.com/itlackey/akm-plugins) (current integrations include Claude Code, Codex and OpenCode). Plugins add richer UX — in-editor asset browsing, automatic context injection — but the core `akm` CLI works without them. ## OpenCode plugins: one package per OpenCode major OpenCode 1 and OpenCode 2 load different plugin APIs, so akm ships one plugin package for each. Install only the one that matches the `opencode` you run; akm never installs or replaces the `opencode` binary, and `akm upgrade` never adds one plugin to the other major's config. | OpenCode | Plugin package | Config key | Plugin cache | | --- | --- | --- | --- | | 1 | `akm-opencode` | `"plugin"` | `~/.cache/opencode/packages/akm-opencode@<tag>/` | | 2 | `akm-opencode-v2` | `"plugins"` (the key `opencode plugin add` writes) | `~/.cache/opencode/npm/akm-opencode-v2@<tag>/<build>/` | (`$XDG_CACHE_HOME` and `$XDG_CONFIG_HOME` move both.) Both packages declare the same `akm-cli` dependency. OpenCode 1 is deprecated as the `opencode` harness and removed in 0.11 (see [STABILITY.md](../../STABILITY.md)); use OpenCode 2. **OpenCode 1.** Add `akm-opencode` to the global config (`~/.config/opencode/opencode.json`): ```json { "plugin": ["akm-opencode"] } ``` **OpenCode 2.** ```sh opencode plugin add akm-opencode-v2 ``` This installs the package and adds it to `plugins` in the global config. **Updating.** `akm upgrade` refreshes the cached plugin of each major it finds, holds the CLI to the `akm-cli` those plugins pin, and leaves a plugin alone whose config pins another spec such as `akm-opencode@0.8.0`. Use `akm upgrade --channel next` with `akm-opencode@next` / `akm-opencode-v2@next` in the config to follow prereleases. The exact rules are in the [`akm upgrade` reference](../reference/cli.md#harness-plugins). `akm doctor` warns when either plugin's bundled `akm-cli` differs from the running CLI. **Which OpenCode akm runs** does not depend on the plugin: the `opencode` harness runs your OpenCode through its CLI (OpenCode 2; OpenCode 1 still runs through 0.10 and prints a deprecation notice), and akm's own runtime fetches and runs its own pinned one (see [Configuration](../reference/configuration.md#without-a-harness)). Install the plugin for the OpenCode you use yourself. ## See also - [Configuration](../reference/configuration.md#connections) — connections, harnesses and model aliases - [Discover and Load](discover-and-load.md) — the full curate → show retrieval path - [Capture Knowledge](capture-knowledge.md) — capturing agent-generated memories - [Improve the Library](improve-the-library.md) — feeding back usage signals - [CLI Reference](../reference/cli.md) — `completions` and `hints` command documentation - [Concepts](concepts.md) — bundles, adapters, refs, and the asset type system - [Bundle Types](../reference/bundle-types.md) — how AKM indexes existing project layouts in place