Skip to content

Feature: auto-detect Claude Code / Codex / OpenClaw instances #65

@liaoandi

Description

@liaoandi

Background

When running multiple AI coding agents (Claude Code, Codex, OpenClaw) simultaneously, each instance needs to manually join the office via API. This is tedious and error-prone — agents get duplicated, forget to leave, or never join at all.

Proposal

A lightweight daemon script that:

  1. Auto-detects running Claude Code / Codex processes every ~10 seconds (via pgrep)
  2. Auto-joins new instances with a descriptive name based on their working directory (e.g. Claude Code (trading), Codex (podcast_juicer))
  3. Auto-removes agents when their process exits
  4. Monitors OpenClaw gateway logs to toggle lobster status between idle/writing

How it works

┌─────────────┐     pgrep -x claude      ┌──────────────────┐
│ Claude Code  │ ◄──────────────────────► │                  │
│ (trading)    │                          │  star-office      │
├─────────────┤     pgrep -x codex       │  daemon           │
│ Codex        │ ◄──────────────────────► │                  │
│ (juicer)     │                          │  (every 10s)      │
├─────────────┤     gateway.log tail     │                  │
│ OpenClaw     │ ◄──────────────────────► │                  │
│ (lobster)    │                          └───────┬──────────┘
└─────────────┘                                   │
                                                  ▼
                                          /join-agent
                                          /agent-push
                                          /leave-agent

Why not hooks?

Claude Code supports PostToolUse / Stop hooks, but:

  • Each hook invocation is a separate shell process with no stable session identifier
  • This causes duplicate agent registrations (we saw it balloon to #97)
  • Codex has no system-level hooks at all

A polling daemon avoids these issues entirely.

Status

I have a working prototype (star-office-daemon.sh) running locally. Happy to submit a PR if there's interest, or adapt to a preferred approach (e.g. integrate into the backend as a background thread).

Related PR: #64 (fixes agent overlap when many agents are in the same area)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions