using-contextd
Use when starting any session with contextd - introduces core tools for cross-session memory, semantic code search, and error remediation. REQUIRES contextd MCP server.
What this skill does
# Using contextd
## Prerequisites: contextd MCP Server
**This skill REQUIRES the contextd MCP server.**
Before using any contextd tools, verify availability:
1. Check for `mcp__contextd__*` tools (use ToolSearch if needed)
2. If tools are NOT available:
- Inform user: "contextd MCP server not configured"
- Suggest: "Run `/contextd:init` to configure contextd"
- Alternative: Use standard Read/Grep/Glob (no cross-session memory)
## Error Handling
| Error | Meaning | Fix |
|-------|---------|-----|
| `Unknown tool: mcp__contextd__*` | MCP not configured | Run `/contextd:init` |
| `Connection refused on port 9090` | Server not running | Run `contextd serve` |
| `Tenant not found` | First use | Will auto-create |
### Input Validation Errors
contextd v1.5+ enforces strict input validation. Common errors:
| Error | Cause | Fix |
|-------|-------|-----|
| `invalid project_path: path contains directory traversal` | Path contains `../` | Use absolute paths or paths within project |
| `invalid tenant_id: must be lowercase alphanumeric with underscores` | Invalid characters in ID | Use format: `my_project`, `org123` (1-64 chars) |
| `invalid project_id: must be lowercase alphanumeric with underscores` | Invalid characters in ID | Same as tenant_id format |
| `invalid include_patterns: contains dangerous characters` | Shell injection chars in glob | Remove `;`, `\|`, `` ` ``, `$` from patterns |
| `invalid patterns: excessive wildcards` | Pattern like `***` | Use standard globs: `*`, `**`, `*.go` |
---
## Pre-Flight Protocol (MANDATORY)
**BEFORE any filesystem operation (Read, Grep, Glob), you MUST:**
1. **`semantic_search(query, project_path: ".")`** - Semantic code search with auto grep fallback
2. **`memory_search(project_id, query)`** - Check past learnings and solutions
Skipping this is a protocol violation.
## Core Tools
| Category | Tools | Purpose |
|----------|-------|---------|
| **Search** | `semantic_search`, `repository_search`, `repository_index` | Code lookup by meaning |
| **Memory** | `memory_search`, `memory_record`, `memory_feedback`, `memory_outcome` | Cross-session learning |
| **Checkpoint** | `checkpoint_save`, `checkpoint_list`, `checkpoint_resume` | Context preservation |
| **Remediation** | `remediation_search`, `remediation_record`, `troubleshoot_diagnose` | Error pattern tracking |
| **Context Folding** | `branch_create`, `branch_return`, `branch_status` | Isolated sub-tasks |
| **Reflection** | `reflect_analyze`, `reflect_report` | Behavior pattern analysis |
## Health Monitoring (HTTP)
contextd exposes HTTP health endpoints for monitoring vectorstore integrity:
| Endpoint | Purpose | Status Codes |
|----------|---------|--------------|
| `GET /health` | Basic health with metadata summary | 200 OK, 503 Degraded |
| `GET /api/v1/health/metadata` | Detailed per-collection status | 200 OK |
**Graceful Degradation (P0)**: If corrupt collections are detected, contextd quarantines them and continues operating with healthy collections. Check health status to detect degraded state.
**Example health check**:
```bash
curl -s http://localhost:9090/health | jq
# {"status":"ok","metadata":{"status":"healthy","healthy_count":22,"corrupt_count":0}}
```
## Search Priority
| Priority | Tool | When |
|----------|------|------|
| **1st** | `semantic_search` | Auto-selects best method (indexed or grep fallback) |
| **2nd** | `memory_search` | Have I solved this before? |
| **3rd** | Read/Grep/Glob | Fallback for exact matches only |
### Path Validation (contextd v1.5+)
All tools accepting `project_path` validate paths before use:
- **No directory traversal**: Paths containing `../` are rejected
- **Affected tools**: `semantic_search`, `repository_index`, `repository_search`, `reflect_report`
- **Use absolute paths** or paths within the current project directory
## The Learning Loop
```
1. SEARCH at task start (MANDATORY)
semantic_search(query, project_path)
memory_search(project_id, query)
2. DO the work
(apply relevant memories)
3. RECORD at completion
memory_record(project_id, title, content, outcome)
4. FEEDBACK when memories helped
memory_feedback(memory_id, helpful)
```
## Key Concepts
**Tenant ID**: Derived from git remote (e.g., `github.com/fyrsmithlabs/contextd` -> `fyrsmithlabs`). Verify with: `git remote get-url origin | sed 's|.*github.com[:/]\([^/]*\).*|\1|'`
**Project ID**: Scopes memories. Use repository name (e.g., `contextd`) or `org_repo` format for multi-org.
### ID Format Requirements (contextd v1.5+)
Both `tenant_id` and `project_id` must follow this format:
- **Characters**: Lowercase alphanumeric and underscores only (`a-z`, `0-9`, `_`)
- **Length**: 1-64 characters
- **Valid**: `my_project`, `contextd`, `org123`, `fyrsmithlabs_marketplace`
- **Invalid**: `My-Project` (uppercase, hyphen), `org/repo` (slash), `project..name` (dots)
**Confidence**: Memories have scores (0-1) that adjust via feedback. Higher = ranks first.
## What to Record
**Good memories:**
- Non-obvious solutions
- Patterns that apply broadly
- Design decisions with rationale (the WHY)
- Mistakes and why they failed
**Skip recording:**
- Trivial fixes (typos, syntax)
- Project-specific details (put in CLAUDE.md)
## Recording Design Decisions
When design involves significant discussion, capture the WHY:
```json
{
"project_id": "contextd",
"title": "ADR: Registry pattern for DI",
"content": "DECISION: Use Registry interface.\nWHY: Idiomatic Go, single mock for tests.\nREJECTED: Passing individual services (constructor bloat).",
"outcome": "success",
"tags": ["adr", "architecture", "design-decision"]
}
```
## Optional: Conversation Indexing
Index past Claude Code sessions to pre-warm contextd:
```bash
# Via /init command
/init --conversations
# What it extracts:
# - Error -> fix patterns (remediations)
# - Learnings (memories)
# - User corrections (policies)
```
Conversations are scrubbed for secrets before processing.
## Common Mistakes
| Mistake | Fix |
|---------|-----|
| Using Read/Grep before contextd | `semantic_search` FIRST |
| Not searching at task start | Always `memory_search` first |
| Forgetting to record learnings | `memory_record` at task completion |
| Re-solving fixed errors | `remediation_search` when errors occur |
| Context bloat from sub-tasks | Use `branch_create` for isolation |
---
## Memory Lifecycle
### Temporal Decay & Expiration
Memories have a confidence score (0-1) that decays over time without reinforcement:
| Age | Decay Factor | Result |
|-----|--------------|--------|
| < 7 days | 1.0 | Full confidence |
| 7-30 days | 0.9 | Slight decay |
| 30-90 days | 0.7 | Moderate decay |
| > 90 days | 0.5 | Significant decay (but never deleted) |
**Boost confidence via:**
- `memory_feedback(memory_id, helpful=true)` - Resets decay timer
- Memory reuse in solutions - Auto-boosted when applied
**Expiration policies:**
- `ttl_days: 365` - Auto-archive after 1 year without activity
- `never_expire: true` - For ADRs and critical decisions
### Memory Types
| Type | Purpose | Default TTL |
|------|---------|-------------|
| `learning` | General knowledge gained | 180 days |
| `remediation` | Error -> fix mappings | 365 days |
| `decision` | ADR/architecture choices | Never |
| `failure` | What NOT to do | 365 days |
| `pattern` | Reusable code patterns | 180 days |
| `policy` | STRICT constraints | Never |
Tag memories with type: `tags: ["type:learning", "category:testing"]`
---
## Query Expansion & Fuzzy Matching
### Automatic Query Expansion
`semantic_search` and `memory_search` automatically expand queries:
| Original Query | Expanded To |
|----------------|-------------|
| "auth error" | "auth error", "authentication failure", "login issue", "401", "403" |
| "test fails" | "test fails", "test failure", "assertion error", "spec broken" |
| "slow query" | "slow query", "performance", "N+1", "timeout", "latency" |
Disable expansion: `expand_query: false`Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.