Skip to main content

Codex Plugin

Automatically save conversation facts and inject context into prompts.

← Back to MCP Setup


Installation​

npx @audaxic/memory-codex install

This will:

  • Prompt for your Audaxic API key (saved to ~/.config/audaxic/config.json)
  • Copy hook scripts to ~/.codex/audaxic/
  • Register hooks in ~/.codex/hooks.json

Get your API key from: memory-dashboard.audaxic.com


How It Works​

The installer registers two Codex CLI hooks:

UserPromptSubmit → recall.js​

When you submit a prompt, this hook:

  • Buffers your prompt to ~/.codex/audaxic/buffer.json
  • Searches Audaxic Memory for relevant context (POST /search)
  • Injects retrieved memories as <audaxic_memory_context> into the agent

Stop → capture.js​

When the agent finishes responding, this hook:

  • Buffers the assistant's response to ~/.codex/audaxic/buffer.json
  • When the buffer reaches 30 messages, flushes to POST /add
  • Persists to disk immediately so no messages are lost on crash

Architecture​

┌──────────────────────────────────────────────────────────────┐
│ Codex CLI │
│ │
│ User types prompt │
│ │ │
│ ▼ │
│ UserPromptSubmit ──► recall.js │
│ │ ├─ buffer user prompt to disk │
│ │ └─ POST /search → inject context │
│ ▼ │
│ LLM responds │
│ │ │
│ ▼ │
│ Stop ──────────────► capture.js │
│ ├─ buffer assistant msg to disk │
│ └─ if buffer >= 30 → POST /add │
└──────────────────────────────────────────────────────────────┘

Environment Variable Alternative​

Instead of the setup prompt, you can set the API key as an environment variable:

export AUDAXIC_API_KEY="ak_your_key_here"

The scripts check in this order:

  1. AUDAXIC_API_KEY environment variable
  2. ~/.config/audaxic/config.json config file

Uninstall​

Remove the plugin by deleting the hook files:

# Remove hooks directory
rm -rf ~/.codex/audaxic/

# Remove hooks from ~/.codex/hooks.json
# (Edit the file and remove the Audaxic entries)

API Endpoints​

EndpointMethodDescription
https://api.memory.audaxic.com/searchPOSTSearch memories for context injection
https://api.memory.audaxic.com/addPOSTSave conversation messages in batch

Behavioral Triggers​

AUTO-SEARCH before:​

  • Making architectural decisions
  • Adding new dependencies
  • Fixing bugs (check for prior solutions)
  • Starting new sessions (load preferences)

AUTO-SAVE after:​

  • User states a preference
  • Decision with rationale made
  • Complex bug fixed
  • Project conventions learned

DO NOT save:​

  • Temporary state, debug info, secrets

Content Rules​

  • One fact per memory
  • Natural language, not keywords
  • Include reasoning, not just outcomes
  • Be specific for better semantic matching

Lifecycle​

Add → Search → Update (delete + re-add) → Delete (when obsolete)


Troubleshooting​

Plugin not working​

  1. Verify hooks are registered: Check ~/.codex/hooks.json
  2. Verify API key is set: cat ~/.config/audaxic/config.json
  3. Check ~/.codex/audaxic/buffer.json for unsent messages

Context not being injected​

  1. Check that recall.js exists in ~/.codex/audaxic/
  2. Verify API key is valid at memory-dashboard.audaxic.com
  3. Check network connectivity to api.memory.audaxic.com

Messages not saving​

  1. Check that capture.js exists in ~/.codex/audaxic/
  2. Check ~/.codex/audaxic/buffer.json for pending messages
  3. Verify API endpoint is reachable