agent-coordinator
CLAUDE.md4 starsChanged 9 months agoMITView on GitHub
CANONICAL SOURCE: Master instructions for all AI coding agents. Maintenance: Update only when fundamental patterns change. Read these files when: - You seem confused about what you're working on - User asks "what were we doing?" or "continue" - Starting significant new work Performance: conftest.py caches schema DDL — migrations run ONCE per session. Do NOT add init_database() to test fixtures — _isolate_db autouse fixture handles it. Gotcha: sqlite3.Row has no .get() method. Use row["column"] not row.get("column"). 17 routers extracted.…
- Reads credentials
In this repository7 other files it gives its agents.
- llms.txtllms.txt
- ac-httpSkill
- memorySkill
- gitSkill
- pr-completeSkill
- pr-createSkill
- work-on-issueSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
26 rules. About 0 are common, 14 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 34
NEVER commit directly to main: - ALL changes require feature branches and PRs
- Very specific: line 68
Do NOT add init_database() to test fixtures — _isolate_db autouse fixture handles it.
- Distinctive: line 172
Every agent follows this protocol on every session.
- Distinctive: line 180
If unreachable, warn the user and continue without coordination.
- Distinctive: line 181
Never crash on coordinator being unavailable.
- Very specific: line 183
Register: If you are running inside the agent wrapper (you'll see [wrapper] in your system prompt), registration is handled automatically — …
- Distinctive: line 185
If running standalone (no wrapper), register yourself:
- Very specific: line 206
After completing a significant deliverable, notify relevant agents via POST /messages.
- Distinctive: line 207
Check for new messages periodically during long sessions.
- Very specific: line 211
If running inside the wrapper ([wrapper] in system prompt), session cleanup is handled automatically — do NOT send a sleeping heartbeat …
- Very specific: line 213
If running standalone: POST /agents/{your-id}/heartbeat with {"status": "sleeping"}
- Very specific: line 217
Use your publishes list from identity.yaml as guidance for what you announce.
- Distinctive: line 241
When you need to message someone but don't know who:
- Very specific: line 243
Check each agent's capabilities for relevant skills
- Distinctive: line 248
If coordinator is unavailable:
- Very specific: line 282
When you are launched as an autonomous agent (via the coordinator or work-on-issue skill), follow these instructions to understand who you …
- Very specific: line 304
Do NOT read all skills at once.
- Very specific: line 313
How: Write YAML or markdown files.
- Distinctive: line 314
When: After completing significant work, after learning something important, before session ends
- Distinctive: line 315
Commit with code: When you commit code changes, include your memory files in the same commit
- Distinctive: line 340
When assigned a task for a repository you don't have locally:
- Distinctive: line 342
Check if the repo exists in your workspace area
- Very specific: line 343
If not, clone it: git clone <repo-url> <workspace-path>
- Very specific: line 344
If yes, pull latest: cd <workspace-path> && git checkout main && git pull
- Distinctive: line 364
NO GitHub Actions changes without approval
- Distinctive: line 365
NO secrets in commits
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent Coordinator AI Instructions
CANONICAL SOURCE: Master instructions for all AI coding agents. Maintenance: Update only when fundamental patterns change.
Context Restoration (When Lost or Uncertain)
Read these files when:
- You seem confused about what you're working on
- User asks "what were we doing?" or "continue"
- Starting significant new work
| File | Purpose | When to Read |
.claude/memory/PROJECT_CONTEXT.md | What is Agent Coordinator? | When unfamiliar with project |
Context Anchors (Verify BEFORE Every Task)
1. Port Allocation (CRITICAL)
- Agent Coordinator runs on port 9889
- SQLite database at
data/coordination.db- no separate DB port needed - Standalone Python process - NOT in Docker
2. Atomic Operations (CRITICAL)
- Task claiming uses INSERT...SELECT for atomicity
- File locks use leases that auto-expire
- Database operations use SQLite with WAL mode for concurrent reads
3. Branch Policy (NO EXCEPTIONS)
- NEVER commit directly to main - ALL changes require feature branches and PRs
- Feature branches:
feat/description - Fix branches:
fix/description
Quick Commands (WSL/Linux)
# Start server
AC_DB_PATH=$HOME/agent-coordinator-data/coordination.db \
PYTHONPATH=src python3 -m uvicorn agent_os.server.main:app --host 0.0.0.0 --port 9889
# Run tests (use python3, NOT py)
PYTHONPATH=src python3 -m pytest tests/ -v
# Run single test file (fast — cached schema DDL)
PYTHONPATH=src python3 -m pytest tests/test_server.py -v --timeout=30
# Health check
curl http://localhost:9889/healthTesting
PYTHONPATH=src python3 -m pytest tests/ -v # All tests
PYTHONPATH=src python3 -m pytest tests/test_server.py -v # Single file (~3s)
PYTHONPATH=src python3 -m pytest tests/ -k "health" -v # By keywordPerformance: conftest.py caches schema DDL — migrations run ONCE per session.
Do NOT add init_database() to test fixtures — _isolate_db autouse fixture handles it.
Gotcha: sqlite3.Row has no .get() method. Use row["column"] not row.get("column").
Before Committing
- Tests pass:
PYTHONPATH=src python3 -m pytest tests/test_server.py --timeout=30 - Pre-commit hooks:
pre-commit run --all-files - NO
git add .— use specific files - Conventional Commits:
type(scope): summary - Review every PR before merging
Architecture Note
17 routers extracted. Only 9 system endpoints in main.py. Roadmap: .claude/docs/ROADMAP-v1.md
API Overview
Agent Management
| Endpoint | Method | Description |
/agents/register | POST | Register at session start |
/agents/{id}/heartbeat | POST | Update status (every 15 min) |
/agents | GET | List all agents |
/agents/{id} | DELETE | Mark offline at session end |
Task Management
| Endpoint | Method | Description |
/tasks/claim | POST | Atomically claim an issue |
/tasks/{id}/release | POST | Give up a claimed task |
/tasks/{id}/complete | POST | Mark task done |
/tasks | GET | List all tasks |
File Locks
| Endpoint | Method | Description |
/locks/acquire | POST | Get lock with lease |
/locks/{id}/renew | POST | Extend lease |
/locks/{id} | DELETE | Release lock |
/locks | GET | List all locks |
Messages
| Endpoint | Method | Description |
/messages | POST | Send message |
/messages/{agent_id} | GET | Get your messages |
/messages/{id}/ack | POST | Acknowledge message |
Advanced Features
| Endpoint | Method | Description |
/tasks/auction | POST | Create task auction |
/decisions | POST | Create decision vote |
/standup/today | GET | Get daily standup |
/activity | GET | Activity feed |
Architecture
┌─────────────────────────────────────────────────────────────┐
│ Agent Coordinator │
│ localhost:9889 │
├─────────────────────────────────────────────────────────────┤
│ FastAPI Server │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Agents │ │ Tasks │ │ Locks │ │
│ │ Management │ │ Claiming │ │ Leases │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Messages │ │ Auctions │ │ Decisions │ │
│ │ Queue │ │ Bidding │ │ Voting │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
├─────────────────────────────────────────────────────────────┤
│ SQLite Database (data/coordination.db) │
│ - WAL mode for concurrent reads │
│ - Background log worker for non-blocking audit │
└─────────────────────────────────────────────────────────────┘Health Monitoring
The server automatically monitors agent health:
| Threshold | Status | Action |
| 30+ min no heartbeat | STALE | Log warning |
| 60+ min no heartbeat | DEAD | Release all locks and tasks |
| 2+ hours no heartbeat | OFFLINE | Mark agent offline (resources already released at DEAD) |
Coordinator Protocol (MANDATORY for all agents)
Every agent follows this protocol on every session. It is generic — not tied to any specific role or workflow.
Session Start (before any work)
- Read your identity: Load
.os/agents/{your-name}/identity.yamlfor your agent ID, skills, and message subscriptions (listens_to/publishes). - Check coordinator:
GET ${AC_COORDINATOR_URL:-http://localhost:9889}/health- If unreachable, warn the user and continue without coordination.
- Never crash on coordinator being unavailable.
- Register: If you are running inside the agent wrapper (you'll see
[wrapper]in your system prompt), registration is handled automatically — do NOT register again. If running standalone (no wrapper), register yourself:
Capabilities are the category prefixes of your skills (the part beforePOST /agents/register { "id": "<name from identity.yaml>", "workspace": "<cwd>", "capabilities": ["<skill categories from identity.yaml, e.g. 'development', 'review'>"] }/). For example, skillreview/pr-review→ capabilityreview. - Check messages:
GET /messages/{your-id}?unread_only=true- Process any pending messages before starting new work.
- Acknowledge each:
POST /messages/{msg-id}/ack?agent_id={your-id}
- Discover peers:
GET /agents- Know who else is registered and available.
During Work
- After completing a significant deliverable, notify relevant agents via
POST /messages. - Check for new messages periodically during long sessions.
Session End
- If running inside the wrapper (
[wrapper]in system prompt), session cleanup is handled automatically — do NOT send a sleeping heartbeat yourself. - If running standalone:
POST /agents/{your-id}/heartbeatwith{"status": "sleeping"}
Sending Messages
Use your publishes list from identity.yaml as guidance for what you announce.
Address messages to specific agents or all for broadcast.
POST /messages
{
"from_agent": "<your-id>",
"to_agent": "<target-id or 'all'>",
"type": "<info|request|status|alert>",
"priority": "<low|normal|high|urgent>",
"subject": "<concise summary>",
"body": "<details>",
"requires_ack": true
}Priority guidelines:
urgent— blocked, need immediate helphigh— deliverable ready, review needed, fix needednormal— status update, question, FYIlow— informational, non-blocking
Agent Discovery
When you need to message someone but don't know who:
GET /agents— list all registered agents- Check each agent's
capabilitiesfor relevant skills - Send to the most appropriate agent, or broadcast to
allif unclear
Graceful Degradation
If coordinator is unavailable:
- Warn the user, continue working normally
- PRs and commits still work (git doesn't need the coordinator)
- Note needs in deliverables (e.g., PR description says "needs review")
Helper Scripts
# Check if coordinator is running
.\scripts\coordinator-check.ps1
# Register + check messages in one step
.\scripts\agent-checkin.ps1 <agent-id> [workspace]# Check if coordinator is running
./scripts/coordinator-check.sh
# Register + check messages in one step
./scripts/agent-checkin.sh <agent-id> [workspace]Environment Variables
| Variable | Default | Purpose |
AC_COORDINATOR_URL | http://localhost:9889 | Coordinator base URL |
AC_API_KEY | (from .os/config.yaml) | API authentication key |
Agent Operating Instructions (for CLI Agents)
When you are launched as an autonomous agent (via the coordinator or work-on-issue skill),
follow these instructions to understand who you are and what you can do.
Know Yourself
On session start, read these files to understand your identity and purpose:
| File | What It Contains | When to Read |
.os/agents/{your-name}/identity.yaml | Your name, skills list, provider config, message subscriptions | Always — first thing |
.os/agents/{your-name}/SOUL.md | Your personality, values, working style | Always — shapes how you work |
.os/agents/{your-name}/state.json | Your current status, level, XP | When resuming work (created on first run) |
Your agent name is provided in the first prompt you receive. Use it to locate your files.
Know Your Skills
Your skills are listed in identity.yaml under the skills key. Each skill has documentation:
- Skill instructions:
.os/skills/{category}/{skill-name}/SKILL.md— read when you need to use that skill - Tool schema:
.os/skills/{category}/{skill-name}/tool.yaml— defines inputs/outputs for the skill's tools
Do NOT read all skills at once. Read a skill's SKILL.md when you need it for the current task.
For example, when assigned a development task, read .os/skills/development/work-on-issue/SKILL.md.
Save Your Learnings
As you work, save what you learn to persist across sessions:
- Where:
.os/agents/{your-name}/memory/directory - What to save: Domain knowledge about the codebase, patterns that worked or failed, decisions and their reasoning, gotchas you encountered
- How: Write YAML or markdown files. Use descriptive names (e.g.,
codebase-patterns.md,api-gotchas.md) - When: After completing significant work, after learning something important, before session ends
- Commit with code: When you commit code changes, include your memory files in the same commit
Memory types:
- Episodic: What happened — "Fixed auth bug by changing token validation in middleware"
- Semantic: Facts about the codebase — "The API uses FastAPI with SQLite WAL mode on port 9889"
- Procedural: How-to knowledge — "To run tests:
py -m pytest tests/ -v"
Save Context Periodically
Long sessions may lose early context due to context window limits. Protect against this:
- Every 15-20 minutes (or after completing a significant step), save your working context:
- What you're currently working on
- What you've done so far
- What's left to do
- Key decisions made and why
- Where:
.os/agents/{your-name}/context/working.yaml - Keep it concise — this is a checkpoint, not a full log
Session Auto-Restart
Sessions automatically restart when you exhaust your context window (CLI: up to 3 times, API: up to 2 times by default). On restart, you'll receive a continuation prompt telling you to read your memory files and continue. Your memory files at .os/agents/{your-name}/memory/ persist across restarts — use them to save progress. Commit early and often to prevent lost work.
Workspace Management
When assigned a task for a repository you don't have locally:
- Check if the repo exists in your workspace area
- If not, clone it:
git clone <repo-url> <workspace-path> - If yes, pull latest:
cd <workspace-path> && git checkout main && git pull - Work in the cloned repo, not in the coordinator's directory
Each agent should have its own workspace clone to prevent conflicts with other agents.
Detailed Documentation (Load on Demand)
| Topic | File |
| API Reference | @.claude/docs/api-reference.md |
| Coordinator Wiring Spec | @.claude/docs/phase-c-coordinator-wiring-spec.md |
| Architecture Decision: SQLite | @.claude/decisions/001-sqlite-over-postgres.md |
| Architecture Decision: Idle Ping | @.claude/decisions/002-idle-ping-across-paths.md |
Constraints
- NO GitHub Actions changes without approval
- NO secrets in commits
- Stage files carefully - no
git add .
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

