Claude Code Setup

Give Claude Code Permanent Memory

AgentBay is the memory OS for coding agents. Start local on your machine in 60 seconds, then upgrade to cloud, teams, and projects when you need them. No signup required for local mode.

Path A — Local-first (recommended)

Works fully offline against a local SQLite + FTS5 store. No API key, no cloud, no signup.

pip install agentbay
from agentbay import AgentBay

brain = AgentBay()  # local mode, no signup
brain.store("Auth uses JWT with 24h refresh tokens",
    title="Auth pattern", type="PATTERN")

# Open Claude Code in your project, ask:
# "what do we know about auth?"
# Then have Claude call brain.recall("auth").

When you want cloud, teams, or projects, run brain.login() — your local memories migrate automatically. Path B below also works without ever installing the SDK.

Path B — One-command MCP install

Adds the MCP server, lifecycle hooks (auto-recall on session start, auto-store on stop), and updates your global Claude Code settings in one shot.

export AGENTBAY_API_KEY="ab_live_YOUR_KEY"
curl -sSL https://www.aiagentsbay.com/install-claude.sh | bash

After install, every Claude Code session in any directory has:

  • SessionStart hook — recalls relevant memories into context
  • Stop hook — extracts learnings and stores them (intelligent agent-driven)
  • PreCompact hook — saves context before Claude Code compacts
  • Full MCP tool set — memory, projects, teams, handoffs, reviews

No API key yet? Get a free one (1,000 memories, 10,000 API calls/month, no credit card).

— or set up manually —
1Get an API key (only for cloud mode)
  1. Local mode does not need an API key. Skip to step 3 if you only want local.
  2. For cloud: register at aiagentsbay.com/register (free).
  3. Open Dashboard → API Keys, click Create API Key, copy the ab_live_... key.
2Set the env var
# In ~/.zshrc (Mac) or ~/.bashrc (Linux):
export AGENTBAY_API_KEY="ab_live_YOUR_KEY"
source ~/.zshrc
3Add the MCP server to ~/.claude/settings.json

Edit (or create) ~/.claude/settings.json:

{
  "mcpServers": {
    "agentbay": {
      "type": "http",
      "url": "https://www.aiagentsbay.com/api/mcp",
      "headers": {
        "Authorization": "Bearer ${AGENTBAY_API_KEY}"
      }
    }
  }
}

For local-only mode, skip this step entirely — just install the SDK and call AgentBay().

4(Optional) Add a global memory protocol

Tells every Claude Code session to recall + store proactively. Append to ~/.claude/CLAUDE.md:

# Default memory: AgentBay

You have AgentBay MCP connected globally.

- Before starting work on a task, call agentbay_memory_recall with a query
  about what you're about to work on. Inject relevant memories into context.
- During work, store patterns, pitfalls, and decisions you discover with
  agentbay_memory_store. Don't wait to be asked.
- Use type="PATTERN" | "PITFALL" | "DECISION" | "ARCHITECTURE".
- Don't store raw code or secrets — those belong in git, not memory.
5Verify

Start a new Claude Code session and run:

# In Claude Code:
> what MCP servers do I have connected?

# You should see "agentbay" in the list.
# Then test the round trip:

> store a test memory titled "phase-5 verification" with content "AgentBay is wired up"
> recall the test memory you just stored
> tell me which strategies the recall used (alias / fts / vector / tag)

Claude Code should call agentbay_memory_store then agentbay_memory_recall, and the result should include the per-strategy rationale recorded by the phase-2 quality instrumentation.

A realistic Claude Code example

Real coding-agent workflow: a refactor that survives a session restart.

# Day 1, session 1 — refactoring auth middleware
> I'm refactoring src/middleware.ts. Recall what we know about auth.

  agentbay_memory_recall query="auth middleware"
    → Auth pattern (PATTERN, 87% confidence): JWT with 24h refresh
    → Don't trust upstream IP (PITFALL, 92%): use X-Forwarded-For chain

> Now write the rotation handler.
[Claude does the work, I review it.]

> Session is wrapping up. Hand off so I can resume tomorrow.

  agentbay_handoff_create
    summary="Wrote rotation handler in src/middleware.ts. Tests pass.
             Next: wire it into the SDK and update docs."
    nextSteps=["wire SDK", "update docs", "run integration tests"]
    completedSteps=["rotation handler", "unit tests"]
    filesModified=["src/middleware.ts", "src/middleware.test.ts"]
    keyDecisions=[{decision: "HS256 not RS256", rationale: "no KMS yet"}]
    → handoffId=ho_xyz, qualityScore=90, warnings=[]

# Day 2, new session, different machine
> Resume the most recent handoff for this project.

  agentbay_handoff_resume handoffId=ho_xyz
    → quality 90/100. summary, nextSteps, files all loaded into context.
    → recent failures in this area also surfaced (PITFALL list).
    → I pick up exactly where we left off.

The handoff quality score is computed deterministically from completeness (summary length, next steps, files modified, decisions, etc). The full breakdown is stored alongside the score so you can see why a handoff scored 90 vs 100 — never a mystery KPI. See memory architecture for the full scoring rules.

Upgrade path

Local → Cloud: brain = brain.login() opens a browser, signs you up if needed, and migrates your local memories. Free tier: 1,000 memories, 10,000 API calls/month, 5 projects. No credit card.

Cloud → Teams: Pro and Max plans add multi-agent teams with 5-role permissions and auto-share policies. The Pro plan ships with project-level handoffs and attempt reviews; Max adds swarm coordination.

Governance: every deployment exposes GET /api/v1/projects/[id]/governance with live status of encryption, audit, erasure, redaction, and permissions — every claim is queryable.

See plans →
Troubleshooting

MCP server not appearing?

Restart Claude Code completely. MCP servers are loaded at session start.

"Authentication required" error?

Verify echo $AGENTBAY_API_KEY in the same shell that launches Claude Code. The settings file uses ${AGENTBAY_API_KEY} interpolation, which requires the variable to be set in the launching environment.

Hooks not firing?

Check ~/.claude/hooks/agentbay/ exists and the scripts are executable. The installer also writes the hook config to ~/.claude/settings.json — make sure both are present.

Want pure local mode without ever touching cloud?

Skip the MCP setup entirely. Install the SDK (pip install agentbay) and useAgentBay() directly inside your scripts. Claude Code can shell out to your Python tools.

Other coding agents

Same MCP server. Same SDK. Different setup.