instar 0.6.9 → 0.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/init.js +4 -4
- package/dist/scaffold/templates.js +6 -5
- package/package.json +1 -1
- package/skills/README.md +106 -0
- package/skills/agent-identity/SKILL.md +226 -0
- package/skills/agent-memory/SKILL.md +261 -0
- package/skills/command-guard/SKILL.md +239 -0
- package/skills/credential-leak-detector/SKILL.md +377 -0
- package/skills/instar-feedback/SKILL.md +244 -0
- package/skills/instar-identity/SKILL.md +290 -0
- package/skills/instar-scheduler/SKILL.md +259 -0
- package/skills/instar-session/SKILL.md +270 -0
- package/skills/instar-telegram/SKILL.md +259 -0
- package/skills/smart-web-fetch/SKILL.md +241 -0
package/dist/commands/init.js
CHANGED
|
@@ -496,8 +496,8 @@ This routes feedback to the Instar maintainers automatically. Valid types: \`bug
|
|
|
496
496
|
|
|
497
497
|
**Scripts** — Create shell/python scripts in \`.claude/scripts/\` for reusable capabilities.
|
|
498
498
|
|
|
499
|
-
**Skills** — Reusable behavioral capabilities in \`.claude/skills/\`. Skills are markdown files that Claude Code auto-discovers. Create a directory and
|
|
500
|
-
- Create: \`.claude/skills/my-skill/
|
|
499
|
+
**Skills** — Reusable behavioral capabilities in \`.claude/skills/\`. Skills are markdown files that Claude Code auto-discovers. Create a directory and SKILL.md file, and it becomes a slash command.
|
|
500
|
+
- Create: \`.claude/skills/my-skill/SKILL.md\`
|
|
501
501
|
- Invoke: \`/my-skill\` in any session
|
|
502
502
|
- Schedule: Reference in a job: \`{"execute": {"type": "skill", "value": "my-skill"}}\`
|
|
503
503
|
|
|
@@ -506,8 +506,8 @@ This routes feedback to the Instar maintainers automatically. Valid types: \`bug
|
|
|
506
506
|
You create your own skills. When you recognize a repeated pattern — a multi-step workflow, a structured check, a complex behavior — capture it as a skill. Skills are just markdown files that describe a process. Claude Code auto-discovers them.
|
|
507
507
|
|
|
508
508
|
**How to create a skill:**
|
|
509
|
-
1. Create: \`.claude/skills/my-skill/
|
|
510
|
-
2. Add frontmatter: \`name\`, \`description\`, \`user_invocable
|
|
509
|
+
1. Create: \`.claude/skills/my-skill/SKILL.md\`
|
|
510
|
+
2. Add frontmatter: \`name\`, \`description\`, and \`user_invocable\` nested under \`metadata:\`
|
|
511
511
|
3. Describe the behavior in clear steps
|
|
512
512
|
4. It's available as \`/my-skill\` in the next session
|
|
513
513
|
|
|
@@ -197,7 +197,7 @@ This routes feedback to the Instar maintainers automatically. Valid types: \`bug
|
|
|
197
197
|
**Scripts** — Reusable capabilities in \`.claude/scripts/\`.
|
|
198
198
|
|
|
199
199
|
**Skills** — Reusable behavioral capabilities in \`.claude/skills/\`.
|
|
200
|
-
- Create: Write a markdown file at \`.claude/skills/my-skill/
|
|
200
|
+
- Create: Write a markdown file at \`.claude/skills/my-skill/SKILL.md\`
|
|
201
201
|
- Invoke: \`/my-skill\` in any Claude Code session
|
|
202
202
|
- Schedule: Reference in a job: \`{"execute": {"type": "skill", "value": "my-skill"}}\`
|
|
203
203
|
- List all: \`ls .claude/skills/\`
|
|
@@ -213,17 +213,18 @@ Skills are markdown files that define reusable capabilities. Claude Code auto-di
|
|
|
213
213
|
|
|
214
214
|
**How to create a skill:**
|
|
215
215
|
1. Create a directory: \`.claude/skills/my-skill/\`
|
|
216
|
-
2. Write the skill file: \`.claude/skills/my-skill/
|
|
217
|
-
3. Start with frontmatter: \`name\`, \`description\` (for auto-invocation), \`user_invocable
|
|
216
|
+
2. Write the skill file: \`.claude/skills/my-skill/SKILL.md\`
|
|
217
|
+
3. Start with frontmatter: \`name\`, \`description\` (for auto-invocation), and \`user_invocable\` nested under \`metadata:\`
|
|
218
218
|
4. Describe the behavior, steps, and any grounding requirements
|
|
219
219
|
5. It's immediately available as \`/my-skill\` in the next session
|
|
220
220
|
|
|
221
|
-
**Example skill** (\`.claude/skills/reflect/
|
|
221
|
+
**Example skill** (\`.claude/skills/reflect/SKILL.md\`):
|
|
222
222
|
\`\`\`markdown
|
|
223
223
|
---
|
|
224
224
|
name: reflect
|
|
225
225
|
description: Analyze what was learned in the current session and persist insights to MEMORY.md
|
|
226
|
-
|
|
226
|
+
metadata:
|
|
227
|
+
user_invocable: "true"
|
|
227
228
|
---
|
|
228
229
|
|
|
229
230
|
# /reflect
|
package/package.json
CHANGED
package/skills/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# instar-skills
|
|
2
|
+
|
|
3
|
+
A collection of [Agent Skills](https://agentskills.io) for AI coding agents. Some work with any Claude Code project out of the box. Others unlock the full power of [Instar](https://instar.sh) — persistent autonomy infrastructure for AI agents.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## What are Agent Skills?
|
|
8
|
+
|
|
9
|
+
Agent Skills are folders containing `SKILL.md` files. Compatible agents (Claude Code, Codex, Cursor, VS Code, Amp, goose, and 30+ others) discover and load these files automatically, gaining new capabilities on demand.
|
|
10
|
+
|
|
11
|
+
The [Agent Skills open standard](https://agentskills.io/specification) works across all major AI coding tools.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Standalone Skills (No Dependencies)
|
|
16
|
+
|
|
17
|
+
These work with **any Claude Code project** — no Instar required. Drop them in and get immediate value.
|
|
18
|
+
|
|
19
|
+
### [agent-identity](./agent-identity/SKILL.md)
|
|
20
|
+
|
|
21
|
+
Set up persistent agent identity files (AGENT.md, USER.md, MEMORY.md) that survive across sessions. Teaches the agent who it is and how to orient after context compaction.
|
|
22
|
+
|
|
23
|
+
### [agent-memory](./agent-memory/SKILL.md)
|
|
24
|
+
|
|
25
|
+
Cross-session memory patterns using MEMORY.md. How to organize, maintain, and leverage accumulated knowledge. The agent remembers what it learned last week.
|
|
26
|
+
|
|
27
|
+
### [smart-web-fetch](./smart-web-fetch/SKILL.md)
|
|
28
|
+
|
|
29
|
+
Token-efficient web fetching. Checks llms.txt first, then Cloudflare markdown, then falls back to HTML. 60-80% fewer tokens on documentation and blog pages. Installs a single Python script.
|
|
30
|
+
|
|
31
|
+
### [command-guard](./command-guard/SKILL.md)
|
|
32
|
+
|
|
33
|
+
Safety hooks that block destructive commands (`rm -rf`, force push, database drops) before they execute. Installs a Claude Code PreToolUse hook — structural safety, not behavioral.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Instar-Powered Skills
|
|
38
|
+
|
|
39
|
+
These unlock capabilities that require a persistent server — job scheduling, session management, Telegram messaging. **If Instar isn't installed, the skill guides the user through setup.** No hard walls.
|
|
40
|
+
|
|
41
|
+
### [instar-scheduler](./instar-scheduler/SKILL.md)
|
|
42
|
+
|
|
43
|
+
Schedule recurring agent tasks on cron. Each job spawns a real Claude Code session with full tool access. Priority levels, model tiers, quota awareness.
|
|
44
|
+
|
|
45
|
+
### [instar-session](./instar-session/SKILL.md)
|
|
46
|
+
|
|
47
|
+
Spawn, monitor, and communicate with persistent Claude Code sessions running in tmux. Background tasks, parallel work, long-running operations.
|
|
48
|
+
|
|
49
|
+
### [instar-telegram](./instar-telegram/SKILL.md)
|
|
50
|
+
|
|
51
|
+
Two-way Telegram messaging. Each job gets its own forum topic. Your Telegram group becomes a living dashboard. Message your agent from your phone, anywhere.
|
|
52
|
+
|
|
53
|
+
### [instar-identity](./instar-identity/SKILL.md)
|
|
54
|
+
|
|
55
|
+
The full identity infrastructure — hooks that re-inject identity on every session start, after compaction, and before external messaging. Structure over willpower.
|
|
56
|
+
|
|
57
|
+
### [instar-feedback](./instar-feedback/SKILL.md)
|
|
58
|
+
|
|
59
|
+
Structured feedback that flows agent-to-agent. Your agent reports issues directly to the AI that maintains Instar. One agent's growing pain becomes every agent's growth.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Installing Skills
|
|
64
|
+
|
|
65
|
+
### Copy into your project
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Copy individual skills
|
|
69
|
+
cp -r /path/to/instar/skills/smart-web-fetch .claude/skills/
|
|
70
|
+
cp -r /path/to/instar/skills/agent-identity .claude/skills/
|
|
71
|
+
|
|
72
|
+
# Or copy all standalone skills
|
|
73
|
+
for skill in agent-identity agent-memory smart-web-fetch command-guard; do
|
|
74
|
+
cp -r /path/to/instar/skills/$skill .claude/skills/
|
|
75
|
+
done
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Skills in `.claude/skills/` are auto-discovered by Claude Code as slash commands.
|
|
79
|
+
|
|
80
|
+
### Symlink (same machine)
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
ln -s /path/to/instar/skills/smart-web-fetch .claude/skills/smart-web-fetch
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## How the Funnel Works
|
|
89
|
+
|
|
90
|
+
The standalone skills provide real value with zero friction. When a developer wants more — "run this on a schedule", "message me when it's done", "keep working while I sleep" — the Instar-powered skills are right there, and they handle the onboarding:
|
|
91
|
+
|
|
92
|
+
1. Developer installs `agent-identity` — works immediately, loves it
|
|
93
|
+
2. Developer wants identity to survive restarts automatically — finds `instar-identity`
|
|
94
|
+
3. Skill detects Instar isn't installed — explains the value, offers `npx instar`
|
|
95
|
+
4. Developer installs Instar — 2-minute setup, immediate upgrade
|
|
96
|
+
5. All Instar skills now work. Agent has a persistent body.
|
|
97
|
+
|
|
98
|
+
No walls. No friction. Value at every step.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT — same as [Instar](https://instar.sh).
|
|
105
|
+
|
|
106
|
+
[instar.sh](https://instar.sh) · [npm](https://www.npmjs.com/package/instar) · [GitHub](https://github.com/SageMindAI/instar)
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-identity
|
|
3
|
+
description: Set up persistent agent identity files (AGENT.md, USER.md, MEMORY.md) and teach the agent to read them at every session start. Works in any Claude Code project — no external dependencies required. Trigger words: who am I, identity, remember me, agent name, my principles, who are you, what are my values.
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: sagemindai
|
|
7
|
+
version: "1.0"
|
|
8
|
+
homepage: https://instar.sh
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# agent-identity — Persistent Agent Identity for Claude Code
|
|
12
|
+
|
|
13
|
+
Without identity infrastructure, every Claude Code session starts from zero. The agent has no name, no remembered preferences, no sense of who it works with or what it has learned. Context compaction erases everything mid-session. This skill fixes that — no external tools required.
|
|
14
|
+
|
|
15
|
+
## What This Skill Creates
|
|
16
|
+
|
|
17
|
+
Three files at `.claude/identity/`:
|
|
18
|
+
|
|
19
|
+
- **AGENT.md** — Who the agent is: name, role, personality, principles
|
|
20
|
+
- **USER.md** — Who the agent works with: preferences, context, communication style
|
|
21
|
+
- **MEMORY.md** — What the agent has learned across sessions
|
|
22
|
+
|
|
23
|
+
And a reference in **CLAUDE.md** that teaches the agent to read them at every session start.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Step 1: Create the Identity Directory
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
mkdir -p .claude/identity
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Step 2: Create AGENT.md
|
|
36
|
+
|
|
37
|
+
Replace the placeholder values with your actual agent name and role.
|
|
38
|
+
|
|
39
|
+
```markdown
|
|
40
|
+
# [Agent Name]
|
|
41
|
+
|
|
42
|
+
## Who I Am
|
|
43
|
+
|
|
44
|
+
I am [Agent Name], the autonomous agent for [Project Name]. I handle [main
|
|
45
|
+
responsibilities] and work alongside my collaborator.
|
|
46
|
+
|
|
47
|
+
## Role
|
|
48
|
+
|
|
49
|
+
[One sentence on what this agent does.]
|
|
50
|
+
|
|
51
|
+
## Personality
|
|
52
|
+
|
|
53
|
+
[Describe how the agent should behave: tone, directness, initiative level.]
|
|
54
|
+
|
|
55
|
+
## My Principles
|
|
56
|
+
|
|
57
|
+
1. Build, don't describe — implement, don't list options.
|
|
58
|
+
2. Follow through to done — code is done when it's running, not when it compiles.
|
|
59
|
+
3. Write to MEMORY.md — when I learn something worth keeping, I write it down.
|
|
60
|
+
4. Be honest about limits — fabricating certainty is worse than admitting uncertainty.
|
|
61
|
+
5. Act, don't ask — only pause for destructive or genuinely ambiguous decisions.
|
|
62
|
+
|
|
63
|
+
## Who I Work With
|
|
64
|
+
|
|
65
|
+
My primary collaborator is [User Name]. They prefer [communication style].
|
|
66
|
+
They value [what they value]. See USER.md for full context.
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Save to `.claude/identity/AGENT.md`.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Step 3: Create USER.md
|
|
74
|
+
|
|
75
|
+
```markdown
|
|
76
|
+
# [User Name]
|
|
77
|
+
|
|
78
|
+
## About
|
|
79
|
+
|
|
80
|
+
[Brief description — role, relationship to this project.]
|
|
81
|
+
|
|
82
|
+
## Communication Preferences
|
|
83
|
+
|
|
84
|
+
- [Preference 1: e.g., "Direct answers over long explanations"]
|
|
85
|
+
- [Preference 2: e.g., "Proactive updates, not requests for permission"]
|
|
86
|
+
- [Preference 3: e.g., "Summaries via Telegram, not just files"]
|
|
87
|
+
|
|
88
|
+
## Working Style
|
|
89
|
+
|
|
90
|
+
[How they like to work, what they find frustrating, what they value.]
|
|
91
|
+
|
|
92
|
+
## Notes
|
|
93
|
+
|
|
94
|
+
Update this file as you learn more about [User Name]'s preferences.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Save to `.claude/identity/USER.md`.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Step 4: Create MEMORY.md
|
|
102
|
+
|
|
103
|
+
```markdown
|
|
104
|
+
# [Agent Name] Memory
|
|
105
|
+
|
|
106
|
+
> This file persists across sessions. Write here when you learn something
|
|
107
|
+
> worth remembering. Remove entries that become outdated.
|
|
108
|
+
|
|
109
|
+
## Project Patterns
|
|
110
|
+
|
|
111
|
+
- [Key build/test/deploy commands discovered]
|
|
112
|
+
- [Gotchas found during development]
|
|
113
|
+
|
|
114
|
+
## Tools & Scripts
|
|
115
|
+
|
|
116
|
+
- [Any scripts built, with their location and purpose]
|
|
117
|
+
|
|
118
|
+
## Lessons Learned
|
|
119
|
+
|
|
120
|
+
- [Date]: [What happened, what was learned, what to do differently]
|
|
121
|
+
|
|
122
|
+
## User Preferences (Discovered)
|
|
123
|
+
|
|
124
|
+
- [Preferences observed through interaction, not assumed]
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Save to `.claude/identity/MEMORY.md`.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Step 5: Wire Into CLAUDE.md
|
|
132
|
+
|
|
133
|
+
Add this block to the top of your project's `CLAUDE.md` (create it if it doesn't exist):
|
|
134
|
+
|
|
135
|
+
```markdown
|
|
136
|
+
## Agent Identity
|
|
137
|
+
|
|
138
|
+
At the start of every session, read these files before doing any work:
|
|
139
|
+
|
|
140
|
+
- `.claude/identity/AGENT.md` — Who I am, my principles, my role
|
|
141
|
+
- `.claude/identity/USER.md` — Who I work with and how they prefer to work
|
|
142
|
+
- `.claude/identity/MEMORY.md` — What I've learned across previous sessions
|
|
143
|
+
|
|
144
|
+
After reading, compose an internal orientation:
|
|
145
|
+
"I am [name]. My collaborator is [user]. My current focus is [infer from context].
|
|
146
|
+
Key memory: [most relevant entry from MEMORY.md]."
|
|
147
|
+
|
|
148
|
+
After context compaction (when the context window compresses), re-read all
|
|
149
|
+
three files immediately. Identity is in the files, not in context.
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Step 6: Reading at Session Start
|
|
155
|
+
|
|
156
|
+
When beginning a new session, run:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
cat .claude/identity/AGENT.md
|
|
160
|
+
cat .claude/identity/USER.md
|
|
161
|
+
cat .claude/identity/MEMORY.md
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
This takes seconds and ensures every session starts grounded rather than blank.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Updating Memory Over Time
|
|
169
|
+
|
|
170
|
+
Write to MEMORY.md when you:
|
|
171
|
+
- Discover a project pattern that will save time next session
|
|
172
|
+
- Learn something about the user's preferences through interaction
|
|
173
|
+
- Make a mistake worth not repeating
|
|
174
|
+
- Build a new script or capability
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Append a new entry
|
|
178
|
+
cat >> .claude/identity/MEMORY.md << 'EOF'
|
|
179
|
+
|
|
180
|
+
## New Pattern (YYYY-MM-DD)
|
|
181
|
+
|
|
182
|
+
- [What was learned and why it matters]
|
|
183
|
+
EOF
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Keep entries concise. If MEMORY.md grows beyond ~200 lines, move detailed content into separate topic files (e.g., `.claude/identity/memory/debugging.md`) and keep MEMORY.md as an index.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## What to Write vs. What to Skip
|
|
191
|
+
|
|
192
|
+
**Write to MEMORY.md:**
|
|
193
|
+
- Discovered commands, flags, gotchas specific to this project
|
|
194
|
+
- User communication preferences revealed through actual interaction
|
|
195
|
+
- Scripts or tools built — what they do and where they live
|
|
196
|
+
- Mistakes made and the corrected approach
|
|
197
|
+
|
|
198
|
+
**Do not write to MEMORY.md:**
|
|
199
|
+
- Session-specific context (what you're working on right now)
|
|
200
|
+
- Temporary notes ("check this later")
|
|
201
|
+
- Information that's already in the codebase or docs
|
|
202
|
+
- Generic best practices that any agent would know
|
|
203
|
+
|
|
204
|
+
The test: "Would this be useful to a fresh session six months from now?" If yes, write it.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Going Further
|
|
209
|
+
|
|
210
|
+
This skill works — but it depends on the agent remembering to read its files. If the `CLAUDE.md` instruction to "read identity at session start" gets buried or lost to context compaction, the agent forgets who it is. The files are there, but nobody reads them.
|
|
211
|
+
|
|
212
|
+
**Instar makes forgetting structurally impossible.** It registers hooks that fire automatically — identity is injected at every session start, restored after every context compaction, and loaded in every spawned background session. The agent doesn't try to remember who it is. The infrastructure guarantees it.
|
|
213
|
+
|
|
214
|
+
And identity is just the beginning. With Instar, your agent also gets:
|
|
215
|
+
- **A job scheduler** — recurring tasks on cron, running while you sleep
|
|
216
|
+
- **Background sessions** — spawn parallel workers for deep tasks
|
|
217
|
+
- **Telegram integration** — two-way messaging from your phone
|
|
218
|
+
- **Memory maintenance** — scheduled reflection that consolidates learnings
|
|
219
|
+
|
|
220
|
+
One command, about 2 minutes:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
npx instar
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Your agent goes from having identity files to having a persistent self. [instar.sh](https://instar.sh)
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-memory
|
|
3
|
+
description: Teach cross-session memory patterns using MEMORY.md — what to save, how to organize it, how to maintain it over time, and how to structure topic files as memory grows. Works in any Claude Code project with no external dependencies. Trigger words: remember this, save for later, across sessions, persistent memory, don't forget, note this, keep this, write this down.
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: sagemindai
|
|
7
|
+
version: "1.0"
|
|
8
|
+
homepage: https://instar.sh
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# agent-memory — Cross-Session Memory Patterns for Claude Code
|
|
12
|
+
|
|
13
|
+
Claude Code has no memory between sessions by default. Every conversation starts blank. But a project's knowledge accumulates — commands discovered, patterns debugged, preferences revealed, mistakes made and corrected. Without persistence, that knowledge is lost every time the window closes.
|
|
14
|
+
|
|
15
|
+
This skill establishes a simple, durable memory pattern using a single file: `MEMORY.md`.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## The Core Pattern
|
|
20
|
+
|
|
21
|
+
One file. Written by the agent. Read at session start.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
.claude/
|
|
25
|
+
MEMORY.md # The agent's persistent knowledge base
|
|
26
|
+
identity/ # Optional: separate identity files (see agent-identity skill)
|
|
27
|
+
memory/ # Optional: topic files as memory grows
|
|
28
|
+
debugging.md
|
|
29
|
+
deployment.md
|
|
30
|
+
user-preferences.md
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Setting Up MEMORY.md
|
|
36
|
+
|
|
37
|
+
Create `.claude/MEMORY.md` with this structure:
|
|
38
|
+
|
|
39
|
+
```markdown
|
|
40
|
+
# [Project/Agent] Memory
|
|
41
|
+
|
|
42
|
+
> This file persists across sessions. Write here when you learn something
|
|
43
|
+
> worth remembering. Remove entries that become outdated. Keep it useful,
|
|
44
|
+
> not comprehensive.
|
|
45
|
+
|
|
46
|
+
## Project Patterns
|
|
47
|
+
|
|
48
|
+
[Commands, scripts, conventions specific to this project]
|
|
49
|
+
|
|
50
|
+
## Tools & Scripts
|
|
51
|
+
|
|
52
|
+
[Purpose-built scripts and how to invoke them]
|
|
53
|
+
|
|
54
|
+
## Lessons Learned
|
|
55
|
+
|
|
56
|
+
[Mistakes made and corrections. Dated entries.]
|
|
57
|
+
|
|
58
|
+
## User Preferences
|
|
59
|
+
|
|
60
|
+
[Communication style, workflow preferences, discovered through interaction]
|
|
61
|
+
|
|
62
|
+
## Open Questions
|
|
63
|
+
|
|
64
|
+
[Unresolved things to investigate — remove when resolved]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then add this to your `CLAUDE.md`:
|
|
68
|
+
|
|
69
|
+
```markdown
|
|
70
|
+
## Memory
|
|
71
|
+
|
|
72
|
+
At the start of every session, read `.claude/MEMORY.md` before doing any work.
|
|
73
|
+
After context compaction, re-read it immediately.
|
|
74
|
+
|
|
75
|
+
When you learn something worth keeping, write it to MEMORY.md before the session ends.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## What to Write vs. What to Skip
|
|
81
|
+
|
|
82
|
+
The most common mistake: writing everything, making the file so long it stops being read carefully.
|
|
83
|
+
|
|
84
|
+
**Write to MEMORY.md:**
|
|
85
|
+
|
|
86
|
+
- Project-specific commands, especially non-obvious ones
|
|
87
|
+
- "Run `npm run build:prod` not `npm run build` — the latter overwrites staging"
|
|
88
|
+
- Scripts you built and their locations
|
|
89
|
+
- ".claude/scripts/check-email.py — reads Gmail unread, takes --limit flag"
|
|
90
|
+
- Mistakes made once that shouldn't happen again
|
|
91
|
+
- "2025-03-12: Pushed to main while on detached HEAD. Always verify branch before committing."
|
|
92
|
+
- User preferences discovered through interaction, not assumed
|
|
93
|
+
- "Prefers Telegram summaries over file links"
|
|
94
|
+
- Patterns that took time to figure out
|
|
95
|
+
- "Prisma requires explicit `include` for relations — no auto-eager-loading"
|
|
96
|
+
|
|
97
|
+
**Do not write to MEMORY.md:**
|
|
98
|
+
|
|
99
|
+
- Session-specific context ("currently working on auth PR")
|
|
100
|
+
- Information available in the codebase or docs
|
|
101
|
+
- Reminders for things you'll do this session (use a TODO comment)
|
|
102
|
+
- Generic programming knowledge any agent would have
|
|
103
|
+
- Things that will be outdated next week
|
|
104
|
+
|
|
105
|
+
The test: *Would a fresh session six months from now benefit from this?* If no, skip it.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Organizing Growing Memory
|
|
110
|
+
|
|
111
|
+
MEMORY.md works well up to ~150-200 lines. Beyond that, introduce topic files:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
mkdir -p .claude/memory
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Move detailed sections to topic files and keep MEMORY.md as an index:
|
|
118
|
+
|
|
119
|
+
```markdown
|
|
120
|
+
# Memory Index
|
|
121
|
+
|
|
122
|
+
## Quick Reference
|
|
123
|
+
|
|
124
|
+
- Build: `npm run build:prod`
|
|
125
|
+
- Deploy: `.claude/scripts/deploy.sh --env production`
|
|
126
|
+
- DB migrate: `npm run db:migrate` (always after schema changes)
|
|
127
|
+
|
|
128
|
+
## Topic Files
|
|
129
|
+
|
|
130
|
+
- Debugging patterns: `.claude/memory/debugging.md`
|
|
131
|
+
- Deployment notes: `.claude/memory/deployment.md`
|
|
132
|
+
- User preferences: `.claude/memory/user-preferences.md`
|
|
133
|
+
- API integrations: `.claude/memory/apis.md`
|
|
134
|
+
|
|
135
|
+
## Recent Lessons
|
|
136
|
+
|
|
137
|
+
[Last 3-5 lessons only — older ones move to topic files]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Reference topic files in `CLAUDE.md`:
|
|
141
|
+
|
|
142
|
+
```markdown
|
|
143
|
+
## Memory
|
|
144
|
+
|
|
145
|
+
Read at session start:
|
|
146
|
+
- `.claude/MEMORY.md` — always
|
|
147
|
+
- `.claude/memory/debugging.md` — when debugging
|
|
148
|
+
- `.claude/memory/deployment.md` — when deploying
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Writing Memory During a Session
|
|
154
|
+
|
|
155
|
+
Don't wait until the session ends. Write memory entries when you learn something:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Append an entry immediately
|
|
159
|
+
cat >> .claude/MEMORY.md << 'EOF'
|
|
160
|
+
|
|
161
|
+
## New Discovery (2025-03-20)
|
|
162
|
+
|
|
163
|
+
- The Redis connection string requires `?family=6` for IPv6 — without it,
|
|
164
|
+
connections timeout silently on this server.
|
|
165
|
+
EOF
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
When adding a dated lesson:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
DATE=$(date +%Y-%m-%d)
|
|
172
|
+
cat >> .claude/MEMORY.md << EOF
|
|
173
|
+
|
|
174
|
+
## Lesson (${DATE})
|
|
175
|
+
|
|
176
|
+
- [What happened, what was wrong, what the correct approach is]
|
|
177
|
+
EOF
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Maintaining Memory Over Time
|
|
183
|
+
|
|
184
|
+
Memory files need occasional pruning — entries go stale, contexts change, projects evolve.
|
|
185
|
+
|
|
186
|
+
**Review MEMORY.md when:**
|
|
187
|
+
- Starting a major new phase of the project
|
|
188
|
+
- A remembered pattern stops being true
|
|
189
|
+
- The file grows past 200 lines
|
|
190
|
+
|
|
191
|
+
**What to prune:**
|
|
192
|
+
- Lessons from debugging a problem that's now fixed and closed
|
|
193
|
+
- Preferences that were superseded
|
|
194
|
+
- Scripts that no longer exist
|
|
195
|
+
- Anything prefixed "TODO" that was resolved
|
|
196
|
+
|
|
197
|
+
**What to archive, not delete:**
|
|
198
|
+
- Significant debugging investigations (move to `.claude/memory/archive/`)
|
|
199
|
+
- Historical context that might matter for understanding decisions
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Memory vs. Documentation
|
|
204
|
+
|
|
205
|
+
MEMORY.md is not documentation. It's the agent's personal notebook.
|
|
206
|
+
|
|
207
|
+
| MEMORY.md | Docs (`docs/`) |
|
|
208
|
+
|-----------|----------------|
|
|
209
|
+
| For the agent | For humans |
|
|
210
|
+
| Informal, first-person | Structured, third-person |
|
|
211
|
+
| Includes mistakes and corrections | Shows correct state |
|
|
212
|
+
| Updated constantly | Updated deliberately |
|
|
213
|
+
| Short entries OK | Complete explanations expected |
|
|
214
|
+
|
|
215
|
+
Don't put architecture decisions in MEMORY.md. Do put "when I touch the auth module, I always forget to rebuild the token cache — run `npm run cache:reset` after any change to `lib/auth/`."
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Memory After Compaction
|
|
220
|
+
|
|
221
|
+
Context compaction is the main threat to in-session memory. When the context window fills and compresses, the agent loses anything it learned mid-session that wasn't written to disk.
|
|
222
|
+
|
|
223
|
+
Two protections:
|
|
224
|
+
|
|
225
|
+
1. **Write early** — When you learn something important, write it to MEMORY.md before you forget or before compaction hits.
|
|
226
|
+
|
|
227
|
+
2. **Re-read after compaction** — Claude Code fires a `PostCompact` notification event when context compresses. If you have a hook registered for it, you can automatically re-read MEMORY.md. Without a hook, train yourself to re-read when you notice context was compressed.
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Multiple Agents, Shared Memory
|
|
232
|
+
|
|
233
|
+
When multiple agents work on the same project, they can share MEMORY.md — but this requires a discipline: write facts, not opinions. Shared memory entries should be:
|
|
234
|
+
|
|
235
|
+
- Verifiable ("The deploy script requires X")
|
|
236
|
+
- Durable ("This pattern has been stable for 3 months")
|
|
237
|
+
- Agent-neutral ("Whoever runs this, the same caveat applies")
|
|
238
|
+
|
|
239
|
+
Agent-specific preferences, styles, or goals should stay in each agent's own identity files (see the `agent-identity` skill).
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Going Further
|
|
244
|
+
|
|
245
|
+
This works when things go well. But the agent has to remember to write its memories — and sessions don't always end cleanly. Crash, timeout, context overflow — and anything learned but not yet written is gone.
|
|
246
|
+
|
|
247
|
+
**Instar turns memory from a discipline into infrastructure.** Hooks guarantee MEMORY.md is read at every session start and after every context compaction. A scheduled reflection job runs automatically — consolidating what the agent learned across all its sessions, pruning what's stale, surfacing what matters. Your agent doesn't just store memories. It actively maintains them.
|
|
248
|
+
|
|
249
|
+
And memory is just one piece. With Instar, your agent also gets:
|
|
250
|
+
- **Persistent identity** — knows who it is and who you are, every session
|
|
251
|
+
- **A job scheduler** — recurring tasks on cron, running while you sleep
|
|
252
|
+
- **Background sessions** — spawn parallel workers for deep tasks
|
|
253
|
+
- **Telegram integration** — two-way messaging from your phone
|
|
254
|
+
|
|
255
|
+
One command, about 2 minutes:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
npx instar
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Your agent stops losing what it learned yesterday. [instar.sh](https://instar.sh)
|