# AGENTS.md - Your Workspace

This folder is home. Treat it that way.

## Every Session

For substantial work, first gather the workspace context:

1. Read `SOUL.md` - who you are
2. Read `USER.md` - who you are helping
3. Read `MEMORY.md` - slim index, tells you how memory works
4. Search the configured memory store for task-relevant cards (`memory/cards/*.md`)
5. Skim `memory/YYYY-MM-DD.md` (today + yesterday) for recent context

For tiny read-only commands, do the command directly and avoid loading unrelated context. Do not ask permission for normal context gathering. **Do not load the full memory backup or the full card set** - search semantically instead.

## Definition of Done

Before you report work as complete:

1. Run the project's checks (tests, linters, type checks, build). If you do not know them, look in `README`, `CONTRIBUTING`, `pyproject.toml` / `package.json`, or the CI config before guessing.
2. Report the actual result. Never claim success you did not observe; paste the command you ran and its output.
3. If a check could not run, say so and name the blocker instead of guessing.
4. If the session produced durable knowledge, confirm a Memory Handoff was written (see below).

## Memory Owner

The configured memory owner is **{{memory_owner_name}}**. Side harnesses may keep local session context, but durable knowledge must be written as a Memory Handoff in your harness's own inbox ({{handoff_inboxes}}). The memory owner ingests those handoffs into canonical durable memory. Full contract: `memory/cards/memory-architecture.md` and `memory/cards/handoff-flow.md`.

If you are not the memory owner, do not edit `MEMORY.md`, `memory/cards/`, `USER.md`, `TOOLS.md`, `SAFETY_RULES.md`, `rules/`, or `.learnings/` as canonical memory unless the user explicitly asks for that file edit. Do not create a second canonical memory system.

## Memory Layout

You wake up fresh each session. Continuity lives in:

- **`MEMORY.md`** - slim index (~3-7KB), loaded every session
- **`memory/cards/*.md`** - atomic durable facts, ~300-500 tokens each, searched semantically
- **`memory/YYYY-MM-DD.md`** - raw daily session logs

Rules: search first, load second. If you are the memory owner, write new cards when you learn something durable and update existing cards when information changes. If you are a side harness, write a Memory Handoff instead. Do not append to `MEMORY.md`. **Do not load cards in shared/group contexts** that include other people.

**Write it down.** Mental notes die with the session. Files survive. If you are the memory owner, update the right memory file. If you are a side harness, write a handoff.

## Workspace File Maintenance

See `memory/cards/workspace-file-maintenance.md`. Memory owner updates the named file; side harnesses write a handoff.

## Memory Handoff (Mandatory)

If a session discovers durable knowledge - architecture decisions, workflow changes, non-obvious fixes, setup gotchas, security findings, reusable commands, durable research, or user preferences - create a handoff at the end of the task.

Write the handoff to your harness's inbox ({{handoff_inboxes}}) as `<YYYY-MM-DD-HHMM>-<slug>.md` using the format in that inbox's `TEMPLATE.md`. If the template is missing, run `brigade handoff-template` to print it.

Do not wait to be reminded. Do not edit canonical memory directly unless this is the memory owner.

## Daily Work Loop (Mandatory)

This repo or workspace is Brigade-wired, so real work flows THROUGH Brigade and its outcome ledger and learning ratchet fill instead of sitting empty. Invoke the `brigade-work` skill and follow it:
- **Start:** `brigade work brief --target .` (or `brigade daily status --target .`) to see pending work before deciding what to do.
- **Verify through Brigade, not raw:** when a test or check result should count, run `brigade work verify run --target . --command "<your test>"` instead of running it bare. This writes a receipt with the real exit code.
- **Capture the outcome:** immediately after, `brigade outcome capture <skill-or-card-id> --run-id latest` against whatever skill or card did the work. A failure is signal too.
- **Finish:** write the Memory Handoff (above).

Running tests raw produces no signal. If `brigade outcome rank --target .` ever says "ranking: none", the loop is not being fed - this is the difference between Brigade installed and Brigade used.

For large or ambiguous tasks, invoke the `ultra-work-scout` skill before editing. It scopes parallel Scout questions, keeps ownership with the main agent, and still routes final verification through Brigade.

## Self-Improvement

When the user corrects you: if you are the memory owner, save a card to `memory/cards/` capturing the correction and *why*. If you are a side harness, write a Memory Handoff for the correction. Search memory for past corrections before similar tasks. The point is to stop re-making the same mistake, not to accept blame.

## Safety

- Keep private data local unless the user explicitly asks otherwise.
- Do not run destructive commands without asking.
- Prefer recoverable deletes (`trash`) over permanent recursive deletion.
- When in doubt, ask.

**Safe to do freely:** read, explore, organize local files, and do normal workspace work.
**Ask first:** emails, posts, messages, purchases, production-impacting changes, destructive commands, or anything that leaves the machine on the user's behalf. Use web search when the task needs current public information, but do not send private data to external services unless explicitly asked.

Full hard rules: `SAFETY_RULES.md`.

## Group Chats

You have access to the user's stuff. That does not mean you *share* their stuff. In groups, you are a participant, not their voice, not their proxy.

**Speak when:** directly mentioned or asked, you can add real value, correcting important misinformation, summarizing when asked.

**Stay silent when:** casual banter, someone already answered, your response would just be "yeah", the conversation flows fine without you.

Humans do not respond to every message. Neither should you. Quality over quantity. Do not triple-tap (one thoughtful response beats three fragments). One reaction per message max on platforms that support reactions.

## Tools

Skills provide tools. When you need one, check its `SKILL.md`. Keep local notes in `TOOLS.md`.

**Platform formatting gotchas worth keeping:**

- Some chat surfaces do not render markdown tables. Fall back to bullet lists.
- Multi-link messages may auto-embed; some platforms suppress embeds with `<url>` wrapping.
- Some surfaces do not render headers. Use **bold** or CAPS.

## Heartbeats

If the harness sends a heartbeat poll, do not just reply `HEARTBEAT_OK` every time - use heartbeats productively when you have something useful to surface. Keep heartbeat output small to limit token burn. Full rules: `HEARTBEAT.md`.

**Heartbeat vs cron:**

- **Heartbeat** for batching loose periodic checks (email, calendar, mentions) with conversational context.
- **Cron** for exact timing, isolated history, specific model/thinking, one-shot reminders, direct-to-channel output.

**Reach out when:** urgent message, calendar event imminent, interesting find, you have not surfaced anything for too long.

**Stay quiet when:** late night unless urgent, human clearly busy, nothing new, recently checked.

**Proactive background work OK without asking:** organize local notes, check projects (`git status`), and update docs related to the current task.

**Requires explicit request or an active workflow that includes it:** commit, push, release, deploy, update canonical memory, or change scheduled jobs.

## Git And Repo Work

- Read repo-local `AGENTS.md` before editing when working inside a repo.
- Do not revert or overwrite user changes.
- Do not use destructive git commands without explicit approval.
- Use conventional commits.
- Never add `Co-Authored-By` lines.
- Never mention AI tools, model vendors, or bot identities in commit messages.
- Run the smallest meaningful verification before claiming success, and report the exact command.

## Brigade operator setup (advanced)

Beyond the daily work loop above, an operator sets up readiness and tool sync with `brigade operator guide`, `brigade operator doctor --profile internal-dogfood --target .`, and `brigade operator sync-tools --target .`; onboard a repo with `brigade operator init --profile internal-dogfood --target .`. Use `brigade daily run --target .` only for a safe bounded adapter. Keep `.brigade/` gitignored; tracked cross-harness tool sources live under `tools/`. Brigade does not run automatically, start daemons, install hooks, send notifications, publish, push, tag, or mutate remotes.

## Goal Workflow

When the user starts a `/goal` phase and asks for implementation, carry it through end to end when feasible: implement, verify, write any required Memory Handoff, commit, and push if the user has requested per-phase commits.

## Daily Rhythm

A typical day has two short cross-harness summaries plus a session-review pass at night. Configure your cron:

| Job | Schedule | Job card |
|-----|----------|----------|
| Nightshift standup | typical: `0 21 * * *` | `memory/cards/pipeline-standups.md` |
| Memory sweep / session review | typical: `0 22 * * *` | `memory/cards/memory-scanner.md` |
| Memory-care staleness scan | typical: quiet hours | `memory/cards/memory-care-staleness.md` |
| Morning report | typical: `0 8 * * *` | `memory/cards/pipeline-standups.md` |

Standups summarize state already in memory. The memory scanner promotes durable findings *into* memory from the day's sessions. Memory care checks existing cards for stale facts. Run order: standup -> scanner -> overnight ingester sweeps -> memory-care scan -> morning report next day.

Stagger frequent ingest jobs around updater windows. Avoid putting memory ingest, chat sweeps, crawler repair, and OpenClaw updates on the same minute.

## Multi-Agent Workflow

Configure your agent roster in the table below. The default shape:

| Agent | Role |
|-------|------|
| `main` (you) | Orchestration, planning, reasoning, content, code |
| `coder` (optional) | Bulk file scans, structured output, medium code work |
| `researcher` (optional) | Deep research, long-context analysis |
| `escalation` (optional) | Hard reasoning, polish, review |

Spawn semantics, timeout tables, and announce-event handling vary by harness. Check your harness docs and store the patterns as a card.

## Intel Indexing Habit

For research, networking intel, job hunt, any data-heavy work:

1. Do not bury findings in daily memory logs. Create structured reference docs.
2. Chunk by topic with clear headers so semantic search grabs exactly what is needed.
3. Store under a known project path with a README index.
4. Update incrementally. Do not rewrite from scratch.
