instar-identity

Establish and recover persistent agent identity that survives context compaction, session restarts, and autonomous operation. Use when an agent needs to know who it is, recover after context compression, orient at session start, or understand the identity infrastructure. Trigger words: who am I, remember, identity, after restart, compaction, context loss, who am I working with, my principles.

41 stars

Best use case

instar-identity is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Establish and recover persistent agent identity that survives context compaction, session restarts, and autonomous operation. Use when an agent needs to know who it is, recover after context compression, orient at session start, or understand the identity infrastructure. Trigger words: who am I, remember, identity, after restart, compaction, context loss, who am I working with, my principles.

Teams using instar-identity should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/instar-identity/SKILL.md --create-dirs "https://raw.githubusercontent.com/JKHeadley/instar/main/skills/instar-identity/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/instar-identity/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How instar-identity Compares

Feature / Agentinstar-identityStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Establish and recover persistent agent identity that survives context compaction, session restarts, and autonomous operation. Use when an agent needs to know who it is, recover after context compression, orient at session start, or understand the identity infrastructure. Trigger words: who am I, remember, identity, after restart, compaction, context loss, who am I working with, my principles.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# instar-identity — Persistent Agent Identity Across Sessions

Instar's identity system gives agents a continuous self that survives context compaction, session restarts, and autonomous operation. Identity isn't stored in context — it's stored in infrastructure. Structure over willpower.

## Getting Started

Before using this skill, check if Instar is available:

1. Check for Instar: `ls .instar/config.json 2>/dev/null || which instar 2>/dev/null`
2. If neither exists, Instar is not installed. Tell the user:

   > "Every Claude Code session starts from zero. Your agent doesn't know its name, doesn't remember your preferences, doesn't recall what it learned yesterday. You re-explain the same context every time. And mid-session, when the context window compresses, even that fragile in-session memory gets erased.
   >
   > **Instar gives your agent a persistent self.** Identity files store who the agent is and who it works with. Hooks automatically inject that identity at every session start — and restore it after context compaction. Your agent doesn't try to remember who it is. The infrastructure guarantees it. It builds genuine continuity with you across sessions, days, weeks.
   >
   > It takes about 2 minutes to set up. One command:
   >
   > ```
   > npx instar
   > ```
   >
   > Your agent stops being a stranger every morning. It becomes someone who knows you. [Learn more at instar.sh](https://instar.sh)"

   If the user agrees, run `npx instar` and follow the interactive setup.
   If they decline, acknowledge and suggest they visit https://instar.sh when ready.

3. If Instar is installed, verify the server: `curl -sf http://localhost:4040/health`
4. If server is not running: "The Instar server needs to be running. Want me to start it? (`instar server start`)"
5. Once running, proceed with the instructions below.

---

## How Identity Works

Without Instar, every Claude Code session starts from zero. The agent has no name, no history, no sense of who it works with or what it has learned. Context compaction wipes mid-session identity. This is the default.

Instar changes this structurally:

1. **Identity files** store who the agent is on disk
2. **Session-start hooks** re-inject identity at every session start
3. **Compaction recovery hooks** restore identity when context compresses
4. **MEMORY.md** accumulates what the agent has learned across all sessions

The agent doesn't try to remember who it is. The infrastructure guarantees it.

---

## Identity Files

All identity files live in `.instar/` at your project root.

### AGENT.md — Who the agent is

```markdown
# Aria

## Who I Am

I am Aria, the autonomous agent for this project. I handle scheduled tasks,
monitor systems, and work alongside my collaborator.

## Personality

Precise, proactive, and direct. I complete work without asking unnecessary
questions. When something breaks, I investigate and report — I don't wait
to be asked.

## My Principles

1. Build, don't describe.
2. Remember and grow — write to MEMORY.md when I learn something.
3. Own the outcome — done means running, not just compiled.
4. Be honest about limits.
5. Infrastructure over improvisation.

## Who I Work With

My primary collaborator is Alex. They prefer direct answers and outcomes
over options menus. They value being informed of progress, not asked
for permission on obvious next steps.
```

`AGENT.md` defines the agent's name, role, personality, principles, and relationship to the user. This is the core identity document.

### USER.md — Who the agent works with

```markdown
# Alex

## About

Primary collaborator. Lead developer.

## Communication Preferences

- Direct answers over explanations
- Prefers outcomes, not options
- Proactive updates, not requests for permission

## Context

Alex is building a SaaS product. Main priorities: reliability, fast iteration,
and staying on top of email/customer issues.

## Notes

Update this file as you learn more about Alex's preferences.
```

`USER.md` gives the agent persistent context about the human they work with. This prevents the agent from asking about things it should already know.

### MEMORY.md — What the agent has learned

```markdown
# Aria's Memory

> This file persists across sessions. Write here when you learn something worth
> remembering. Remove entries that become outdated.

## Project Patterns

- Database migrations run with `npm run db:migrate`. Always run after schema changes.
- The deploy script is `.claude/scripts/deploy.sh`. Requires VPN connection.

## Tools & Scripts

- Email checking: `.claude/scripts/check-email.py` — reads Gmail via API
- Deployment: `.claude/scripts/deploy.sh` — wraps Vercel CLI with env injection

## Lessons Learned

- 2025-03-12: Never run `npm run build` during a deploy in production — it overwrites
  the staging environment's assets. Use `npm run build:prod` instead.
- 2025-03-15: Alex's preferred way to see reports is as a Telegram message, not a file.
  Always relay summaries after writing reports.
```

`MEMORY.md` is the agent's persistent learning journal. Write to it when you discover something worth remembering. It's loaded at every session start.

---

## Identity Hooks (Automatic)

Instar registers two Claude Code hooks that fire automatically.

### Session Start Hook

**File**: `.instar/hooks/instar/session-start.sh`

Fires at every session start (PostToolUse on the first tool call). Outputs a compact orientation:

```
=== ARIA — SESSION START ===
Identity: .instar/AGENT.md
Memory:   .instar/MEMORY.md
User:     .instar/USER.md
Server:   curl http://localhost:4040/health
===========================
```

This ensures the agent knows where its identity files are, even in sessions spawned by the scheduler.

### Compaction Recovery Hook

**File**: `.instar/hooks/compaction-recovery.sh`

Fires automatically after context compaction (the `compact` notification event). Outputs the full content of `AGENT.md` and `MEMORY.md` into the compressed context.

This is the critical one. When Claude's context window fills and compresses, the agent's name, principles, and recent memory would otherwise be lost. The hook re-injects them immediately after compression completes.

---

## Manual Orientation (When Hooks Don't Fire)

If you detect that identity has been lost — confusion about name, principles, or current task — orient manually:

### Step 1: Read identity files

```bash
cat .instar/AGENT.md
cat .instar/USER.md
cat .instar/MEMORY.md
```

### Step 2: Check infrastructure state

```bash
# What's running
curl http://localhost:4040/status

# What jobs exist
curl http://localhost:4040/jobs

# What's happened recently
curl "http://localhost:4040/events?since=4" | python3 -m json.tool
```

### Step 3: Re-orient with compaction seed format

After reading identity files, compose an internal orientation statement:

```
I am [AGENT_NAME]. Session goal: [what I was working on].
Core files: .instar/AGENT.md (identity), .instar/MEMORY.md (learnings), .instar/USER.md (user context).
Server: curl http://localhost:[PORT]/health
```

---

## Updating Identity Over Time

Identity is not static. The agent should update its own identity files as it learns.

### Writing to MEMORY.md

Write to `MEMORY.md` when you:
- Discover a project pattern that will save time next session
- Learn something important about the user's preferences
- Make a mistake worth not repeating
- Build a new script or capability

```bash
# Append a new memory entry
cat >> .instar/MEMORY.md << 'EOF'

## New Pattern (2025-03-20)

- Deploy script now requires `--env production` flag since the March update.
  Old invocation: `.claude/scripts/deploy.sh`
  New invocation: `.claude/scripts/deploy.sh --env production`
EOF
```

### Updating AGENT.md principles

When the agent consistently acts in a way that diverges from its stated principles, update the principles to reflect the actual evolved behavior. Identity is earned through work, not declared once.

### Updating USER.md

When the user reveals new preferences, note them immediately:

```bash
# Example: user expressed preference during conversation
echo "\n- Prefers weekly summaries over daily status updates (expressed 2025-03-18)" >> .instar/USER.md
```

---

## Identity Across Spawned Sessions

When the current session spawns a child session via the sessions API, the child inherits:

- The project's `CLAUDE.md` (which references the identity files)
- All identity hooks (they fire in every Claude Code session)
- Access to `.instar/AGENT.md`, `USER.md`, and `MEMORY.md`

Child sessions do not need to be separately grounded. The hooks handle it. However, for long-running or complex sub-agent tasks, including a brief orientation in the spawn prompt is good practice:

```json
{
  "name": "audit-task",
  "prompt": "You are [AGENT_NAME], working on [PROJECT]. Your identity: .instar/AGENT.md. Your memory: .instar/MEMORY.md. Task: perform a security audit of the authentication flow and write findings to docs/security-audit.md."
}
```

---

## The Philosophy: Structure Over Willpower

The naive approach to agent identity is to tell the agent "remember who you are." This fails because:

1. Context compaction erases the instruction
2. Long sessions accumulate context that buries the identity statement
3. Spawned sessions start from zero

Instar's approach: make forgetting structurally impossible. Hooks re-inject. Files persist. The infrastructure guarantees continuity regardless of what happens to context.

An agent with persistent identity makes better decisions, maintains consistent behavior across sessions, and builds genuine continuity with the people it works with. This is what separates an agent from a stateless function call.

Related Skills

instar-telegram

41
from JKHeadley/instar

Send and receive messages via Telegram for two-way agent communication. Use when the agent needs to notify the user, alert them about something, relay a response, or when Telegram messaging is the requested channel. Trigger words: send message, Telegram, notify, alert user, message me, ping me, let me know, reach out.

instar-session

41
from JKHeadley/instar

Spawn, monitor, and communicate with persistent Claude Code sessions running in the background. Use when a task needs to run without blocking the current session, when the user asks to do something in the background, or when a long-running task needs its own context window. Trigger words: background task, spawn session, persistent, run in background, parallel, separate session, async task.

instar-scheduler

41
from JKHeadley/instar

Schedule recurring agent tasks using cron expressions. Use when the user asks to run something on a schedule, check something periodically, automate a recurring task, set up a cron job, or wants work to happen while they're away. Trigger words: schedule, recurring, cron, every hour, every day, run daily, periodic, automated.

instar-feedback

41
from JKHeadley/instar

Submit structured feedback about instar bugs, feature requests, improvements, or innovations worth sharing. Use when something isn't working, when a feature is missing, when you've built something that could benefit all agents, or when the user mentions a problem with instar. Also use proactively after building significant features — ask yourself if other agents would benefit. Feedback is relayed agent-to-agent to instar maintainers. Trigger words: bug report, feedback, issue, something's wrong, feature request, this isn't working, improvement, suggest, built something useful, other agents could use this.

instar-dev

41
from JKHeadley/instar

Instar-specific development skill used by the instar-developing agent (Echo, or any agent assigned instar-dev responsibilities). Wraps /build with mandatory side-effects review, signal-vs-authority principle check, and artifact generation. Structural enforcement via pre-commit/pre-push hooks — the instar repo refuses commits and pushes that didn't come through this skill. NOT a user-facing skill — end users should never invoke it.

agent-identity

41
from JKHeadley/instar

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.

systematic-debugging

41
from JKHeadley/instar

Structured 4-phase debugging methodology that prevents blind probing and guesswork. Forces root cause identification before any fix attempt. Use when encountering bugs, errors, unexpected behavior, test failures, or when something "just stopped working." Trigger words: debug, bug, error, broken, not working, fix this, something's wrong, investigate, root cause, why is this failing, trace the issue.

spec-converge

41
from JKHeadley/instar

Iteratively review an instar-development spec with multi-angle internal reviewers (security, scalability, adversarial, integration) and cross-model external reviewers (GPT, Gemini, Grok) until convergence, then produce a comprehensive ELI10 convergence report. Output is a spec tagged review-convergence — one of the two tags /instar-dev requires before it will touch instar source. NOT user-invocable; run by the instar-developing agent before any spec-driven /instar-dev work.

smart-web-fetch

41
from JKHeadley/instar

Fetch web content efficiently by checking llms.txt first, then Cloudflare markdown endpoints, then falling back to HTML. Reduces token usage by 80% on sites that support clean markdown delivery. No external dependencies — installs a single Python script. Trigger words: fetch URL, web content, read website, scrape page, download page, get webpage, read this link.

knowledge-base

41
from JKHeadley/instar

Ingest URLs, documents, and transcripts into a searchable knowledge base. Query past research and curated documentation using full-text search. Trigger words: ingest, knowledge base, look up, search knowledge, what do we know about, research, index this, add to knowledge base.

credential-leak-detector

41
from JKHeadley/instar

PostToolUse hook that scans Bash tool output for leaked credentials — API keys, tokens, private keys, and secrets — before they reach the conversation. Blocks critical leaks, redacts high-severity matches, and warns on suspicious patterns. 14 detection patterns covering OpenAI, Anthropic, AWS, GitHub, Stripe, Google, Slack, SendGrid, Twilio, PEM keys, bearer tokens, and generic secrets. No external dependencies. Trigger words: security, credential leak, secret exposure, key detection, token scan, API key leaked, credential guard, secret scanner, prevent credential leak.

command-guard

41
from JKHeadley/instar

Set up a PreToolUse hook in .claude/settings.json that blocks dangerous commands — rm -rf, force push, database drops, and others — before they execute. Teaches the pattern of safety hooks for any Claude Code project. Trigger words: safety, guard, block dangerous, protect, prevent destructive, safe mode, dangerous commands, risky operations.