Repository files navigation

agent-brain

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

agent-brain is a personal operating model for AI coding agents (Claude Code, OpenCode, Codex, Antigravity CLI). It gives you:

  • A second-brain knowledge structure (journal, WIP, memory, tasks) that the model builds on top of any folder of notes — Obsidian is one option, not a requirement.
  • Version-controlled runtime config & memory: your CLAUDE.md / AGENTS.md, memory, and runtime settings live in a git-tracked brain and are symlinked into each runtime (~/.claude, ~/.config/opencode, …), so your agent configuration and memory travel with you across machines.
  • A session lifecycle (daily notes, session notes, consolidation) driven by the brain skill.
  • An optional boyscout skill: spot improvement opportunities while you work, then route them to an explicit remediation workflow or backlog.

Prerequisites

  • Python 3.x (stdlib only — no pip dependencies)
  • git on PATH
  • At least one supported agent runtime installed:
    • Claude Code~/.claude/
    • OpenCode~/.config/opencode/
    • Shared agents dir → ~/.agents/
    • Codex CLI → ~/.codex/ (AGENTS.md and config.toml are persisted under the private brain's _AGENTS/CODEX/; the brain skill is installed at ~/.agents/skills/brain)
    • Antigravity CLI → ~/.gemini/antigravity-cli/ (skill-only integration)

Install

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh | bash

This clones agent-brain to ~/.local/share/agent-brain and runs the orchestrator, which will ask for your brain path (an Obsidian vault, a notes folder, or a new empty dir). It dry-runs by default. After reviewing the plan, use the exact public apply command printed at the end; it preserves the selected brain, runtime filter, and symlink policy:

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh \
| bash -s -- --brain /path/to/brain --apply

If _COMMON already exists

If your brain already has a _COMMON symlink pointing to a different model (e.g. a previous setup), the dry-run reports the current entry and desired symlink separately, including the raw target of a broken link. It also checks every template symlink managed by home_setup and reports stale targets. On --apply, the installer preserves the existing _COMMON entry as _COMMON.backup-<ts>, repoints _COMMON to agent-brain, and relinks stale managed templates through the new _COMMON. Regular template files remain untouched. The Git snapshot created before installation provides an additional rollback anchor.

Flags

FlagPurpose
--brain <path>Brain root path (skips interactive prompt)
--applyExecute (default: dry-run)
--updategit pull --ff-only the repo before wiring
--runtime claude,opencode,agents,codex,antigravityRestrict to a comma-separated runtime subset (default: all detected)
--symlink-policy copy|keepIngest top-level symlink content, or leave eligible non-canonical links at the brain root

How it works

The installer is a thin orchestrator that delegates to two layers:

  1. brain_state — state machine (virginattachedinitialmaintenance). Determines what flow to run based on the brain's current state.
  2. home_setup — structure: pre-cleanup, staging (for virgin brains), _COMMON symlink, wrapper files, templates.
  3. runtime_manager — all runtime config: detects each runtime, ingests local config into the brain (Direction A), implants brain config into local (Direction B), handles conflicts, links skills.
  4. runtime_health — read-only post-apply validation for every selected runtime, using the same mapping matrix as runtime_manager.

Runtime policy and private configuration belong to the private brain, not this public repository. When a brain contains _AGENTS/SHARED/memory/, Codex receives a stable pointer at ~/.agents/brain-memory; the bundled query tool ranks a small number of indexed notes on demand. Codex's own generated ~/.codex/memories/ directory remains local and separate.

Environment profiles

Environment profiles provide a runtime-neutral contract for selecting issue trackers, repositories, project conventions, and optional private resources without embedding those values in the public core. Profiles live in the private brain under _AGENTS/SHARED/profiles/; global runtime symlinks remain stable when profiles change.

See docs/runtime-profiles.md for the versioned schema, selection algorithm, precedence, safety rules, and sanitized examples. model/SCRIPTS/runtime_health.py loads and validates these files when they exist in a brain. Use --profile <id> for explicit selection or --cwd <path> to exercise project-rule selection. MCP/API availability is delegated to the active runtime adapter; the read-only check never treats a configured provider name as proof of live access.

Skills can call skills/brain/scripts/profile_context.py to resolve generic capabilities into sanitized provider context. --live checks the Codex MCP registry/auth boundary, while the caller can pass exact --available-tool names plus --tool-catalog-complete to enforce active exposure. An omitted or incomplete catalog remains unverified. Claude live discovery is refused because its official registry command may rewrite runtime settings.

Runtime adapters can project standalone private profile resources with model/SCRIPTS/profile_overlays.py. The adapter supplies explicit roots for each selected resource kind; the dry-run-first projector links brain-owned sources, quarantines conflicts, and is safe to apply repeatedly without rewriting runtime configuration.

model/SCRIPTS/profile_secrets.py checks referenced secret names without returning their values. Environment presence, metadata-only macOS keychain lookup, and sanitized runtime-native catalogs share the same fail-closed status contract.

Git is used as rollback anchor: a local snapshot commit or annotated tag is created before any mutation. Snapshot messages are deterministic and snapshot signing is disabled so unattended bootstrap runs never open an editor or a GPG prompt. Nothing is pushed automatically.

Skills

Two skills ship with agent-brain, but only the operating skill is installed automatically:

SkillCommandInstallationPurpose
brain/brain (Codex: $brain)AutomaticConnect to the brain, manage session lifecycle, daily notes, and standardization
boyscout/boyscout (Codex: $boyscout)Opt-inSpot improvement opportunities and route them to an explicit remediation workflow or backlog

Skills live outside the brain and are symlinked to the repo. Codex and OpenCode share ~/.agents/skills/; Claude uses ~/.claude/skills/; Antigravity CLI uses ~/.gemini/antigravity-cli/skills/. The legacy Gemini CLI path is not managed. Skill files use normal names without the .common.md suffix.

The brain skill's session-open apply is idempotent: it creates or updates one session note, upserts exactly one daily recovery entry keyed by the full session ID, preserves a manually edited summary, and checks the resulting session/daily state. Active WIP notes can be checked against the WIP/WIP.md dashboard with the bundled read-only brain_check.py tool.

Install boyscout for Codex only when wanted. Review the dry-run first:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents --apply

The same installer accepts a repo-owned skill directory and can link it into every detected runtime:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold --apply

Repository layout

agent-brain/
├── bootstrap-zero.sh # curl entry point (clones repo, dispatches to orchestrator)
├── docs/ # public architecture and versioned profile schemas
├── examples/profiles/ # sanitized environment-profile examples
├── model/ # the operating model — what _COMMON symlinks to inside a brain
│ ├── AGENTS.common.md # shared agent instructions
│ ├── BRAIN.common.md # brain structure & conventions
│ ├── RULES-*.common.md # daily notes, file naming, links, sessions, evidence
│ ├── JOBS.common.md # recurring maintenance routines
│ ├── TASK_TYPES/ # how-to guides for recurring task types
│ ├── TEMPLATES/ # daily note, WIP, issue, report templates
│ └── SCRIPTS/
│ ├── brain_state.py # state machine (shared)
│ ├── home_setup.py # structure (cleanup, staging, _COMMON, wrappers)
│ ├── runtime_catalog.py # runtime config homes and skill destinations
│ ├── runtime_manager.py # runtime config (Direction A/B, conflict, skill link)
│ ├── runtime_health.py # post-apply checks for all supported runtimes
│ ├── profile_overlays.py # optional private-resource projection
│ ├── profile_secrets.py # value-free secret-reference preflight
│ ├── runtime_install.sh # low-level symlink helper (called by runtime_manager)
│ └── skill_link.sh # manual skill installer for non-default skills
└── skills/
├── brain/ # session lifecycle, daily notes, maintenance
│ ├── SKILL.md
│ ├── scripts/ # session_open.py, brain_check.py, find_home.py, ...
│ └── references/ # project-aware-loading, setup-and-attach, brain-maintenance, runtime-merge
└── boyscout/ # improvement-spotting + backlog management
├── SKILL.md
├── scripts/ # backlog.py, doctor.py, fix-ceremony.sh
└── references/ # finding-schema, detection guides, ticket backends, deep-mode, ...

Files under model/ keep the .common.md naming convention because they live inside a brain (via _COMMON) and must stay link-safe for notes apps. skills/ and the repo root use normal names.

Tests

The stdlib-only test suite runs entirely against temporary brains, homes, and Git repositories:

python3 -m unittest discover -s tests -v

CI executes the same suite on macOS and Linux. The profile integration test uses an isolated temporary HOME and verifies dry-run safety, conflict quarantine, and double-apply idempotence.

See tests/README.md for the covered contracts, individual-test commands, and fixture rules.

Local and CI gates

The canonical local gate is the todo19 QA-manifest alias complete-local-gate, executed only through tests/support/evidence_cli.py run-todo. It runs the current unittest suite, the immutable 113-ID baseline replay, Python compilation, shell syntax checks, committed diff whitespace checks, worktree scope/whitespace checks, the strict operating-model checker, and a zero-__pycache__ assertion.

GitHub Actions mirrors the strict local gate on ubuntu-latest and macos-latest. The workflow checks out full history (fetch-depth: 0), resolves MODEL_BASE from a valid pull-request base, push base, pinned immutable baseline, or root-commit fallback, proves the selected commit object, then runs committed-range gates before the suite and worktree gates after compile/shell checks. The workflow is a contract map only; private-brain migration remains explicit user work and is not automatic.

License

TBD.

About

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

agent-brain

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

agent-brain is a personal operating model for AI coding agents (Claude Code, OpenCode, Codex, Antigravity CLI). It gives you:

  • A second-brain knowledge structure (journal, WIP, memory, tasks) that the model builds on top of any folder of notes — Obsidian is one option, not a requirement.
  • Version-controlled runtime config & memory: your CLAUDE.md / AGENTS.md, memory, and runtime settings live in a git-tracked brain and are symlinked into each runtime (~/.claude, ~/.config/opencode, …), so your agent configuration and memory travel with you across machines.
  • A session lifecycle (daily notes, session notes, consolidation) driven by the brain skill.
  • An optional boyscout skill: spot improvement opportunities while you work, then route them to an explicit remediation workflow or backlog.

Prerequisites

  • Python 3.x (stdlib only — no pip dependencies)
  • git on PATH
  • At least one supported agent runtime installed:
    • Claude Code~/.claude/
    • OpenCode~/.config/opencode/
    • Shared agents dir → ~/.agents/
    • Codex CLI → ~/.codex/ (AGENTS.md and config.toml are persisted under the private brain's _AGENTS/CODEX/; the brain skill is installed at ~/.agents/skills/brain)
    • Antigravity CLI → ~/.gemini/antigravity-cli/ (skill-only integration)

Install

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh | bash

This clones agent-brain to ~/.local/share/agent-brain and runs the orchestrator, which will ask for your brain path (an Obsidian vault, a notes folder, or a new empty dir). It dry-runs by default. After reviewing the plan, use the exact public apply command printed at the end; it preserves the selected brain, runtime filter, and symlink policy:

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh \
| bash -s -- --brain /path/to/brain --apply

If _COMMON already exists

If your brain already has a _COMMON symlink pointing to a different model (e.g. a previous setup), the dry-run reports the current entry and desired symlink separately, including the raw target of a broken link. It also checks every template symlink managed by home_setup and reports stale targets. On --apply, the installer preserves the existing _COMMON entry as _COMMON.backup-<ts>, repoints _COMMON to agent-brain, and relinks stale managed templates through the new _COMMON. Regular template files remain untouched. The Git snapshot created before installation provides an additional rollback anchor.

Flags

FlagPurpose
--brain <path>Brain root path (skips interactive prompt)
--applyExecute (default: dry-run)
--updategit pull --ff-only the repo before wiring
--runtime claude,opencode,agents,codex,antigravityRestrict to a comma-separated runtime subset (default: all detected)
--symlink-policy copy|keepIngest top-level symlink content, or leave eligible non-canonical links at the brain root

How it works

The installer is a thin orchestrator that delegates to two layers:

  1. brain_state — state machine (virginattachedinitialmaintenance). Determines what flow to run based on the brain's current state.
  2. home_setup — structure: pre-cleanup, staging (for virgin brains), _COMMON symlink, wrapper files, templates.
  3. runtime_manager — all runtime config: detects each runtime, ingests local config into the brain (Direction A), implants brain config into local (Direction B), handles conflicts, links skills.
  4. runtime_health — read-only post-apply validation for every selected runtime, using the same mapping matrix as runtime_manager.

Runtime policy and private configuration belong to the private brain, not this public repository. When a brain contains _AGENTS/SHARED/memory/, Codex receives a stable pointer at ~/.agents/brain-memory; the bundled query tool ranks a small number of indexed notes on demand. Codex's own generated ~/.codex/memories/ directory remains local and separate.

Environment profiles

Environment profiles provide a runtime-neutral contract for selecting issue trackers, repositories, project conventions, and optional private resources without embedding those values in the public core. Profiles live in the private brain under _AGENTS/SHARED/profiles/; global runtime symlinks remain stable when profiles change.

See docs/runtime-profiles.md for the versioned schema, selection algorithm, precedence, safety rules, and sanitized examples. model/SCRIPTS/runtime_health.py loads and validates these files when they exist in a brain. Use --profile <id> for explicit selection or --cwd <path> to exercise project-rule selection. MCP/API availability is delegated to the active runtime adapter; the read-only check never treats a configured provider name as proof of live access.

Skills can call skills/brain/scripts/profile_context.py to resolve generic capabilities into sanitized provider context. --live checks the Codex MCP registry/auth boundary, while the caller can pass exact --available-tool names plus --tool-catalog-complete to enforce active exposure. An omitted or incomplete catalog remains unverified. Claude live discovery is refused because its official registry command may rewrite runtime settings.

Runtime adapters can project standalone private profile resources with model/SCRIPTS/profile_overlays.py. The adapter supplies explicit roots for each selected resource kind; the dry-run-first projector links brain-owned sources, quarantines conflicts, and is safe to apply repeatedly without rewriting runtime configuration.

model/SCRIPTS/profile_secrets.py checks referenced secret names without returning their values. Environment presence, metadata-only macOS keychain lookup, and sanitized runtime-native catalogs share the same fail-closed status contract.

Git is used as rollback anchor: a local snapshot commit or annotated tag is created before any mutation. Snapshot messages are deterministic and snapshot signing is disabled so unattended bootstrap runs never open an editor or a GPG prompt. Nothing is pushed automatically.

Skills

Two skills ship with agent-brain, but only the operating skill is installed automatically:

SkillCommandInstallationPurpose
brain/brain (Codex: $brain)AutomaticConnect to the brain, manage session lifecycle, daily notes, and standardization
boyscout/boyscout (Codex: $boyscout)Opt-inSpot improvement opportunities and route them to an explicit remediation workflow or backlog

Skills live outside the brain and are symlinked to the repo. Codex and OpenCode share ~/.agents/skills/; Claude uses ~/.claude/skills/; Antigravity CLI uses ~/.gemini/antigravity-cli/skills/. The legacy Gemini CLI path is not managed. Skill files use normal names without the .common.md suffix.

The brain skill's session-open apply is idempotent: it creates or updates one session note, upserts exactly one daily recovery entry keyed by the full session ID, preserves a manually edited summary, and checks the resulting session/daily state. Active WIP notes can be checked against the WIP/WIP.md dashboard with the bundled read-only brain_check.py tool.

Install boyscout for Codex only when wanted. Review the dry-run first:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents --apply

The same installer accepts a repo-owned skill directory and can link it into every detected runtime:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold --apply

Repository layout

agent-brain/
├── bootstrap-zero.sh # curl entry point (clones repo, dispatches to orchestrator)
├── docs/ # public architecture and versioned profile schemas
├── examples/profiles/ # sanitized environment-profile examples
├── model/ # the operating model — what _COMMON symlinks to inside a brain
│ ├── AGENTS.common.md # shared agent instructions
│ ├── BRAIN.common.md # brain structure & conventions
│ ├── RULES-*.common.md # daily notes, file naming, links, sessions, evidence
│ ├── JOBS.common.md # recurring maintenance routines
│ ├── TASK_TYPES/ # how-to guides for recurring task types
│ ├── TEMPLATES/ # daily note, WIP, issue, report templates
│ └── SCRIPTS/
│ ├── brain_state.py # state machine (shared)
│ ├── home_setup.py # structure (cleanup, staging, _COMMON, wrappers)
│ ├── runtime_catalog.py # runtime config homes and skill destinations
│ ├── runtime_manager.py # runtime config (Direction A/B, conflict, skill link)
│ ├── runtime_health.py # post-apply checks for all supported runtimes
│ ├── profile_overlays.py # optional private-resource projection
│ ├── profile_secrets.py # value-free secret-reference preflight
│ ├── runtime_install.sh # low-level symlink helper (called by runtime_manager)
│ └── skill_link.sh # manual skill installer for non-default skills
└── skills/
├── brain/ # session lifecycle, daily notes, maintenance
│ ├── SKILL.md
│ ├── scripts/ # session_open.py, brain_check.py, find_home.py, ...
│ └── references/ # project-aware-loading, setup-and-attach, brain-maintenance, runtime-merge
└── boyscout/ # improvement-spotting + backlog management
├── SKILL.md
├── scripts/ # backlog.py, doctor.py, fix-ceremony.sh
└── references/ # finding-schema, detection guides, ticket backends, deep-mode, ...

Files under model/ keep the .common.md naming convention because they live inside a brain (via _COMMON) and must stay link-safe for notes apps. skills/ and the repo root use normal names.

Tests

The stdlib-only test suite runs entirely against temporary brains, homes, and Git repositories:

python3 -m unittest discover -s tests -v

CI executes the same suite on macOS and Linux. The profile integration test uses an isolated temporary HOME and verifies dry-run safety, conflict quarantine, and double-apply idempotence.

See tests/README.md for the covered contracts, individual-test commands, and fixture rules.

Local and CI gates

The canonical local gate is the todo19 QA-manifest alias complete-local-gate, executed only through tests/support/evidence_cli.py run-todo. It runs the current unittest suite, the immutable 113-ID baseline replay, Python compilation, shell syntax checks, committed diff whitespace checks, worktree scope/whitespace checks, the strict operating-model checker, and a zero-__pycache__ assertion.

GitHub Actions mirrors the strict local gate on ubuntu-latest and macos-latest. The workflow checks out full history (fetch-depth: 0), resolves MODEL_BASE from a valid pull-request base, push base, pinned immutable baseline, or root-commit fallback, proves the selected commit object, then runs committed-range gates before the suite and worktree gates after compile/shell checks. The workflow is a contract map only; private-brain migration remains explicit user work and is not automatic.

License

TBD.

About

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

agent-brain

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

agent-brain is a personal operating model for AI coding agents (Claude Code, OpenCode, Codex, Antigravity CLI). It gives you:

  • A second-brain knowledge structure (journal, WIP, memory, tasks) that the model builds on top of any folder of notes — Obsidian is one option, not a requirement.
  • Version-controlled runtime config & memory: your CLAUDE.md / AGENTS.md, memory, and runtime settings live in a git-tracked brain and are symlinked into each runtime (~/.claude, ~/.config/opencode, …), so your agent configuration and memory travel with you across machines.
  • A session lifecycle (daily notes, session notes, consolidation) driven by the brain skill.
  • An optional boyscout skill: spot improvement opportunities while you work, then route them to an explicit remediation workflow or backlog.

Prerequisites

  • Python 3.x (stdlib only — no pip dependencies)
  • git on PATH
  • At least one supported agent runtime installed:
    • Claude Code~/.claude/
    • OpenCode~/.config/opencode/
    • Shared agents dir → ~/.agents/
    • Codex CLI → ~/.codex/ (AGENTS.md and config.toml are persisted under the private brain's _AGENTS/CODEX/; the brain skill is installed at ~/.agents/skills/brain)
    • Antigravity CLI → ~/.gemini/antigravity-cli/ (skill-only integration)

Install

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh | bash

This clones agent-brain to ~/.local/share/agent-brain and runs the orchestrator, which will ask for your brain path (an Obsidian vault, a notes folder, or a new empty dir). It dry-runs by default. After reviewing the plan, use the exact public apply command printed at the end; it preserves the selected brain, runtime filter, and symlink policy:

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh \
| bash -s -- --brain /path/to/brain --apply

If _COMMON already exists

If your brain already has a _COMMON symlink pointing to a different model (e.g. a previous setup), the dry-run reports the current entry and desired symlink separately, including the raw target of a broken link. It also checks every template symlink managed by home_setup and reports stale targets. On --apply, the installer preserves the existing _COMMON entry as _COMMON.backup-<ts>, repoints _COMMON to agent-brain, and relinks stale managed templates through the new _COMMON. Regular template files remain untouched. The Git snapshot created before installation provides an additional rollback anchor.

Flags

FlagPurpose
--brain <path>Brain root path (skips interactive prompt)
--applyExecute (default: dry-run)
--updategit pull --ff-only the repo before wiring
--runtime claude,opencode,agents,codex,antigravityRestrict to a comma-separated runtime subset (default: all detected)
--symlink-policy copy|keepIngest top-level symlink content, or leave eligible non-canonical links at the brain root

How it works

The installer is a thin orchestrator that delegates to two layers:

  1. brain_state — state machine (virginattachedinitialmaintenance). Determines what flow to run based on the brain's current state.
  2. home_setup — structure: pre-cleanup, staging (for virgin brains), _COMMON symlink, wrapper files, templates.
  3. runtime_manager — all runtime config: detects each runtime, ingests local config into the brain (Direction A), implants brain config into local (Direction B), handles conflicts, links skills.
  4. runtime_health — read-only post-apply validation for every selected runtime, using the same mapping matrix as runtime_manager.

Runtime policy and private configuration belong to the private brain, not this public repository. When a brain contains _AGENTS/SHARED/memory/, Codex receives a stable pointer at ~/.agents/brain-memory; the bundled query tool ranks a small number of indexed notes on demand. Codex's own generated ~/.codex/memories/ directory remains local and separate.

Environment profiles

Environment profiles provide a runtime-neutral contract for selecting issue trackers, repositories, project conventions, and optional private resources without embedding those values in the public core. Profiles live in the private brain under _AGENTS/SHARED/profiles/; global runtime symlinks remain stable when profiles change.

See docs/runtime-profiles.md for the versioned schema, selection algorithm, precedence, safety rules, and sanitized examples. model/SCRIPTS/runtime_health.py loads and validates these files when they exist in a brain. Use --profile <id> for explicit selection or --cwd <path> to exercise project-rule selection. MCP/API availability is delegated to the active runtime adapter; the read-only check never treats a configured provider name as proof of live access.

Skills can call skills/brain/scripts/profile_context.py to resolve generic capabilities into sanitized provider context. --live checks the Codex MCP registry/auth boundary, while the caller can pass exact --available-tool names plus --tool-catalog-complete to enforce active exposure. An omitted or incomplete catalog remains unverified. Claude live discovery is refused because its official registry command may rewrite runtime settings.

Runtime adapters can project standalone private profile resources with model/SCRIPTS/profile_overlays.py. The adapter supplies explicit roots for each selected resource kind; the dry-run-first projector links brain-owned sources, quarantines conflicts, and is safe to apply repeatedly without rewriting runtime configuration.

model/SCRIPTS/profile_secrets.py checks referenced secret names without returning their values. Environment presence, metadata-only macOS keychain lookup, and sanitized runtime-native catalogs share the same fail-closed status contract.

Git is used as rollback anchor: a local snapshot commit or annotated tag is created before any mutation. Snapshot messages are deterministic and snapshot signing is disabled so unattended bootstrap runs never open an editor or a GPG prompt. Nothing is pushed automatically.

Skills

Two skills ship with agent-brain, but only the operating skill is installed automatically:

SkillCommandInstallationPurpose
brain/brain (Codex: $brain)AutomaticConnect to the brain, manage session lifecycle, daily notes, and standardization
boyscout/boyscout (Codex: $boyscout)Opt-inSpot improvement opportunities and route them to an explicit remediation workflow or backlog

Skills live outside the brain and are symlinked to the repo. Codex and OpenCode share ~/.agents/skills/; Claude uses ~/.claude/skills/; Antigravity CLI uses ~/.gemini/antigravity-cli/skills/. The legacy Gemini CLI path is not managed. Skill files use normal names without the .common.md suffix.

The brain skill's session-open apply is idempotent: it creates or updates one session note, upserts exactly one daily recovery entry keyed by the full session ID, preserves a manually edited summary, and checks the resulting session/daily state. Active WIP notes can be checked against the WIP/WIP.md dashboard with the bundled read-only brain_check.py tool.

Install boyscout for Codex only when wanted. Review the dry-run first:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents --apply

The same installer accepts a repo-owned skill directory and can link it into every detected runtime:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold --apply

Repository layout

agent-brain/
├── bootstrap-zero.sh # curl entry point (clones repo, dispatches to orchestrator)
├── docs/ # public architecture and versioned profile schemas
├── examples/profiles/ # sanitized environment-profile examples
├── model/ # the operating model — what _COMMON symlinks to inside a brain
│ ├── AGENTS.common.md # shared agent instructions
│ ├── BRAIN.common.md # brain structure & conventions
│ ├── RULES-*.common.md # daily notes, file naming, links, sessions, evidence
│ ├── JOBS.common.md # recurring maintenance routines
│ ├── TASK_TYPES/ # how-to guides for recurring task types
│ ├── TEMPLATES/ # daily note, WIP, issue, report templates
│ └── SCRIPTS/
│ ├── brain_state.py # state machine (shared)
│ ├── home_setup.py # structure (cleanup, staging, _COMMON, wrappers)
│ ├── runtime_catalog.py # runtime config homes and skill destinations
│ ├── runtime_manager.py # runtime config (Direction A/B, conflict, skill link)
│ ├── runtime_health.py # post-apply checks for all supported runtimes
│ ├── profile_overlays.py # optional private-resource projection
│ ├── profile_secrets.py # value-free secret-reference preflight
│ ├── runtime_install.sh # low-level symlink helper (called by runtime_manager)
│ └── skill_link.sh # manual skill installer for non-default skills
└── skills/
├── brain/ # session lifecycle, daily notes, maintenance
│ ├── SKILL.md
│ ├── scripts/ # session_open.py, brain_check.py, find_home.py, ...
│ └── references/ # project-aware-loading, setup-and-attach, brain-maintenance, runtime-merge
└── boyscout/ # improvement-spotting + backlog management
├── SKILL.md
├── scripts/ # backlog.py, doctor.py, fix-ceremony.sh
└── references/ # finding-schema, detection guides, ticket backends, deep-mode, ...

Files under model/ keep the .common.md naming convention because they live inside a brain (via _COMMON) and must stay link-safe for notes apps. skills/ and the repo root use normal names.

Tests

The stdlib-only test suite runs entirely against temporary brains, homes, and Git repositories:

python3 -m unittest discover -s tests -v

CI executes the same suite on macOS and Linux. The profile integration test uses an isolated temporary HOME and verifies dry-run safety, conflict quarantine, and double-apply idempotence.

See tests/README.md for the covered contracts, individual-test commands, and fixture rules.

Local and CI gates

The canonical local gate is the todo19 QA-manifest alias complete-local-gate, executed only through tests/support/evidence_cli.py run-todo. It runs the current unittest suite, the immutable 113-ID baseline replay, Python compilation, shell syntax checks, committed diff whitespace checks, worktree scope/whitespace checks, the strict operating-model checker, and a zero-__pycache__ assertion.

GitHub Actions mirrors the strict local gate on ubuntu-latest and macos-latest. The workflow checks out full history (fetch-depth: 0), resolves MODEL_BASE from a valid pull-request base, push base, pinned immutable baseline, or root-commit fallback, proves the selected commit object, then runs committed-range gates before the suite and worktree gates after compile/shell checks. The workflow is a contract map only; private-brain migration remains explicit user work and is not automatic.

License

TBD.

About

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

agent-brain

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

agent-brain is a personal operating model for AI coding agents (Claude Code, OpenCode, Codex, Antigravity CLI). It gives you:

  • A second-brain knowledge structure (journal, WIP, memory, tasks) that the model builds on top of any folder of notes — Obsidian is one option, not a requirement.
  • Version-controlled runtime config & memory: your CLAUDE.md / AGENTS.md, memory, and runtime settings live in a git-tracked brain and are symlinked into each runtime (~/.claude, ~/.config/opencode, …), so your agent configuration and memory travel with you across machines.
  • A session lifecycle (daily notes, session notes, consolidation) driven by the brain skill.
  • An optional boyscout skill: spot improvement opportunities while you work, then route them to an explicit remediation workflow or backlog.

Prerequisites

  • Python 3.x (stdlib only — no pip dependencies)
  • git on PATH
  • At least one supported agent runtime installed:
    • Claude Code~/.claude/
    • OpenCode~/.config/opencode/
    • Shared agents dir → ~/.agents/
    • Codex CLI → ~/.codex/ (AGENTS.md and config.toml are persisted under the private brain's _AGENTS/CODEX/; the brain skill is installed at ~/.agents/skills/brain)
    • Antigravity CLI → ~/.gemini/antigravity-cli/ (skill-only integration)

Install

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh | bash

This clones agent-brain to ~/.local/share/agent-brain and runs the orchestrator, which will ask for your brain path (an Obsidian vault, a notes folder, or a new empty dir). It dry-runs by default. After reviewing the plan, use the exact public apply command printed at the end; it preserves the selected brain, runtime filter, and symlink policy:

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh \
| bash -s -- --brain /path/to/brain --apply

If _COMMON already exists

If your brain already has a _COMMON symlink pointing to a different model (e.g. a previous setup), the dry-run reports the current entry and desired symlink separately, including the raw target of a broken link. It also checks every template symlink managed by home_setup and reports stale targets. On --apply, the installer preserves the existing _COMMON entry as _COMMON.backup-<ts>, repoints _COMMON to agent-brain, and relinks stale managed templates through the new _COMMON. Regular template files remain untouched. The Git snapshot created before installation provides an additional rollback anchor.

Flags

FlagPurpose
--brain <path>Brain root path (skips interactive prompt)
--applyExecute (default: dry-run)
--updategit pull --ff-only the repo before wiring
--runtime claude,opencode,agents,codex,antigravityRestrict to a comma-separated runtime subset (default: all detected)
--symlink-policy copy|keepIngest top-level symlink content, or leave eligible non-canonical links at the brain root

How it works

The installer is a thin orchestrator that delegates to two layers:

  1. brain_state — state machine (virginattachedinitialmaintenance). Determines what flow to run based on the brain's current state.
  2. home_setup — structure: pre-cleanup, staging (for virgin brains), _COMMON symlink, wrapper files, templates.
  3. runtime_manager — all runtime config: detects each runtime, ingests local config into the brain (Direction A), implants brain config into local (Direction B), handles conflicts, links skills.
  4. runtime_health — read-only post-apply validation for every selected runtime, using the same mapping matrix as runtime_manager.

Runtime policy and private configuration belong to the private brain, not this public repository. When a brain contains _AGENTS/SHARED/memory/, Codex receives a stable pointer at ~/.agents/brain-memory; the bundled query tool ranks a small number of indexed notes on demand. Codex's own generated ~/.codex/memories/ directory remains local and separate.

Environment profiles

Environment profiles provide a runtime-neutral contract for selecting issue trackers, repositories, project conventions, and optional private resources without embedding those values in the public core. Profiles live in the private brain under _AGENTS/SHARED/profiles/; global runtime symlinks remain stable when profiles change.

See docs/runtime-profiles.md for the versioned schema, selection algorithm, precedence, safety rules, and sanitized examples. model/SCRIPTS/runtime_health.py loads and validates these files when they exist in a brain. Use --profile <id> for explicit selection or --cwd <path> to exercise project-rule selection. MCP/API availability is delegated to the active runtime adapter; the read-only check never treats a configured provider name as proof of live access.

Skills can call skills/brain/scripts/profile_context.py to resolve generic capabilities into sanitized provider context. --live checks the Codex MCP registry/auth boundary, while the caller can pass exact --available-tool names plus --tool-catalog-complete to enforce active exposure. An omitted or incomplete catalog remains unverified. Claude live discovery is refused because its official registry command may rewrite runtime settings.

Runtime adapters can project standalone private profile resources with model/SCRIPTS/profile_overlays.py. The adapter supplies explicit roots for each selected resource kind; the dry-run-first projector links brain-owned sources, quarantines conflicts, and is safe to apply repeatedly without rewriting runtime configuration.

model/SCRIPTS/profile_secrets.py checks referenced secret names without returning their values. Environment presence, metadata-only macOS keychain lookup, and sanitized runtime-native catalogs share the same fail-closed status contract.

Git is used as rollback anchor: a local snapshot commit or annotated tag is created before any mutation. Snapshot messages are deterministic and snapshot signing is disabled so unattended bootstrap runs never open an editor or a GPG prompt. Nothing is pushed automatically.

Skills

Two skills ship with agent-brain, but only the operating skill is installed automatically:

SkillCommandInstallationPurpose
brain/brain (Codex: $brain)AutomaticConnect to the brain, manage session lifecycle, daily notes, and standardization
boyscout/boyscout (Codex: $boyscout)Opt-inSpot improvement opportunities and route them to an explicit remediation workflow or backlog

Skills live outside the brain and are symlinked to the repo. Codex and OpenCode share ~/.agents/skills/; Claude uses ~/.claude/skills/; Antigravity CLI uses ~/.gemini/antigravity-cli/skills/. The legacy Gemini CLI path is not managed. Skill files use normal names without the .common.md suffix.

The brain skill's session-open apply is idempotent: it creates or updates one session note, upserts exactly one daily recovery entry keyed by the full session ID, preserves a manually edited summary, and checks the resulting session/daily state. Active WIP notes can be checked against the WIP/WIP.md dashboard with the bundled read-only brain_check.py tool.

Install boyscout for Codex only when wanted. Review the dry-run first:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents --apply

The same installer accepts a repo-owned skill directory and can link it into every detected runtime:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold --apply

Repository layout

agent-brain/
├── bootstrap-zero.sh # curl entry point (clones repo, dispatches to orchestrator)
├── docs/ # public architecture and versioned profile schemas
├── examples/profiles/ # sanitized environment-profile examples
├── model/ # the operating model — what _COMMON symlinks to inside a brain
│ ├── AGENTS.common.md # shared agent instructions
│ ├── BRAIN.common.md # brain structure & conventions
│ ├── RULES-*.common.md # daily notes, file naming, links, sessions, evidence
│ ├── JOBS.common.md # recurring maintenance routines
│ ├── TASK_TYPES/ # how-to guides for recurring task types
│ ├── TEMPLATES/ # daily note, WIP, issue, report templates
│ └── SCRIPTS/
│ ├── brain_state.py # state machine (shared)
│ ├── home_setup.py # structure (cleanup, staging, _COMMON, wrappers)
│ ├── runtime_catalog.py # runtime config homes and skill destinations
│ ├── runtime_manager.py # runtime config (Direction A/B, conflict, skill link)
│ ├── runtime_health.py # post-apply checks for all supported runtimes
│ ├── profile_overlays.py # optional private-resource projection
│ ├── profile_secrets.py # value-free secret-reference preflight
│ ├── runtime_install.sh # low-level symlink helper (called by runtime_manager)
│ └── skill_link.sh # manual skill installer for non-default skills
└── skills/
├── brain/ # session lifecycle, daily notes, maintenance
│ ├── SKILL.md
│ ├── scripts/ # session_open.py, brain_check.py, find_home.py, ...
│ └── references/ # project-aware-loading, setup-and-attach, brain-maintenance, runtime-merge
└── boyscout/ # improvement-spotting + backlog management
├── SKILL.md
├── scripts/ # backlog.py, doctor.py, fix-ceremony.sh
└── references/ # finding-schema, detection guides, ticket backends, deep-mode, ...

Files under model/ keep the .common.md naming convention because they live inside a brain (via _COMMON) and must stay link-safe for notes apps. skills/ and the repo root use normal names.

Tests

The stdlib-only test suite runs entirely against temporary brains, homes, and Git repositories:

python3 -m unittest discover -s tests -v

CI executes the same suite on macOS and Linux. The profile integration test uses an isolated temporary HOME and verifies dry-run safety, conflict quarantine, and double-apply idempotence.

See tests/README.md for the covered contracts, individual-test commands, and fixture rules.

Local and CI gates

The canonical local gate is the todo19 QA-manifest alias complete-local-gate, executed only through tests/support/evidence_cli.py run-todo. It runs the current unittest suite, the immutable 113-ID baseline replay, Python compilation, shell syntax checks, committed diff whitespace checks, worktree scope/whitespace checks, the strict operating-model checker, and a zero-__pycache__ assertion.

GitHub Actions mirrors the strict local gate on ubuntu-latest and macos-latest. The workflow checks out full history (fetch-depth: 0), resolves MODEL_BASE from a valid pull-request base, push base, pinned immutable baseline, or root-commit fallback, proves the selected commit object, then runs committed-range gates before the suite and worktree gates after compile/shell checks. The workflow is a contract map only; private-brain migration remains explicit user work and is not automatic.

License

TBD.

About

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

agent-brain

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

agent-brain is a personal operating model for AI coding agents (Claude Code, OpenCode, Codex, Antigravity CLI). It gives you:

  • A second-brain knowledge structure (journal, WIP, memory, tasks) that the model builds on top of any folder of notes — Obsidian is one option, not a requirement.
  • Version-controlled runtime config & memory: your CLAUDE.md / AGENTS.md, memory, and runtime settings live in a git-tracked brain and are symlinked into each runtime (~/.claude, ~/.config/opencode, …), so your agent configuration and memory travel with you across machines.
  • A session lifecycle (daily notes, session notes, consolidation) driven by the brain skill.
  • An optional boyscout skill: spot improvement opportunities while you work, then route them to an explicit remediation workflow or backlog.

Prerequisites

  • Python 3.x (stdlib only — no pip dependencies)
  • git on PATH
  • At least one supported agent runtime installed:
    • Claude Code~/.claude/
    • OpenCode~/.config/opencode/
    • Shared agents dir → ~/.agents/
    • Codex CLI → ~/.codex/ (AGENTS.md and config.toml are persisted under the private brain's _AGENTS/CODEX/; the brain skill is installed at ~/.agents/skills/brain)
    • Antigravity CLI → ~/.gemini/antigravity-cli/ (skill-only integration)

Install

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh | bash

This clones agent-brain to ~/.local/share/agent-brain and runs the orchestrator, which will ask for your brain path (an Obsidian vault, a notes folder, or a new empty dir). It dry-runs by default. After reviewing the plan, use the exact public apply command printed at the end; it preserves the selected brain, runtime filter, and symlink policy:

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh \
| bash -s -- --brain /path/to/brain --apply

If _COMMON already exists

If your brain already has a _COMMON symlink pointing to a different model (e.g. a previous setup), the dry-run reports the current entry and desired symlink separately, including the raw target of a broken link. It also checks every template symlink managed by home_setup and reports stale targets. On --apply, the installer preserves the existing _COMMON entry as _COMMON.backup-<ts>, repoints _COMMON to agent-brain, and relinks stale managed templates through the new _COMMON. Regular template files remain untouched. The Git snapshot created before installation provides an additional rollback anchor.

Flags

FlagPurpose
--brain <path>Brain root path (skips interactive prompt)
--applyExecute (default: dry-run)
--updategit pull --ff-only the repo before wiring
--runtime claude,opencode,agents,codex,antigravityRestrict to a comma-separated runtime subset (default: all detected)
--symlink-policy copy|keepIngest top-level symlink content, or leave eligible non-canonical links at the brain root

How it works

The installer is a thin orchestrator that delegates to two layers:

  1. brain_state — state machine (virginattachedinitialmaintenance). Determines what flow to run based on the brain's current state.
  2. home_setup — structure: pre-cleanup, staging (for virgin brains), _COMMON symlink, wrapper files, templates.
  3. runtime_manager — all runtime config: detects each runtime, ingests local config into the brain (Direction A), implants brain config into local (Direction B), handles conflicts, links skills.
  4. runtime_health — read-only post-apply validation for every selected runtime, using the same mapping matrix as runtime_manager.

Runtime policy and private configuration belong to the private brain, not this public repository. When a brain contains _AGENTS/SHARED/memory/, Codex receives a stable pointer at ~/.agents/brain-memory; the bundled query tool ranks a small number of indexed notes on demand. Codex's own generated ~/.codex/memories/ directory remains local and separate.

Environment profiles

Environment profiles provide a runtime-neutral contract for selecting issue trackers, repositories, project conventions, and optional private resources without embedding those values in the public core. Profiles live in the private brain under _AGENTS/SHARED/profiles/; global runtime symlinks remain stable when profiles change.

See docs/runtime-profiles.md for the versioned schema, selection algorithm, precedence, safety rules, and sanitized examples. model/SCRIPTS/runtime_health.py loads and validates these files when they exist in a brain. Use --profile <id> for explicit selection or --cwd <path> to exercise project-rule selection. MCP/API availability is delegated to the active runtime adapter; the read-only check never treats a configured provider name as proof of live access.

Skills can call skills/brain/scripts/profile_context.py to resolve generic capabilities into sanitized provider context. --live checks the Codex MCP registry/auth boundary, while the caller can pass exact --available-tool names plus --tool-catalog-complete to enforce active exposure. An omitted or incomplete catalog remains unverified. Claude live discovery is refused because its official registry command may rewrite runtime settings.

Runtime adapters can project standalone private profile resources with model/SCRIPTS/profile_overlays.py. The adapter supplies explicit roots for each selected resource kind; the dry-run-first projector links brain-owned sources, quarantines conflicts, and is safe to apply repeatedly without rewriting runtime configuration.

model/SCRIPTS/profile_secrets.py checks referenced secret names without returning their values. Environment presence, metadata-only macOS keychain lookup, and sanitized runtime-native catalogs share the same fail-closed status contract.

Git is used as rollback anchor: a local snapshot commit or annotated tag is created before any mutation. Snapshot messages are deterministic and snapshot signing is disabled so unattended bootstrap runs never open an editor or a GPG prompt. Nothing is pushed automatically.

Skills

Two skills ship with agent-brain, but only the operating skill is installed automatically:

SkillCommandInstallationPurpose
brain/brain (Codex: $brain)AutomaticConnect to the brain, manage session lifecycle, daily notes, and standardization
boyscout/boyscout (Codex: $boyscout)Opt-inSpot improvement opportunities and route them to an explicit remediation workflow or backlog

Skills live outside the brain and are symlinked to the repo. Codex and OpenCode share ~/.agents/skills/; Claude uses ~/.claude/skills/; Antigravity CLI uses ~/.gemini/antigravity-cli/skills/. The legacy Gemini CLI path is not managed. Skill files use normal names without the .common.md suffix.

The brain skill's session-open apply is idempotent: it creates or updates one session note, upserts exactly one daily recovery entry keyed by the full session ID, preserves a manually edited summary, and checks the resulting session/daily state. Active WIP notes can be checked against the WIP/WIP.md dashboard with the bundled read-only brain_check.py tool.

Install boyscout for Codex only when wanted. Review the dry-run first:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents --apply

The same installer accepts a repo-owned skill directory and can link it into every detected runtime:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold --apply

Repository layout

agent-brain/
├── bootstrap-zero.sh # curl entry point (clones repo, dispatches to orchestrator)
├── docs/ # public architecture and versioned profile schemas
├── examples/profiles/ # sanitized environment-profile examples
├── model/ # the operating model — what _COMMON symlinks to inside a brain
│ ├── AGENTS.common.md # shared agent instructions
│ ├── BRAIN.common.md # brain structure & conventions
│ ├── RULES-*.common.md # daily notes, file naming, links, sessions, evidence
│ ├── JOBS.common.md # recurring maintenance routines
│ ├── TASK_TYPES/ # how-to guides for recurring task types
│ ├── TEMPLATES/ # daily note, WIP, issue, report templates
│ └── SCRIPTS/
│ ├── brain_state.py # state machine (shared)
│ ├── home_setup.py # structure (cleanup, staging, _COMMON, wrappers)
│ ├── runtime_catalog.py # runtime config homes and skill destinations
│ ├── runtime_manager.py # runtime config (Direction A/B, conflict, skill link)
│ ├── runtime_health.py # post-apply checks for all supported runtimes
│ ├── profile_overlays.py # optional private-resource projection
│ ├── profile_secrets.py # value-free secret-reference preflight
│ ├── runtime_install.sh # low-level symlink helper (called by runtime_manager)
│ └── skill_link.sh # manual skill installer for non-default skills
└── skills/
├── brain/ # session lifecycle, daily notes, maintenance
│ ├── SKILL.md
│ ├── scripts/ # session_open.py, brain_check.py, find_home.py, ...
│ └── references/ # project-aware-loading, setup-and-attach, brain-maintenance, runtime-merge
└── boyscout/ # improvement-spotting + backlog management
├── SKILL.md
├── scripts/ # backlog.py, doctor.py, fix-ceremony.sh
└── references/ # finding-schema, detection guides, ticket backends, deep-mode, ...

Files under model/ keep the .common.md naming convention because they live inside a brain (via _COMMON) and must stay link-safe for notes apps. skills/ and the repo root use normal names.

Tests

The stdlib-only test suite runs entirely against temporary brains, homes, and Git repositories:

python3 -m unittest discover -s tests -v

CI executes the same suite on macOS and Linux. The profile integration test uses an isolated temporary HOME and verifies dry-run safety, conflict quarantine, and double-apply idempotence.

See tests/README.md for the covered contracts, individual-test commands, and fixture rules.

Local and CI gates

The canonical local gate is the todo19 QA-manifest alias complete-local-gate, executed only through tests/support/evidence_cli.py run-todo. It runs the current unittest suite, the immutable 113-ID baseline replay, Python compilation, shell syntax checks, committed diff whitespace checks, worktree scope/whitespace checks, the strict operating-model checker, and a zero-__pycache__ assertion.

GitHub Actions mirrors the strict local gate on ubuntu-latest and macos-latest. The workflow checks out full history (fetch-depth: 0), resolves MODEL_BASE from a valid pull-request base, push base, pinned immutable baseline, or root-commit fallback, proves the selected commit object, then runs committed-range gates before the suite and worktree gates after compile/shell checks. The workflow is a contract map only; private-brain migration remains explicit user work and is not automatic.

License

TBD.

About

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

agent-brain

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

agent-brain is a personal operating model for AI coding agents (Claude Code, OpenCode, Codex, Antigravity CLI). It gives you:

  • A second-brain knowledge structure (journal, WIP, memory, tasks) that the model builds on top of any folder of notes — Obsidian is one option, not a requirement.
  • Version-controlled runtime config & memory: your CLAUDE.md / AGENTS.md, memory, and runtime settings live in a git-tracked brain and are symlinked into each runtime (~/.claude, ~/.config/opencode, …), so your agent configuration and memory travel with you across machines.
  • A session lifecycle (daily notes, session notes, consolidation) driven by the brain skill.
  • An optional boyscout skill: spot improvement opportunities while you work, then route them to an explicit remediation workflow or backlog.

Prerequisites

  • Python 3.x (stdlib only — no pip dependencies)
  • git on PATH
  • At least one supported agent runtime installed:
    • Claude Code~/.claude/
    • OpenCode~/.config/opencode/
    • Shared agents dir → ~/.agents/
    • Codex CLI → ~/.codex/ (AGENTS.md and config.toml are persisted under the private brain's _AGENTS/CODEX/; the brain skill is installed at ~/.agents/skills/brain)
    • Antigravity CLI → ~/.gemini/antigravity-cli/ (skill-only integration)

Install

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh | bash

This clones agent-brain to ~/.local/share/agent-brain and runs the orchestrator, which will ask for your brain path (an Obsidian vault, a notes folder, or a new empty dir). It dry-runs by default. After reviewing the plan, use the exact public apply command printed at the end; it preserves the selected brain, runtime filter, and symlink policy:

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh \
| bash -s -- --brain /path/to/brain --apply

If _COMMON already exists

If your brain already has a _COMMON symlink pointing to a different model (e.g. a previous setup), the dry-run reports the current entry and desired symlink separately, including the raw target of a broken link. It also checks every template symlink managed by home_setup and reports stale targets. On --apply, the installer preserves the existing _COMMON entry as _COMMON.backup-<ts>, repoints _COMMON to agent-brain, and relinks stale managed templates through the new _COMMON. Regular template files remain untouched. The Git snapshot created before installation provides an additional rollback anchor.

Flags

FlagPurpose
--brain <path>Brain root path (skips interactive prompt)
--applyExecute (default: dry-run)
--updategit pull --ff-only the repo before wiring
--runtime claude,opencode,agents,codex,antigravityRestrict to a comma-separated runtime subset (default: all detected)
--symlink-policy copy|keepIngest top-level symlink content, or leave eligible non-canonical links at the brain root

How it works

The installer is a thin orchestrator that delegates to two layers:

  1. brain_state — state machine (virginattachedinitialmaintenance). Determines what flow to run based on the brain's current state.
  2. home_setup — structure: pre-cleanup, staging (for virgin brains), _COMMON symlink, wrapper files, templates.
  3. runtime_manager — all runtime config: detects each runtime, ingests local config into the brain (Direction A), implants brain config into local (Direction B), handles conflicts, links skills.
  4. runtime_health — read-only post-apply validation for every selected runtime, using the same mapping matrix as runtime_manager.

Runtime policy and private configuration belong to the private brain, not this public repository. When a brain contains _AGENTS/SHARED/memory/, Codex receives a stable pointer at ~/.agents/brain-memory; the bundled query tool ranks a small number of indexed notes on demand. Codex's own generated ~/.codex/memories/ directory remains local and separate.

Environment profiles

Environment profiles provide a runtime-neutral contract for selecting issue trackers, repositories, project conventions, and optional private resources without embedding those values in the public core. Profiles live in the private brain under _AGENTS/SHARED/profiles/; global runtime symlinks remain stable when profiles change.

See docs/runtime-profiles.md for the versioned schema, selection algorithm, precedence, safety rules, and sanitized examples. model/SCRIPTS/runtime_health.py loads and validates these files when they exist in a brain. Use --profile <id> for explicit selection or --cwd <path> to exercise project-rule selection. MCP/API availability is delegated to the active runtime adapter; the read-only check never treats a configured provider name as proof of live access.

Skills can call skills/brain/scripts/profile_context.py to resolve generic capabilities into sanitized provider context. --live checks the Codex MCP registry/auth boundary, while the caller can pass exact --available-tool names plus --tool-catalog-complete to enforce active exposure. An omitted or incomplete catalog remains unverified. Claude live discovery is refused because its official registry command may rewrite runtime settings.

Runtime adapters can project standalone private profile resources with model/SCRIPTS/profile_overlays.py. The adapter supplies explicit roots for each selected resource kind; the dry-run-first projector links brain-owned sources, quarantines conflicts, and is safe to apply repeatedly without rewriting runtime configuration.

model/SCRIPTS/profile_secrets.py checks referenced secret names without returning their values. Environment presence, metadata-only macOS keychain lookup, and sanitized runtime-native catalogs share the same fail-closed status contract.

Git is used as rollback anchor: a local snapshot commit or annotated tag is created before any mutation. Snapshot messages are deterministic and snapshot signing is disabled so unattended bootstrap runs never open an editor or a GPG prompt. Nothing is pushed automatically.

Skills

Two skills ship with agent-brain, but only the operating skill is installed automatically:

SkillCommandInstallationPurpose
brain/brain (Codex: $brain)AutomaticConnect to the brain, manage session lifecycle, daily notes, and standardization
boyscout/boyscout (Codex: $boyscout)Opt-inSpot improvement opportunities and route them to an explicit remediation workflow or backlog

Skills live outside the brain and are symlinked to the repo. Codex and OpenCode share ~/.agents/skills/; Claude uses ~/.claude/skills/; Antigravity CLI uses ~/.gemini/antigravity-cli/skills/. The legacy Gemini CLI path is not managed. Skill files use normal names without the .common.md suffix.

The brain skill's session-open apply is idempotent: it creates or updates one session note, upserts exactly one daily recovery entry keyed by the full session ID, preserves a manually edited summary, and checks the resulting session/daily state. Active WIP notes can be checked against the WIP/WIP.md dashboard with the bundled read-only brain_check.py tool.

Install boyscout for Codex only when wanted. Review the dry-run first:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents --apply

The same installer accepts a repo-owned skill directory and can link it into every detected runtime:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold --apply

Repository layout

agent-brain/
├── bootstrap-zero.sh # curl entry point (clones repo, dispatches to orchestrator)
├── docs/ # public architecture and versioned profile schemas
├── examples/profiles/ # sanitized environment-profile examples
├── model/ # the operating model — what _COMMON symlinks to inside a brain
│ ├── AGENTS.common.md # shared agent instructions
│ ├── BRAIN.common.md # brain structure & conventions
│ ├── RULES-*.common.md # daily notes, file naming, links, sessions, evidence
│ ├── JOBS.common.md # recurring maintenance routines
│ ├── TASK_TYPES/ # how-to guides for recurring task types
│ ├── TEMPLATES/ # daily note, WIP, issue, report templates
│ └── SCRIPTS/
│ ├── brain_state.py # state machine (shared)
│ ├── home_setup.py # structure (cleanup, staging, _COMMON, wrappers)
│ ├── runtime_catalog.py # runtime config homes and skill destinations
│ ├── runtime_manager.py # runtime config (Direction A/B, conflict, skill link)
│ ├── runtime_health.py # post-apply checks for all supported runtimes
│ ├── profile_overlays.py # optional private-resource projection
│ ├── profile_secrets.py # value-free secret-reference preflight
│ ├── runtime_install.sh # low-level symlink helper (called by runtime_manager)
│ └── skill_link.sh # manual skill installer for non-default skills
└── skills/
├── brain/ # session lifecycle, daily notes, maintenance
│ ├── SKILL.md
│ ├── scripts/ # session_open.py, brain_check.py, find_home.py, ...
│ └── references/ # project-aware-loading, setup-and-attach, brain-maintenance, runtime-merge
└── boyscout/ # improvement-spotting + backlog management
├── SKILL.md
├── scripts/ # backlog.py, doctor.py, fix-ceremony.sh
└── references/ # finding-schema, detection guides, ticket backends, deep-mode, ...

Files under model/ keep the .common.md naming convention because they live inside a brain (via _COMMON) and must stay link-safe for notes apps. skills/ and the repo root use normal names.

Tests

The stdlib-only test suite runs entirely against temporary brains, homes, and Git repositories:

python3 -m unittest discover -s tests -v

CI executes the same suite on macOS and Linux. The profile integration test uses an isolated temporary HOME and verifies dry-run safety, conflict quarantine, and double-apply idempotence.

See tests/README.md for the covered contracts, individual-test commands, and fixture rules.

Local and CI gates

The canonical local gate is the todo19 QA-manifest alias complete-local-gate, executed only through tests/support/evidence_cli.py run-todo. It runs the current unittest suite, the immutable 113-ID baseline replay, Python compilation, shell syntax checks, committed diff whitespace checks, worktree scope/whitespace checks, the strict operating-model checker, and a zero-__pycache__ assertion.

GitHub Actions mirrors the strict local gate on ubuntu-latest and macos-latest. The workflow checks out full history (fetch-depth: 0), resolves MODEL_BASE from a valid pull-request base, push base, pinned immutable baseline, or root-commit fallback, proves the selected commit object, then runs committed-range gates before the suite and worktree gates after compile/shell checks. The workflow is a contract map only; private-brain migration remains explicit user work and is not automatic.

License

TBD.

About

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

agent-brain

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

agent-brain is a personal operating model for AI coding agents (Claude Code, OpenCode, Codex, Antigravity CLI). It gives you:

  • A second-brain knowledge structure (journal, WIP, memory, tasks) that the model builds on top of any folder of notes — Obsidian is one option, not a requirement.
  • Version-controlled runtime config & memory: your CLAUDE.md / AGENTS.md, memory, and runtime settings live in a git-tracked brain and are symlinked into each runtime (~/.claude, ~/.config/opencode, …), so your agent configuration and memory travel with you across machines.
  • A session lifecycle (daily notes, session notes, consolidation) driven by the brain skill.
  • An optional boyscout skill: spot improvement opportunities while you work, then route them to an explicit remediation workflow or backlog.

Prerequisites

  • Python 3.x (stdlib only — no pip dependencies)
  • git on PATH
  • At least one supported agent runtime installed:
    • Claude Code~/.claude/
    • OpenCode~/.config/opencode/
    • Shared agents dir → ~/.agents/
    • Codex CLI → ~/.codex/ (AGENTS.md and config.toml are persisted under the private brain's _AGENTS/CODEX/; the brain skill is installed at ~/.agents/skills/brain)
    • Antigravity CLI → ~/.gemini/antigravity-cli/ (skill-only integration)

Install

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh | bash

This clones agent-brain to ~/.local/share/agent-brain and runs the orchestrator, which will ask for your brain path (an Obsidian vault, a notes folder, or a new empty dir). It dry-runs by default. After reviewing the plan, use the exact public apply command printed at the end; it preserves the selected brain, runtime filter, and symlink policy:

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh \
| bash -s -- --brain /path/to/brain --apply

If _COMMON already exists

If your brain already has a _COMMON symlink pointing to a different model (e.g. a previous setup), the dry-run reports the current entry and desired symlink separately, including the raw target of a broken link. It also checks every template symlink managed by home_setup and reports stale targets. On --apply, the installer preserves the existing _COMMON entry as _COMMON.backup-<ts>, repoints _COMMON to agent-brain, and relinks stale managed templates through the new _COMMON. Regular template files remain untouched. The Git snapshot created before installation provides an additional rollback anchor.

Flags

FlagPurpose
--brain <path>Brain root path (skips interactive prompt)
--applyExecute (default: dry-run)
--updategit pull --ff-only the repo before wiring
--runtime claude,opencode,agents,codex,antigravityRestrict to a comma-separated runtime subset (default: all detected)
--symlink-policy copy|keepIngest top-level symlink content, or leave eligible non-canonical links at the brain root

How it works

The installer is a thin orchestrator that delegates to two layers:

  1. brain_state — state machine (virginattachedinitialmaintenance). Determines what flow to run based on the brain's current state.
  2. home_setup — structure: pre-cleanup, staging (for virgin brains), _COMMON symlink, wrapper files, templates.
  3. runtime_manager — all runtime config: detects each runtime, ingests local config into the brain (Direction A), implants brain config into local (Direction B), handles conflicts, links skills.
  4. runtime_health — read-only post-apply validation for every selected runtime, using the same mapping matrix as runtime_manager.

Runtime policy and private configuration belong to the private brain, not this public repository. When a brain contains _AGENTS/SHARED/memory/, Codex receives a stable pointer at ~/.agents/brain-memory; the bundled query tool ranks a small number of indexed notes on demand. Codex's own generated ~/.codex/memories/ directory remains local and separate.

Environment profiles

Environment profiles provide a runtime-neutral contract for selecting issue trackers, repositories, project conventions, and optional private resources without embedding those values in the public core. Profiles live in the private brain under _AGENTS/SHARED/profiles/; global runtime symlinks remain stable when profiles change.

See docs/runtime-profiles.md for the versioned schema, selection algorithm, precedence, safety rules, and sanitized examples. model/SCRIPTS/runtime_health.py loads and validates these files when they exist in a brain. Use --profile <id> for explicit selection or --cwd <path> to exercise project-rule selection. MCP/API availability is delegated to the active runtime adapter; the read-only check never treats a configured provider name as proof of live access.

Skills can call skills/brain/scripts/profile_context.py to resolve generic capabilities into sanitized provider context. --live checks the Codex MCP registry/auth boundary, while the caller can pass exact --available-tool names plus --tool-catalog-complete to enforce active exposure. An omitted or incomplete catalog remains unverified. Claude live discovery is refused because its official registry command may rewrite runtime settings.

Runtime adapters can project standalone private profile resources with model/SCRIPTS/profile_overlays.py. The adapter supplies explicit roots for each selected resource kind; the dry-run-first projector links brain-owned sources, quarantines conflicts, and is safe to apply repeatedly without rewriting runtime configuration.

model/SCRIPTS/profile_secrets.py checks referenced secret names without returning their values. Environment presence, metadata-only macOS keychain lookup, and sanitized runtime-native catalogs share the same fail-closed status contract.

Git is used as rollback anchor: a local snapshot commit or annotated tag is created before any mutation. Snapshot messages are deterministic and snapshot signing is disabled so unattended bootstrap runs never open an editor or a GPG prompt. Nothing is pushed automatically.

Skills

Two skills ship with agent-brain, but only the operating skill is installed automatically:

SkillCommandInstallationPurpose
brain/brain (Codex: $brain)AutomaticConnect to the brain, manage session lifecycle, daily notes, and standardization
boyscout/boyscout (Codex: $boyscout)Opt-inSpot improvement opportunities and route them to an explicit remediation workflow or backlog

Skills live outside the brain and are symlinked to the repo. Codex and OpenCode share ~/.agents/skills/; Claude uses ~/.claude/skills/; Antigravity CLI uses ~/.gemini/antigravity-cli/skills/. The legacy Gemini CLI path is not managed. Skill files use normal names without the .common.md suffix.

The brain skill's session-open apply is idempotent: it creates or updates one session note, upserts exactly one daily recovery entry keyed by the full session ID, preserves a manually edited summary, and checks the resulting session/daily state. Active WIP notes can be checked against the WIP/WIP.md dashboard with the bundled read-only brain_check.py tool.

Install boyscout for Codex only when wanted. Review the dry-run first:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents --apply

The same installer accepts a repo-owned skill directory and can link it into every detected runtime:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold --apply

Repository layout

agent-brain/
├── bootstrap-zero.sh # curl entry point (clones repo, dispatches to orchestrator)
├── docs/ # public architecture and versioned profile schemas
├── examples/profiles/ # sanitized environment-profile examples
├── model/ # the operating model — what _COMMON symlinks to inside a brain
│ ├── AGENTS.common.md # shared agent instructions
│ ├── BRAIN.common.md # brain structure & conventions
│ ├── RULES-*.common.md # daily notes, file naming, links, sessions, evidence
│ ├── JOBS.common.md # recurring maintenance routines
│ ├── TASK_TYPES/ # how-to guides for recurring task types
│ ├── TEMPLATES/ # daily note, WIP, issue, report templates
│ └── SCRIPTS/
│ ├── brain_state.py # state machine (shared)
│ ├── home_setup.py # structure (cleanup, staging, _COMMON, wrappers)
│ ├── runtime_catalog.py # runtime config homes and skill destinations
│ ├── runtime_manager.py # runtime config (Direction A/B, conflict, skill link)
│ ├── runtime_health.py # post-apply checks for all supported runtimes
│ ├── profile_overlays.py # optional private-resource projection
│ ├── profile_secrets.py # value-free secret-reference preflight
│ ├── runtime_install.sh # low-level symlink helper (called by runtime_manager)
│ └── skill_link.sh # manual skill installer for non-default skills
└── skills/
├── brain/ # session lifecycle, daily notes, maintenance
│ ├── SKILL.md
│ ├── scripts/ # session_open.py, brain_check.py, find_home.py, ...
│ └── references/ # project-aware-loading, setup-and-attach, brain-maintenance, runtime-merge
└── boyscout/ # improvement-spotting + backlog management
├── SKILL.md
├── scripts/ # backlog.py, doctor.py, fix-ceremony.sh
└── references/ # finding-schema, detection guides, ticket backends, deep-mode, ...

Files under model/ keep the .common.md naming convention because they live inside a brain (via _COMMON) and must stay link-safe for notes apps. skills/ and the repo root use normal names.

Tests

The stdlib-only test suite runs entirely against temporary brains, homes, and Git repositories:

python3 -m unittest discover -s tests -v

CI executes the same suite on macOS and Linux. The profile integration test uses an isolated temporary HOME and verifies dry-run safety, conflict quarantine, and double-apply idempotence.

See tests/README.md for the covered contracts, individual-test commands, and fixture rules.

Local and CI gates

The canonical local gate is the todo19 QA-manifest alias complete-local-gate, executed only through tests/support/evidence_cli.py run-todo. It runs the current unittest suite, the immutable 113-ID baseline replay, Python compilation, shell syntax checks, committed diff whitespace checks, worktree scope/whitespace checks, the strict operating-model checker, and a zero-__pycache__ assertion.

GitHub Actions mirrors the strict local gate on ubuntu-latest and macos-latest. The workflow checks out full history (fetch-depth: 0), resolves MODEL_BASE from a valid pull-request base, push base, pinned immutable baseline, or root-commit fallback, proves the selected commit object, then runs committed-range gates before the suite and worktree gates after compile/shell checks. The workflow is a contract map only; private-brain migration remains explicit user work and is not automatic.

License

TBD.

About

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

agent-brain

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

agent-brain is a personal operating model for AI coding agents (Claude Code, OpenCode, Codex, Antigravity CLI). It gives you:

  • A second-brain knowledge structure (journal, WIP, memory, tasks) that the model builds on top of any folder of notes — Obsidian is one option, not a requirement.
  • Version-controlled runtime config & memory: your CLAUDE.md / AGENTS.md, memory, and runtime settings live in a git-tracked brain and are symlinked into each runtime (~/.claude, ~/.config/opencode, …), so your agent configuration and memory travel with you across machines.
  • A session lifecycle (daily notes, session notes, consolidation) driven by the brain skill.
  • An optional boyscout skill: spot improvement opportunities while you work, then route them to an explicit remediation workflow or backlog.

Prerequisites

  • Python 3.x (stdlib only — no pip dependencies)
  • git on PATH
  • At least one supported agent runtime installed:
    • Claude Code~/.claude/
    • OpenCode~/.config/opencode/
    • Shared agents dir → ~/.agents/
    • Codex CLI → ~/.codex/ (AGENTS.md and config.toml are persisted under the private brain's _AGENTS/CODEX/; the brain skill is installed at ~/.agents/skills/brain)
    • Antigravity CLI → ~/.gemini/antigravity-cli/ (skill-only integration)

Install

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh | bash

This clones agent-brain to ~/.local/share/agent-brain and runs the orchestrator, which will ask for your brain path (an Obsidian vault, a notes folder, or a new empty dir). It dry-runs by default. After reviewing the plan, use the exact public apply command printed at the end; it preserves the selected brain, runtime filter, and symlink policy:

curl -fsSL https://raw.githubusercontent.com/juanyque/agent-brain/main/bootstrap-zero.sh \
| bash -s -- --brain /path/to/brain --apply

If _COMMON already exists

If your brain already has a _COMMON symlink pointing to a different model (e.g. a previous setup), the dry-run reports the current entry and desired symlink separately, including the raw target of a broken link. It also checks every template symlink managed by home_setup and reports stale targets. On --apply, the installer preserves the existing _COMMON entry as _COMMON.backup-<ts>, repoints _COMMON to agent-brain, and relinks stale managed templates through the new _COMMON. Regular template files remain untouched. The Git snapshot created before installation provides an additional rollback anchor.

Flags

FlagPurpose
--brain <path>Brain root path (skips interactive prompt)
--applyExecute (default: dry-run)
--updategit pull --ff-only the repo before wiring
--runtime claude,opencode,agents,codex,antigravityRestrict to a comma-separated runtime subset (default: all detected)
--symlink-policy copy|keepIngest top-level symlink content, or leave eligible non-canonical links at the brain root

How it works

The installer is a thin orchestrator that delegates to two layers:

  1. brain_state — state machine (virginattachedinitialmaintenance). Determines what flow to run based on the brain's current state.
  2. home_setup — structure: pre-cleanup, staging (for virgin brains), _COMMON symlink, wrapper files, templates.
  3. runtime_manager — all runtime config: detects each runtime, ingests local config into the brain (Direction A), implants brain config into local (Direction B), handles conflicts, links skills.
  4. runtime_health — read-only post-apply validation for every selected runtime, using the same mapping matrix as runtime_manager.

Runtime policy and private configuration belong to the private brain, not this public repository. When a brain contains _AGENTS/SHARED/memory/, Codex receives a stable pointer at ~/.agents/brain-memory; the bundled query tool ranks a small number of indexed notes on demand. Codex's own generated ~/.codex/memories/ directory remains local and separate.

Environment profiles

Environment profiles provide a runtime-neutral contract for selecting issue trackers, repositories, project conventions, and optional private resources without embedding those values in the public core. Profiles live in the private brain under _AGENTS/SHARED/profiles/; global runtime symlinks remain stable when profiles change.

See docs/runtime-profiles.md for the versioned schema, selection algorithm, precedence, safety rules, and sanitized examples. model/SCRIPTS/runtime_health.py loads and validates these files when they exist in a brain. Use --profile <id> for explicit selection or --cwd <path> to exercise project-rule selection. MCP/API availability is delegated to the active runtime adapter; the read-only check never treats a configured provider name as proof of live access.

Skills can call skills/brain/scripts/profile_context.py to resolve generic capabilities into sanitized provider context. --live checks the Codex MCP registry/auth boundary, while the caller can pass exact --available-tool names plus --tool-catalog-complete to enforce active exposure. An omitted or incomplete catalog remains unverified. Claude live discovery is refused because its official registry command may rewrite runtime settings.

Runtime adapters can project standalone private profile resources with model/SCRIPTS/profile_overlays.py. The adapter supplies explicit roots for each selected resource kind; the dry-run-first projector links brain-owned sources, quarantines conflicts, and is safe to apply repeatedly without rewriting runtime configuration.

model/SCRIPTS/profile_secrets.py checks referenced secret names without returning their values. Environment presence, metadata-only macOS keychain lookup, and sanitized runtime-native catalogs share the same fail-closed status contract.

Git is used as rollback anchor: a local snapshot commit or annotated tag is created before any mutation. Snapshot messages are deterministic and snapshot signing is disabled so unattended bootstrap runs never open an editor or a GPG prompt. Nothing is pushed automatically.

Skills

Two skills ship with agent-brain, but only the operating skill is installed automatically:

SkillCommandInstallationPurpose
brain/brain (Codex: $brain)AutomaticConnect to the brain, manage session lifecycle, daily notes, and standardization
boyscout/boyscout (Codex: $boyscout)Opt-inSpot improvement opportunities and route them to an explicit remediation workflow or backlog

Skills live outside the brain and are symlinked to the repo. Codex and OpenCode share ~/.agents/skills/; Claude uses ~/.claude/skills/; Antigravity CLI uses ~/.gemini/antigravity-cli/skills/. The legacy Gemini CLI path is not managed. Skill files use normal names without the .common.md suffix.

The brain skill's session-open apply is idempotent: it creates or updates one session note, upserts exactly one daily recovery entry keyed by the full session ID, preserves a manually edited summary, and checks the resulting session/daily state. Active WIP notes can be checked against the WIP/WIP.md dashboard with the bundled read-only brain_check.py tool.

Install boyscout for Codex only when wanted. Review the dry-run first:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh boyscout ~/.agents --apply

The same installer accepts a repo-owned skill directory and can link it into every detected runtime:

bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold
bash ~/.local/share/agent-brain/model/SCRIPTS/skill_link.sh /path/to/project/skills/confold --apply

Repository layout

agent-brain/
├── bootstrap-zero.sh # curl entry point (clones repo, dispatches to orchestrator)
├── docs/ # public architecture and versioned profile schemas
├── examples/profiles/ # sanitized environment-profile examples
├── model/ # the operating model — what _COMMON symlinks to inside a brain
│ ├── AGENTS.common.md # shared agent instructions
│ ├── BRAIN.common.md # brain structure & conventions
│ ├── RULES-*.common.md # daily notes, file naming, links, sessions, evidence
│ ├── JOBS.common.md # recurring maintenance routines
│ ├── TASK_TYPES/ # how-to guides for recurring task types
│ ├── TEMPLATES/ # daily note, WIP, issue, report templates
│ └── SCRIPTS/
│ ├── brain_state.py # state machine (shared)
│ ├── home_setup.py # structure (cleanup, staging, _COMMON, wrappers)
│ ├── runtime_catalog.py # runtime config homes and skill destinations
│ ├── runtime_manager.py # runtime config (Direction A/B, conflict, skill link)
│ ├── runtime_health.py # post-apply checks for all supported runtimes
│ ├── profile_overlays.py # optional private-resource projection
│ ├── profile_secrets.py # value-free secret-reference preflight
│ ├── runtime_install.sh # low-level symlink helper (called by runtime_manager)
│ └── skill_link.sh # manual skill installer for non-default skills
└── skills/
├── brain/ # session lifecycle, daily notes, maintenance
│ ├── SKILL.md
│ ├── scripts/ # session_open.py, brain_check.py, find_home.py, ...
│ └── references/ # project-aware-loading, setup-and-attach, brain-maintenance, runtime-merge
└── boyscout/ # improvement-spotting + backlog management
├── SKILL.md
├── scripts/ # backlog.py, doctor.py, fix-ceremony.sh
└── references/ # finding-schema, detection guides, ticket backends, deep-mode, ...

Files under model/ keep the .common.md naming convention because they live inside a brain (via _COMMON) and must stay link-safe for notes apps. skills/ and the repo root use normal names.

Tests

The stdlib-only test suite runs entirely against temporary brains, homes, and Git repositories:

python3 -m unittest discover -s tests -v

CI executes the same suite on macOS and Linux. The profile integration test uses an isolated temporary HOME and verifies dry-run safety, conflict quarantine, and double-apply idempotence.

See tests/README.md for the covered contracts, individual-test commands, and fixture rules.

Local and CI gates

The canonical local gate is the todo19 QA-manifest alias complete-local-gate, executed only through tests/support/evidence_cli.py run-todo. It runs the current unittest suite, the immutable 113-ID baseline replay, Python compilation, shell syntax checks, committed diff whitespace checks, worktree scope/whitespace checks, the strict operating-model checker, and a zero-__pycache__ assertion.

GitHub Actions mirrors the strict local gate on ubuntu-latest and macos-latest. The workflow checks out full history (fetch-depth: 0), resolves MODEL_BASE from a valid pull-request base, push base, pinned immutable baseline, or root-commit fallback, proves the selected commit object, then runs committed-range gates before the suite and worktree gates after compile/shell checks. The workflow is a contract map only; private-brain migration remains explicit user work and is not automatic.

License

TBD.

About

Notes-agnostic second-brain operating model + multi-runtime agent config/memory versioning.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages