CLI

OPC - OpsCompanion CLI

Persistent, shared memory plus logs and live application context for AI coding agents across Claude Code, Codex, Cursor, and future runtimes.

Agents in production with Codex and Claude Code

Install

brew tap opscompanion/opc
brew install opc

To upgrade:

brew update && brew upgrade opc

From Source

git clone https://github.com/opscompanion/opc.git
cd opc
make install

Requires Go 1.25+.

Quick Start

# 1. Run the guided setup flow
opc setup

# 2. Save a decision to organization knowledge
opc remember "Use connection pooling for Redis - single connections hit latency issues under load" --tags redis,performance

# 3. Search knowledge and memory
opc search "redis connection"

# 4. Search logs and traces
opc logs "timeout" --service api --severity ERROR --since 1h
opc traces "checkout" --service api --since 6h

# 5. View org/user/workspace context
opc context

opc setup combines API configuration, agent selection, skills and plugins, and hook generation in one interactive flow. It verifies your API key against OpsCompanion endpoints automatically, trying production first and then development, and saves the working endpoint to config.

The --agent Flag

Every command accepts --agent <name> to normalize behavior across runtimes:

opc --agent claude recall "auth migration"   # from Claude Code hooks
opc --agent codex recall "auth migration"    # from Codex hooks
opc search "auth migration"                  # human mode (auto-detect from env)

The flag controls:

  • Which env var to read the session ID from (CLAUDE_SESSION_ID, CODEX_SESSION_ID, and others)
  • Hook configuration format (.claude/settings.local.json vs .codex/hooks.json)
  • Session metadata tagging

When omitted, OPC auto-detects the agent from environment variables. Skills and hooks generated by opc setup or opc install include the correct --agent flag automatically.

opc setup is now the recommended onboarding path. opc init and opc install remain available for scripting and compatibility, but are legacy flows and will be deprecated.

Supported values: claude, codex, cursor, openclaw, auto (default).

How It Works

OPC integrates with AI coding agents via hooks: lightweight event handlers that fire on tool calls, prompts, and session lifecycle events.

Agent (Claude Code, Codex, Cursor, etc.)
  -> fires hook events
    -> opc capture (writes to local JSONL buffer)
      -> checkpoint triggers (git commit, every 50 events, session stop)
        -> local session artifacts

Shared knowledge and memory are available via opc search. No MCP required: hooks are deterministic and do not bloat context with tool schemas.

Commands

CommandDescription
opc setupGuided onboarding flow for API key verification, endpoint detection, agent install, and hooks
opc initLegacy config-only setup
opc installLegacy agent install flow (interactive if --agent is omitted)
opc hooksGenerate hook configuration for the active agent
opc contextDisplay org, user, integration, and workspace context
opc session listList local sessions
opc session inspect <id>Inspect session events and checkpoints
opc remember <text>Save a decision or discovery (--tags to add tags)
opc search <query>Search stored knowledge and memory
opc logs [query]Search logs (opc logs tail for live polling; tail does not accept --since)
opc traces [query]Search traces
opc captureCapture hook events from stdin (used by hooks)
opc versionPrint version info

All commands accept the global --agent flag.

Architecture

OPC follows a thin client, smart server design:

  • Client: captures events, buffers locally as JSONL, and calls the public API for context, knowledge, and memory
  • Server: handles context assembly and knowledge and memory search
  • No local database: /tmp/opc/sessions/ is a temporary buffer

This means intelligence improves server-side without shipping binary updates.

Multi-Agent Memory Sharing

Multiple agents can share knowledge in near-real-time:

Agent A discovers a bug -> checkpoint -> API extracts memory
                                             |
                                             v
Agent B asks about the same area -> opc search -> gets Agent A's discovery

Memory Layers

LayerPurposeShared?
Raw eventsAudit log of every tool callNo
MemoriesExtracted decisions and discoveriesYes

An hour-long session might produce 500 events but only 3-5 memories.

Supported Agents

AgentIntegrationStatus
Claude Codeopc setupSupported
Codexopc setupSupported
Cursoropc setupSkills only
OpenClawopc setupSkills only

Legacy Commands

opc init and opc install are still supported for compatibility and scripting, but opc setup replaces them for normal onboarding.

  • opc init is the old config-only flow
  • opc install is the old agent install flow
  • New users should start with opc setup

Development

make build      # Build binary
make install    # Install to $GOPATH/bin
make snapshot   # GoReleaser local build
make clean      # Remove binary

Releasing

git tag v0.3.1
git push origin v0.3.1
# GitHub Actions -> GoReleaser -> GitHub Release -> Homebrew formula auto-updates

Builds target darwin and linux on amd64 and arm64.

Contributing

Contributions welcome! Please open an issue or pull request.

On this page