agent-brain/SKILL.md
Persistent memory and digital twin brain for Antigravity sessions. Use this skill on EVERY session for: (1) loading cross-session memory at session start, (2) saving session summaries and learnings at session end, (3) syncing memory to pCloud cloud storage, (4) searching historical memory and past decisions, (5) managing per-project context. Triggers on: session start, session end signals (commit, release note, 告一段落, 收工, sync memory, save brain), memory recall requests (上次做了什麼, recall, search memory).
npx skillsauth add tai-ch0802/skills-bundle agent-brainInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Persistent file-first memory system. Every Antigravity session contributes to a growing knowledge base stored as Markdown files locally at ~/.agent-brain/ and synced to pCloud /agent-brain/.
Build a digital twin — an agent that accumulates all session knowledge, user preferences, project context, and decisions over time.
All information flowing through the agent's memory is classified into four ontological layers. Use this classification to decide where to store each piece of information.
| Layer | Code | Nature | Mutability | Lifecycle | File |
|-------|------|--------|------------|-----------|------|
| Identity | IDENTITY | Who am I working with | Rarely changes (requires repeated observation) | Permanent | USER.md |
| Knowledge | KNOWLEDGE | What I know | Accumulative, compressible | Long-term (30+ days) | MEMORY.md |
| Experience | EXPERIENCE | What I did | Immutable (append-only) | Historical record | sessions/*.md |
| State | STATE | What I'm doing right now | Freely overwritable | Current work session | STATE.md |
When new information emerges, route it through this decision tree:
New information →
├─ About the user's personal preferences/habits? → IDENTITY (USER.md)
├─ A durable technical fact useful in 30+ days? → KNOWLEDGE (MEMORY.md)
├─ Current task context (active bug, target file)? → STATE (STATE.md)
└─ None of the above, but worth recording? → EXPERIENCE (sessions/*.md)
| Layer | Write Mode | Sync Strategy | Conflict Resolution | |-------|-----------|---------------|---------------------| | Identity | Overwrite (requires multi-observation evidence) | Section merge | Keep longer version | | Knowledge | Append durable facts only | Section merge | Keep longer version | | Experience | Strict append-only | Append merge + dedup | Header fingerprint dedup | | State | Free overwrite | Never synced (ephemeral) | N/A |
~/.agent-brain/
├── .env # pCloud credentials (NEVER synced)
├── .sync-manifest.json # SHA256 manifest for incremental sync
├── MEMORY.md # Long-term persistent facts (KNOWLEDGE)
├── USER.md # User preferences & patterns (IDENTITY)
├── STATE.md # Current work session context (STATE)
├── sessions/
│ └── YYYY-MM-DD.md # Daily session logs (EXPERIENCE, append-only)
├── projects/
│ └── {project-name}.md # Per-project accumulated context
├── tmp/ # Temporary directory for conflict resolution (auto-cleaned)
└── brain.db # SQLite FTS5 index
| File | Load at Start | Purpose |
|------|:---:|---------|
| MEMORY.md | ✅ Full | Cross-session facts, decisions, learnings |
| USER.md | ✅ Full | User's coding style, tool preferences |
| STATE.md | ✅ Full | Resumable work context from last session |
| sessions/today.md | ✅ Full | Today's session summaries |
| sessions/yesterday.md | ✅ Full | Yesterday's context for continuity |
| sessions/older | ❌ On-demand | Search via grep or brain.db |
| projects/*.md | ❌ On-demand | Load when working on that project |
| brain.db | ❌ By script | SQLite FTS5 index for memory search |
| .sync-manifest.json | ❌ Internal | Tracks file SHA256 hashes for incremental sync |
Execute on every session:
Check bootstrap: If ~/.agent-brain/ does not exist, run:
bash ~/.gemini/antigravity/skills/agent-brain/scripts/bootstrap.sh
Archive stale STATE: If ~/.agent-brain/STATE.md exists:
Updated: timestampsessions/YYYY-MM-DD.md as an archived state block, then clear STATE.mdLoad core memory — read these files into context:
~/.agent-brain/MEMORY.md (full)~/.agent-brain/USER.md (full)~/.agent-brain/STATE.md (full, if exists and non-empty)~/.agent-brain/sessions/YYYY-MM-DD.md for today (if exists)~/.agent-brain/sessions/YYYY-MM-DD.md for yesterday (if exists)Load project context (optional): If the current workspace clearly maps to a project, check if ~/.agent-brain/projects/{project-name}.md exists and load it.
Proceed with the user's request, enriched by accumulated memory.
Activate memory flush when the user says or implies session ending:
save brain, sync memory, 記憶同步, 更新記憶commit, release note, 告一段落, 今天先到這, 收工, 結束, 下班, 先這樣Generate session summary and append to ~/.agent-brain/sessions/YYYY-MM-DD.md:
## Session HH:MM:SS — {context}
**Project**: [[projects/{name}]]
**Workspace**: {repo or directory path}
### Summary
{1-3 sentence summary of what was accomplished}
### Key Decisions
- {decision 1}
- {decision 2}
### Learnings
- {new knowledge gained}
### Next Steps
- [ ] {unfinished task}
Update MEMORY.md if new persistent facts emerged:
Update USER.md if new user preferences were observed:
Update STATE.md — overwrite with current work context:
Update projects/{name}.md with cross-link to today's session:
- YYYY-MM-DD: {brief description} [[sessions/YYYY-MM-DD#session-hhmmss]]
Create the file if it doesn't exist, using the format in memory-format.md.
Check MEMORY.md capacity:
⚠ MEMORY.md approaching limit (XXX/500 lines). Consider compression.projects/)Run indexer:
python3 ~/.gemini/antigravity/skills/agent-brain/scripts/index-memory.py index
Note: Session end does NOT automatically sync to pCloud. Use
/upload-brainto push changes or/sync-brainfor full bidirectional sync.
When user asks about past work, decisions, or history:
~/.agent-brain/projects/{name}.md~/.agent-brain/sessions/YYYY-MM-DD.mdgrep_search on ~/.agent-brain/python3 ~/.gemini/antigravity/skills/agent-brain/scripts/index-memory.py search "query"
api.pcloud.com (US data center)/agent-brain/~/.agent-brain/.envpcloud skill for API details if neededThe sync system uses a SHA256 manifest (.sync-manifest.json) to track which files have been synced. Only files whose content has changed since the last sync are transferred.
# Check sync status (dry-run — shows what would change, no writes)
bash ~/.gemini/antigravity/skills/agent-brain/scripts/sync.sh status
# Upload local changes to pCloud (incremental — only changed files)
bash ~/.gemini/antigravity/skills/agent-brain/scripts/sync.sh push
# Download from pCloud (incremental — only changed files)
bash ~/.gemini/antigravity/skills/agent-brain/scripts/sync.sh pull
# Bidirectional sync with conflict resolution
bash ~/.gemini/antigravity/skills/agent-brain/scripts/sync.sh sync
When both local and remote versions of a file have changed since the last sync:
~/.agent-brain/tmp/ directory is created for stagingtmp/sessions/*.md): Append-only merge — deduplicate session blocks by header fingerprintMEMORY.md, USER.md, projects/*.md): Section-level merge using ## headings as keys — both sides' unique sections are preserved, shared sections keep the longer versiontmp/ is cleaned up after mergebrain.db is rebuilt from scratch using index-memory.py rebuild — it is treated as a derived artifact and never merged directlybrain.db) is pushed to pCloudprojects/.[ARCHIVED] prefix.[[projects/name]], projects reference [[sessions/date]]..env only.Agent Brain ships with five global workflows that can be installed to ~/.agent/workflows/ during bootstrap (or manually via install-workflows.sh):
| Workflow | Slash Command | Purpose |
|----------|---------------|---------|
| save-brain | /save-brain | Flush session memory → update MEMORY/USER/STATE/projects → build index (local only) |
| upload-brain | /upload-brain | Push local changes to pCloud (one-way upload, incremental) |
| download-brain | /download-brain | Pull cloud changes to local (one-way download, incremental) |
| sync-brain | /sync-brain | Bidirectional pCloud sync with SHA-based incremental transfer and conflict resolution |
| load-brain | /load-brain | Load MEMORY.md, USER.md, STATE.md, today/yesterday sessions → load project context (local only) |
Workflows are installed automatically during bootstrap. To install or reinstall manually:
bash ~/.gemini/antigravity/skills/agent-brain/scripts/install-workflows.sh
development
Unified testing skill — TDD workflow, unit/integration patterns, E2E/Playwright strategies. Replaces tdd-workflow + testing-patterns + webapp-testing.
testing
Security-first skill vetting for AI agents. Use before installing any skill from ClawdHub, GitHub, or other sources. Checks for red flags, permission scope, and suspicious patterns.
development
Spec-Driven Development (SDD): A structured workflow (Requirement -> Analysis -> Implementation) enforcing explicit documentation before coding.
development
Methodologies for System Analysis (SA), focusing on technical architecture, data flow modeling, and API design.