|
| 1 | +--- |
| 2 | +name: context-offloading |
| 3 | +description: "Use when: saving agent context for future sessions, retrieving historical context, tracking decisions across sessions, enabling cross-session memory for agents, or maintaining project memory. Triggers: 'save context', 'remember', 'memory', 'prior context', 'load history', 'session memory', 'project memory'. NOT for: ephemeral context only, single-session tasks, or when context should not persist." |
| 4 | +--- |
| 5 | + |
| 6 | +# Context Offloading |
| 7 | + |
| 8 | +Enable agents to save and retrieve context across sessions, creating persistent memory for coding agents. This skill stores decisions, session logs, and project identity in human-readable markdown files. |
| 9 | + |
| 10 | +## When to Use This Skill |
| 11 | + |
| 12 | +Use this skill when: |
| 13 | +- Saving important decisions and context for future sessions |
| 14 | +- Retrieving historical context before answering questions |
| 15 | +- Tracking architecture decisions across sessions |
| 16 | +- Enabling cross-session memory for agents |
| 17 | +- Onboarding new agents with project context |
| 18 | + |
| 19 | +Do NOT use this skill when: |
| 20 | +- Ephemeral context only |
| 21 | +- Single-session tasks |
| 22 | +- Context should not persist |
| 23 | +- Project already has memory system |
| 24 | + |
| 25 | +## Input Format |
| 26 | + |
| 27 | +```yaml |
| 28 | +context_request: |
| 29 | + action: string # "init", "write", "query", "manage" |
| 30 | + content: string # Context to save (for write) |
| 31 | + tags: array # Optional: ["decision", "architecture", "setup"] |
| 32 | + query: string # Search query (for query) |
| 33 | + context_path: string # Custom path (optional, default: .context/) |
| 34 | + session_name: string # Session identifier (optional) |
| 35 | +``` |
| 36 | +
|
| 37 | +## Output Format |
| 38 | +
|
| 39 | +```yaml |
| 40 | +context_result: |
| 41 | + status: "success" | "error" |
| 42 | + message: string |
| 43 | + written_to: string # File path if written |
| 44 | + results: array # Query results |
| 45 | + context_path: string # Where context is stored |
| 46 | + files_created: array # Files created during init |
| 47 | +``` |
| 48 | +
|
| 49 | +## Capabilities |
| 50 | +
|
| 51 | +### 1. Initialize Context Storage (5 min) |
| 52 | +
|
| 53 | +- Create `.context/` directory structure |
| 54 | +- Create `identity.md` for project purpose, stack, conventions |
| 55 | +- Create `decisions.md` for architecture decisions |
| 56 | +- Create `session-logs/` for episodic notes |
| 57 | +- Create `.gitignore` to exclude from version control |
| 58 | + |
| 59 | +### 2. Write Memory Note (5 min) |
| 60 | + |
| 61 | +- Accept context content with optional tags |
| 62 | +- Route to appropriate file (identity, decisions, session-logs) |
| 63 | +- Append with timestamp and session identifier |
| 64 | +- Handle markdown formatting |
| 65 | + |
| 66 | +### 3. Query Context (10 min) |
| 67 | + |
| 68 | +- Accept search query string |
| 69 | +- Search all context files using grep |
| 70 | +- Rank results by relevance |
| 71 | +- Return results with source file and timestamp |
| 72 | +- Highlight matching content |
| 73 | + |
| 74 | +### 4. Manage Session Logs (5 min) |
| 75 | + |
| 76 | +- Create daily session files (YYYY-MM-DD.md) |
| 77 | +- Archive old sessions |
| 78 | +- List recent sessions |
| 79 | +- Clean up based on retention policy |
| 80 | + |
| 81 | +## File Structure |
| 82 | + |
| 83 | +``` |
| 84 | +.context/ |
| 85 | +├── .gitignore # Exclude from Git |
| 86 | +├── identity.md # Project purpose, stack, conventions |
| 87 | +├── decisions.md # Architecture decisions, policies |
| 88 | +├── session-logs/ # Episodic notes |
| 89 | +│ ├── 2026-04-07.md |
| 90 | +│ └── 2026-04-08.md |
| 91 | +└── index.md # Optional: quick reference index |
| 92 | +``` |
| 93 | +
|
| 94 | +## Usage Examples |
| 95 | +
|
| 96 | +### Initialize Context Storage |
| 97 | +"Set up context storage in my project for persistent memory." |
| 98 | +
|
| 99 | +### Write a Decision |
| 100 | +"Save this decision: We chose PostgreSQL over MongoDB because of ACID compliance needs for financial data." |
| 101 | +
|
| 102 | +### Query Prior Context |
| 103 | +"What decisions were made about the database architecture?" |
| 104 | +"Find prior context about authentication implementation." |
| 105 | +
|
| 106 | +### Session Memory |
| 107 | +"Remember that we hit a bug with the payment API - the workaround was to retry with exponential backoff." |
| 108 | +
|
| 109 | +## Configuration Options |
| 110 | +
|
| 111 | +- `context_path`: Where to store context (default: `.context/`) |
| 112 | +- `retention_days`: Days to keep session logs (default: 90) |
| 113 | +- `include_gitignore`: Create .gitignore (default: true) |
| 114 | +- `auto_init`: Auto-create context on first write if missing |
| 115 | +
|
| 116 | +## Constraints |
| 117 | +
|
| 118 | +- MUST create human-readable markdown files |
| 119 | +- MUST maintain context across sessions |
| 120 | +- SHOULD support search functionality |
| 121 | +- MUST include timestamps on entries |
| 122 | +- SHOULD exclude from version control by default |
| 123 | +
|
| 124 | +## Integration Examples |
| 125 | +
|
| 126 | +- **Before answering**: Query context for relevant prior decisions |
| 127 | +- **After making decision**: Write decision to context |
| 128 | +- **On session start**: Load recent session logs for continuity |
| 129 | +- **Project onboarding**: Read identity.md for project context |
| 130 | +
|
| 131 | +## Dependencies |
| 132 | +
|
| 133 | +- Python 3.10+ |
| 134 | +- Standard library: pathlib, subprocess (grep), datetime, re |
| 135 | +- Optional: SQLite (for future FTS5 search enhancement) |
0 commit comments