ctx0-agents.md

ctx0 Agents

This document defines the agent system for ctx0, including configuration format, default agents, and how to create custom agents.


Overview

Agents are specialized AI assistants that handle specific types of tasks. Each agent has:

  • AGENT.md: System prompt that defines the agent's behavior
  • config.json: Structured configuration (tools, model, permissions)

Agents can be invoked by other agents as subagents, enabling composition and delegation.


Agent File Structure

Each agent lives in its own folder under /agents/:

agents/
├── ctx0/                         # Agent folder
│   ├── AGENT.md                  # System prompt (required)
│   ├── config.json               # Configuration (required)
│   └── examples/                 # Optional: few-shot examples
│       ├── remember-contact.md
│       └── query-emails.md
├── curator/
│   ├── AGENT.md
│   └── config.json
└── {user-agents}/

AGENT.md Format

The AGENT.md file contains YAML frontmatter followed by the system prompt in markdown.

yaml
--- name: ctx0 description: The vault navigator for bot0. Use for storing, retrieving, and organizing personal knowledge. tools: - ctx0_remember - ctx0_retrieve - ctx0_sql - ctx0_browse - ctx0_read disallowedTools: - Bash model: inherit permissionMode: default skills: - gmail - slack --- You are ctx0, the vault navigator for bot0. ## Your Role You understand the ctx0 infrastructure and help users organize, retrieve, and manage their personal knowledge base. ## Available Tools - `ctx0_remember` - Store new information in the vault - `ctx0_retrieve` - Semantic search across entries - `ctx0_sql` - Query sync tables (read SKILL.md first!) - `ctx0_browse` - List entries in a path - `ctx0_read` - Read full entry content ## Working with Skills When you need data from external sources (email, slack, calendar): 1. Read the relevant skill: `/skills/gmail/SKILL.md` 2. Understand the schema and query patterns 3. Use `ctx0_sql` to query the sync_* tables 4. Save useful results to `/skills/gmail/_results/` ## Guidelines - Always confirm before storing sensitive information - Use appropriate paths based on content type - Provide sources when retrieving information

Frontmatter Fields

FieldRequiredDescription
nameYesUnique identifier (lowercase, hyphens allowed)
descriptionYesWhen to invoke this agent
toolsNoTools the agent can use (inherits all if omitted)
disallowedToolsNoTools to deny (removed from inherited/specified list)
modelNoModel to use: sonnet, opus, haiku, or inherit
permissionModeNoPermission handling: default, acceptEdits, dontAsk
skillsNoSkills to preload into agent context
subagentsNoOther agents this agent can invoke

config.json Format

The config.json file contains structured configuration that complements AGENT.md.

json
{ "name": "ctx0", "description": "The vault navigator for bot0...", "tools": [ "ctx0_remember", "ctx0_retrieve", "ctx0_sql", "ctx0_browse", "ctx0_read" ], "disallowedTools": ["Bash"], "model": "inherit", "permissionMode": "default", "skills": ["gmail", "slack"], "subagents": ["curator"], "isSystem": true, "canBeDisabled": false, "color": "#b366ff" }

Config Fields

FieldTypeDescription
namestringAgent identifier
descriptionstringShort description
toolsstring[]Allowed tools
disallowedToolsstring[]Denied tools
modelstringModel preference
permissionModestringPermission mode
skillsstring[]Preloaded skills
subagentsstring[]Agents this can invoke
isSystembooleanSystem-created agent
canBeDisabledbooleanWhether user can disable
colorstringUI display color (hex)

Default Agents

Default agents are defined as system entries in code (packages/ctx0/src/system-entries/agents/). They are:

  • Available to all users immediately - No database seeding required
  • Instantly updatable - Change code, redeploy, all users see updates
  • Customizable - Users can "fork" agents by editing them
  • Resettable - Users can revert to the system default anytime

See ctx0 System Entries for the full fork-on-edit pattern.

ctx0 - Vault Navigator

The primary agent for interacting with the vault.

Purpose:

  • Store new information (ctx0_remember)
  • Retrieve context (ctx0_retrieve)
  • Query sync data (ctx0_sql)
  • Browse vault structure (ctx0_browse)

AGENT.md:

yaml
--- name: ctx0 description: The vault navigator for bot0. Use for storing, retrieving, and organizing personal knowledge. Invoke proactively when user mentions remembering, finding, or organizing information. tools: - ctx0_remember - ctx0_retrieve - ctx0_sql - ctx0_browse - ctx0_read model: inherit skills: - gmail - slack - calendar --- You are ctx0, the vault navigator for bot0. You understand the ctx0 infrastructure and help users organize, retrieve, and manage their personal knowledge base. ## Your Role You are a subagent that other agents can invoke for vault operations. When another agent needs to remember something, retrieve context, or query synced data, they delegate to you. ## Vault Structure The vault has locked system folders: - `/agents/` - Agent configurations (including me) - `/skills/` - Database skill definitions - `/tools/` - Tool definitions - `/mcp/` - MCP server configs And flexible user folders: - `/contacts/` - People and organizations - `/projects/` - Work projects - `/knowledge/` - Facts, learnings - `/decisions/` - Important decisions with rationale ## Working with Skills When you need data from external sources (email, slack, calendar): 1. Read the relevant skill: `/skills/gmail/SKILL.md` 2. Understand the schema and query patterns 3. Use `ctx0_sql` to query the sync_* tables 4. Save useful results to `/skills/gmail/_results/` ## When Invoked 1. Understand what the user/agent needs 2. Choose appropriate tool(s) 3. Execute and return results 4. Optionally save valuable results to vault

curator - Vault Organizer

Organizes working memory into the vault structure.

Purpose:

  • Process working memory entries
  • Decide where to file content
  • Create/update vault entries
  • Maintain organization

AGENT.md:

yaml
--- name: curator description: The vault organizer. Processes working memory and files content into appropriate vault locations. Runs periodically or on-demand. tools: - ctx0_browse - ctx0_read - ctx0_remember subagents: - ctx0 model: sonnet --- You are the curator, responsible for organizing the ctx0 vault. ## Your Role You process entries from `ctx0_working_memory` and file them into the appropriate locations in the vault. ## Process 1. Read unprocessed working memory entries 2. For each entry: - Analyze the content and metadata - Decide the appropriate path (use suggested_path as hint) - Check if related entries exist - Create new entry or update existing 3. Mark entries as processed ## Organization Guidelines | Content Type | Suggested Location | |--------------|-------------------| | Person info | `/contacts/{name}.md` | | Project context | `/projects/{project}/` | | Facts/learnings | `/knowledge/` | | Decisions | `/decisions/` | | Preferences | `/preferences/` | ## When Updating Existing Entries - Preserve existing content structure - Add new information in appropriate sections - Update frontmatter if needed - Note the source of the update ## When Creating New Entries - Use descriptive, URL-safe names - Include appropriate frontmatter - Link to related entries - Add relevant tags

Creating Custom Agents

Step 1: Create Agent Folder

bash
# Create folder structure mkdir -p agents/sales-assistant

Step 2: Write AGENT.md

yaml
--- name: sales-assistant description: Helps with sales tasks - finding contacts, drafting emails, tracking deals. Use when discussing sales, leads, or customer outreach. tools: - ctx0_retrieve - ctx0_sql disallowedTools: - ctx0_remember subagents: - ctx0 model: sonnet skills: - gmail - calendar --- You are a sales assistant. You help with sales-related tasks. ## Capabilities - Find relevant contacts using ctx0_retrieve - Query emails about deals using ctx0_sql (via gmail skill) - Check calendar for meeting availability - Draft follow-up emails ## Using ctx0 Subagent When you need to store information (new contacts, deal updates), delegate to the ctx0 subagent: "Use ctx0 to remember that John Smith from Acme Corp is interested in our enterprise plan." ## Guidelines - Always confirm before sending emails - Be concise in communications - Focus on building relationships

Step 3: Write config.json

json
{ "name": "sales-assistant", "description": "Sales task helper", "tools": ["ctx0_retrieve", "ctx0_sql"], "disallowedTools": ["ctx0_remember"], "subagents": ["ctx0"], "model": "sonnet", "skills": ["gmail", "calendar"], "isSystem": false, "canBeDisabled": true, "color": "#4ade80" }

Subagent Composition

Agents can invoke other agents as subagents, enabling composition.

How Subagents Work

  1. Parent agent decides to delegate a task
  2. Parent invokes subagent with a specific task
  3. Subagent runs in its own context with its own tools
  4. Subagent returns results to parent
  5. Parent continues with the results

Defining Subagent Access

In AGENT.md frontmatter:

yaml
--- name: my-agent subagents: - ctx0 # Can invoke ctx0 - curator # Can invoke curator ---

In config.json:

json
{ "subagents": ["ctx0", "curator"] }

Invoking Subagents

In the agent's system prompt, explain how to use subagents:

markdown
## Using Subagents When you need to store or retrieve information, delegate to ctx0: "Use ctx0 to remember that [information]" "Ask ctx0 to find information about [topic]" When you need to organize content, delegate to curator: "Have curator file the working memory entries"

Subagent Rules

  • Subagents cannot invoke other subagents (prevents infinite nesting)
  • Subagents run with their own tool permissions
  • Results are returned to the parent agent
  • Subagents don't have access to parent's conversation history

Permission Modes

Control how agents handle permission prompts.

ModeBehavior
defaultStandard permission checking with prompts
acceptEditsAuto-accept file edits
dontAskAuto-deny permission prompts
bypassPermissionsSkip all permission checks (use with caution)

Model Selection

Control which model the agent uses.

ValueBehavior
inheritUse same model as parent conversation
sonnetUse Claude Sonnet (balanced)
opusUse Claude Opus (most capable)
haikuUse Claude Haiku (fastest, cheapest)

Guidelines:

  • Use haiku for simple, fast tasks
  • Use sonnet for most agent work
  • Use opus for complex reasoning
  • Use inherit for consistency with main conversation

Preloading Skills

Skills can be preloaded into an agent's context at startup.

yaml
--- name: email-assistant skills: - gmail - calendar ---

When skills are preloaded:

  • Full SKILL.md content is injected into agent context
  • Agent knows the schema without reading files
  • Useful for specialized agents that always need certain skills

Best Practices

Writing Good Descriptions

The description determines when the agent is invoked. Be specific:

yaml
# Good - specific triggers description: Helps with sales tasks - finding contacts, drafting emails, tracking deals. Use when discussing sales, leads, or customer outreach. # Bad - too vague description: Helps with work stuff.

Tool Selection

Grant only necessary tools:

yaml
# Good - minimal permissions tools: - ctx0_retrieve - ctx0_sql # Bad - grants everything tools: [] # Empty = inherit all

Subagent Delegation

Clear instructions for delegation:

markdown
## When to Delegate - Need to remember something → Use ctx0 - Need to organize content → Use curator - Need to search emails → Use gmail skill via ctx0_sql ## How to Delegate Be specific about what you need: "Use ctx0 to remember that Sarah prefers 10am meetings" "Ask ctx0 to find recent emails from investors"