Directory-Specific API Keys
Use a different memory project for each project directory, while keeping one general fallback.
Audaxic API keys are scoped to a single project. If you map a directory to a key, every memory read and write made by an agent opened in that directory goes to that key's project. The same mapping works across Claude Code, Codex, and OpenCode, so switching agents in the same directory keeps the same memory.
Configure
The mapping lives in ~/.config/audaxic/config.json:
{
"apiKey": "ak_general...",
"directoryKeys": {
"C:\\projeler\\my-project": "ak_project_a...",
"C:\\projeler\\another-project": "ak_project_b..."
}
}
Use any plugin's CLI to manage it:
# General fallback
npx @audaxic/memory-claude key set --global
# Key for the current directory
cd C:\projeler\my-project
npx @audaxic/memory-claude key set
# Inspect
npx @audaxic/memory-claude key list
npx @audaxic/memory-claude key resolve
The commands are identical for @audaxic/memory-codex and @audaxic/memory-opencode; they all read and write the same shared config.
To remove a directory mapping:
npx @audaxic/memory-claude key remove
Resolution order
For every operation, the plugin chooses the key in this order:
AUDAXIC_API_KEY— explicit environment override- The nearest matching
directoryKeysentry - The Claude plugin's
CLAUDE_PLUGIN_OPTION_API_TOKEN(Claude only) - The general
apiKey
If none is set, the plugin disables itself without blocking the agent.
key list and key resolve warn when AUDAXIC_API_KEY is set and overriding the directory mapping.
Directory matching
- Paths are resolved to their real absolute path.
- Windows paths are compared case-insensitively and with normalized separators.
- The most specific parent wins:
repo/packages/apiuses a key forrepo/packages/apiif present, otherwise the key forrepo. - A git worktree with no direct mapping falls back to its main checkout's key. A worktree-specific entry overrides that.
Parallel agents
Every parked message stores the API key it was captured with. A hook or background drain running in directory B can flush a message captured in directory A, but it always sends A's message with A's key. Atomic claim files keep multiple agents from sending the same message twice.
This matters for:
- Two agents in the same directory — they share the same project, as intended.
- Two agents in different directories — each keeps its own project.
- Git worktrees — they use the main checkout's key unless mapped separately.
- OpenCode v2 — one background service can serve multiple workspaces; the plugin resolves the key per workspace and stores it with each message.
Per-client behavior
| Client | Auto-save / search | Manual MCP tools |
|---|---|---|
| Claude Code | Directory-aware | Directory-aware local stdio proxy |
| Codex | Directory-aware | Directory-aware http_headers_helper |
| OpenCode | Directory-aware | Use the plugin; no MCP proxy is required |
The OpenCode plugin does not use MCP for its own save/search path. If you configure the hosted MCP server separately in OpenCode, that static configuration is outside the plugin.
Security
- The config file is created with mode
0600in your user profile. - Keys are never written into a repository.
- Pending message files also use mode
0600and may contain the key captured with that message until it is delivered. - On Windows,
0600is advisory; the file is protected by the account's profile permissions.
Troubleshooting
npx @audaxic/memory-claude key resolve
Example output:
Directory: C:\projeler\my-project\packages\api
Resolved: directory key (ak_12345...cdef)
Matched: C:\projeler\my-project
If it shows the general key, add a mapping for the directory or a parent. If it shows the environment override, unset AUDAXIC_API_KEY for the agent process.
If it still uses the wrong project, confirm the agent is running in the mapped directory. Claude Code resolves CLAUDE_PROJECT_DIR, Codex uses the session cwd, and OpenCode uses the workspace directory.