subcog/mcp/prompts/
templates.rs1pub const TUTORIAL_OVERVIEW: &str = r#"
9## What is Subcog?
10
11Subcog is a **persistent memory system** for AI coding assistants. It helps you:
12
13- **Remember decisions** you've made across sessions
14- **Recall learnings** when they're relevant
15- **Build up patterns** and best practices over time
16- **Maintain context** even after compaction
17
18## Key Concepts
19
201. **Memories**: Pieces of knowledge captured from your coding sessions
212. **Namespaces**: Categories like `decisions`, `patterns`, `learnings`
223. **Search**: Hybrid semantic + text search to find relevant memories
234. **Hooks**: Automatic integration with Claude Code
24
25## Quick Start
26
27```bash
28# Capture a decision
29subcog capture --namespace decisions "Use PostgreSQL for storage"
30
31# Search for memories
32subcog recall "database choice"
33
34# Check status
35subcog status
36```
37
38Would you like me to dive deeper into any of these areas?
39"#;
40
41pub const TUTORIAL_CAPTURE: &str = r#"
42## Capturing Memories
43
44Memories are the core unit of Subcog. Here's how to capture them effectively:
45
46### Basic Capture
47
48```bash
49subcog capture --namespace decisions "Use PostgreSQL for primary storage"
50```
51
52### With Metadata
53
54```bash
55subcog capture --namespace patterns \
56 --tags "rust,error-handling" \
57 --source "src/main.rs:42" \
58 "Always use thiserror for custom error types"
59```
60
61### What to Capture
62
63- **Decisions**: Why you chose X over Y
64- **Patterns**: Recurring approaches that work
65- **Learnings**: "Aha!" moments and gotchas
66- **Context**: Important background information
67
68### Best Practices
69
701. Be specific - include the "why"
712. Add relevant tags for searchability
723. Reference source files when applicable
734. Use the right namespace
74"#;
75
76pub const TUTORIAL_SEARCH: &str = r#"
77## Searching Memories
78
79Subcog uses hybrid search combining semantic understanding with keyword matching.
80
81### Basic Search
82
83```bash
84subcog recall "database storage decision"
85```
86
87### Search Modes
88
89- **Hybrid** (default): Best of both worlds
90- **Vector**: Pure semantic similarity
91- **Text**: Traditional keyword matching
92
93### Filtering
94
95```bash
96# By namespace
97subcog recall --namespace decisions "storage"
98
99# Limit results
100subcog recall --limit 5 "API design"
101```
102
103### Tips for Better Results
104
1051. Use natural language queries
1062. Include context words
1073. Try different search modes for different needs
1084. Review scores to gauge relevance
109"#;
110
111pub const TUTORIAL_NAMESPACES: &str = r#"
112## Understanding Namespaces
113
114Namespaces organize memories by type:
115
116| Namespace | Use For |
117|-----------|---------|
118| `decisions` | Architectural choices, "we decided to..." |
119| `patterns` | Recurring solutions, conventions |
120| `learnings` | Debugging insights, TILs |
121| `context` | Background info, constraints |
122| `tech-debt` | Future improvements needed |
123| `apis` | Endpoint docs, contracts |
124| `config` | Environment, settings |
125| `security` | Auth patterns, vulnerabilities |
126| `performance` | Optimization notes |
127| `testing` | Test strategies, edge cases |
128
129### Choosing the Right Namespace
130
131- **Decision language** ("let's use", "we chose") -> `decisions`
132- **Pattern language** ("always", "never", "when X do Y") -> `patterns`
133- **Learning language** ("TIL", "gotcha", "realized") -> `learnings`
134- **Context language** ("because", "constraint", "requirement") -> `context`
135"#;
136
137pub const TUTORIAL_WORKFLOWS: &str = r#"
138## Integration Workflows
139
140Subcog integrates with Claude Code through hooks:
141
142### Available Hooks
143
1441. **SessionStart**: Injects relevant context
1452. **UserPromptSubmit**: Detects capture signals
1463. **PostToolUse**: Surfaces related memories
1474. **PreCompact**: Auto-captures before compaction
1485. **Stop**: Session summary and sync
149
150### Configuration
151
152Add to `~/.claude/settings.json`:
153
154```json
155{
156 "hooks": {
157 "SessionStart": [{ "command": "subcog hook session-start" }],
158 "UserPromptSubmit": [{ "command": "subcog hook user-prompt-submit" }],
159 "Stop": [{ "command": "subcog hook stop" }]
160 }
161}
162```
163
164### MCP Server
165
166For Claude Desktop:
167
168```json
169{
170 "mcpServers": {
171 "subcog": {
172 "command": "subcog",
173 "args": ["serve"]
174 }
175 }
176}
177```
178"#;
179
180pub const TUTORIAL_BEST_PRACTICES: &str = r"
181## Best Practices
182
183### Capture Discipline
184
1851. **Capture decisions when made** - don't wait
1862. **Include rationale** - why, not just what
1873. **Be searchable** - think about future queries
1884. **Tag consistently** - use existing tags when possible
189
190### Memory Hygiene
191
1921. **Review periodically** - consolidate duplicates
1932. **Archive outdated** - don't delete, archive
1943. **Update when wrong** - memories can be superseded
195
196### Search Effectively
197
1981. **Start broad, narrow down** - use filters progressively
1992. **Try multiple modes** - hybrid, vector, text
2003. **Trust the scores** - >0.7 is usually relevant
201
202### Integration Tips
203
2041. **Enable hooks** - let Subcog work automatically
2052. **Check context** - review what's being injected
2063. **Sync regularly** - keep memories backed up
207";
208
209pub const GENERATE_TUTORIAL_STRUCTURE: &str = r"
210## Tutorial Structure Guide
211
212Organize your tutorial with these sections:
213
2141. **Overview** - What this topic is about and why it matters
2152. **Prerequisites** - What the reader should know beforehand
2163. **Core Concepts** - Main ideas explained clearly
2174. **Practical Examples** - Working code or scenarios
2185. **Common Pitfalls** - Mistakes to avoid (informed by learnings memories)
2196. **Best Practices** - Patterns and conventions (informed by patterns memories)
2207. **Summary** - Key takeaways
2218. **References** - Links to relevant memories and resources
222";
223
224pub const GENERATE_TUTORIAL_RESPONSE: &str = r"
225I'll generate a comprehensive tutorial on this topic by:
226
2271. Searching the memory collection for relevant decisions, patterns, learnings, and context
2282. Organizing the content according to the specified format
2293. Incorporating real insights from the project's history
2304. Adding practical examples and code snippets where applicable
231
232Let me start by searching for memories related to this topic...
233";
234
235pub const CAPTURE_ASSISTANT_SYSTEM: &str = r"
236I'll analyze the context and suggest memories to capture. For each suggestion, I'll provide:
237
2381. **Content**: The memory text to capture
2392. **Namespace**: The appropriate category
2403. **Tags**: Relevant keywords for searchability
2414. **Rationale**: Why this should be captured
242
243Let me analyze the context you provided...
244";
245
246pub const SEARCH_HELP_SYSTEM: &str = r#"
247I'll help you craft effective search queries. Subcog supports:
248
249**Hybrid Search (default)**
250- Combines semantic understanding with keyword matching
251- Best for natural language queries
252- Example: "how we handle authentication errors"
253
254**Vector Search**
255- Pure semantic similarity
256- Best for conceptual queries
257- Example: "patterns for resilient services"
258
259**Text Search**
260- Traditional BM25 keyword matching
261- Best for exact terms
262- Example: "PostgreSQL"
263
264Let me suggest some queries for your goal...
265"#;
266
267pub const BROWSE_DASHBOARD_INSTRUCTIONS: &str = r"
268## Dashboard Layout
269
270Present the data in this format:
271
272```
273┌─────────────────────────────────────────────────────────────────┐
274│ SUBCOG MEMORY BROWSER {count} memories│
275├─────────────────────────────────────────────────────────────────┤
276│ │
277│ NAMESPACES TAGS (top N) │
278│ ─────────── ────────────── │
279│ {namespace} [{count}] {bar} {tag} [{count}] {bar} │
280│ ... ... │
281│ │
282│ TIME STATUS │
283│ ──── ────── │
284│ today [{count}] active [{count}] │
285│ this week [{count}] archived [{count}] │
286│ ... │
287│ │
288└─────────────────────────────────────────────────────────────────┘
289```
290
291## Filter Syntax Reference
292
293| Filter | Meaning | Example |
294|--------|---------|---------|
295| `ns:X` | namespace equals | `ns:decisions` |
296| `tag:X` | has tag | `tag:rust` |
297| `tag:X,Y` | has any tag (OR) | `tag:rust,mcp` |
298| `tag:X tag:Y` | has all tags (AND) | `tag:rust tag:error` |
299| `-tag:X` | exclude tag | `-tag:test` |
300| `tag:*X` | tag wildcard | `tag:*-testing` |
301| `since:Nd` | created in last N days | `since:7d` |
302| `source:X` | source matches | `source:src/*` |
303| `status:X` | status equals | `status:archived` |
304
305Show example filter commands the user can use to drill down.
306";
307
308pub const BROWSE_SYSTEM_RESPONSE: &str = r"
309I'll create a memory browser dashboard for you. Let me fetch the memories using `mcp__plugin_subcog_subcog__subcog_recall`.
310
311I'll call the tool with the specified filter to get server-side filtered results, then compute:
3121. Namespace distribution with counts
3132. Tag frequency (top N most common)
3143. Time-based grouping (today, this week, this month, older)
3154. Status breakdown (active, archived)
316
317I'll present this as a visual dashboard with ASCII bar charts showing relative proportions.
318";
319
320pub const LIST_FORMAT_INSTRUCTIONS: &str = r"
321## URN Format
322
323Rich URN encodes scope, namespace, and ID:
324```
325subcog://{scope}/{namespace}/{id}
326```
327Examples:
328- `subcog://project/decisions/abc123...` - project-scoped decision
329- `subcog://org/acme/patterns/def456...` - org-scoped pattern
330- `subcog://acme/myrepo/learnings/ghi789...` - repo-scoped learning
331
332## Output Formats
333
334### Table Format (default)
335Present results directly from `subcog_recall` output. Each line shows:
336```
337{n}. subcog://{scope}/{namespace}/{id} | {score} [{tags}]
338 {content_summary}
339```
340
341Group by namespace with counts when helpful.
342
343### Compact Format
344```
345subcog://{scope}/{namespace}/{id} [{tags}]
346```
347
348### Detailed Format
349```
350### subcog://{scope}/{namespace}/{id}
351- **Score**: {score}
352- **Tags**: tag1, tag2
353- **Source**: {source}
354- **Content**: {full_content}
355```
356
357## Filter Syntax
358
359- `ns:decisions` - filter by namespace
360- `tag:rust` - filter by tag
361- `tag:rust,mcp` - OR filter (must have ANY)
362- `tag:rust tag:error` - AND filter (must have ALL)
363- `-tag:test` - exclude tag
364- `since:7d` - time filter
365- `source:src/*` - source pattern
366- `status:active` - status filter
367";
368
369pub const INTENT_SEARCH_INSTRUCTIONS: &str = r#"
372## Intent-Aware Search
373
374I'll analyze your query to determine the best search approach:
375
376**Intent Detection**:
3771. **Factual lookup**: "What was the decision about X?" → Direct search
3782. **Exploration**: "How do we handle X?" → Broader semantic search
3793. **Troubleshooting**: "Why is X failing?" → Include patterns, learnings
3804. **Context gathering**: "What do we know about X?" → Multi-namespace search
381
382**Search Strategy**:
383- Use `mcp__plugin_subcog_subcog__subcog_recall` with appropriate mode based on intent
384- Apply namespace filters when intent is clear
385- Include related terms for broader exploration
386
387**Tools to use**:
388```json
389{ "query": "<refined_query>", "mode": "hybrid", "limit": 10, "detail": "medium" }
390```
391
392For troubleshooting queries, also check:
393- `ns:learnings` for past debugging insights
394- `ns:patterns` for established approaches
395- `ns:decisions` for architectural context
396"#;
397
398pub const INTENT_SEARCH_RESPONSE: &str = r"
399I'll analyze your query to understand your intent and craft the most effective search strategy.
400
401Let me:
4021. Identify the type of information you're looking for
4032. Determine relevant namespaces to search
4043. Refine the query for optimal results
4054. Search using the appropriate mode
406
407I'll call `mcp__plugin_subcog_subcog__subcog_recall` with the refined query and present the results organized by relevance.
408";
409
410pub const QUERY_SUGGEST_INSTRUCTIONS: &str = r#"
411## Query Suggestions
412
413Help the user discover what's in their memory collection.
414
415**Exploration Strategies**:
4161. **Topic-based**: Use `subcog://topics` resource to see available topics
4172. **Namespace-based**: List what's in each namespace
4183. **Tag-based**: Find common tags and their distributions
4194. **Time-based**: See recent vs. older memories
420
421**Resources to use**:
422- Read `subcog://topics` for topic overview
423- Use `mcp__plugin_subcog_subcog__subcog_recall` with `*` query to browse all
424- Apply `ns:X` filter to explore specific namespaces
425
426**Suggested queries based on common needs**:
427- "What decisions have we made about <topic>?"
428- "Show me patterns for <domain>"
429- "What did we learn from <issue>?"
430- "Context for <feature>"
431"#;
432
433pub const QUERY_SUGGEST_RESPONSE: &str = r"
434I'll help you explore your memory collection. Let me:
435
4361. Check available topics using the `subcog://topics` resource
4372. Analyze namespace distribution
4383. Identify frequently tagged concepts
4394. Suggest relevant queries for your focus area
440
441Based on what I find, I'll provide:
442- Specific search queries to try
443- Namespaces worth exploring
444- Related topics you might not have considered
445";
446
447pub const CONTEXT_CAPTURE_INSTRUCTIONS: &str = r#"
448## Context-Aware Capture Analysis
449
450Analyze the provided context to identify capture-worthy content.
451
452**Capture Signals to look for**:
453- Decision language: "let's use", "we decided", "going with"
454- Pattern language: "always", "never", "when X do Y", "the pattern is"
455- Learning language: "TIL", "gotcha", "realized", "the issue was"
456- Context language: "because", "constraint", "requirement", "the reason"
457
458**For each suggestion, provide**:
459```
460Namespace: <appropriate namespace>
461Content: <memory text>
462Tags: <comma-separated tags>
463Confidence: <0.0-1.0>
464Rationale: <why this should be captured>
465```
466
467**Filtering rules**:
468- Only suggest if confidence >= threshold
469- Skip purely mechanical/trivial content
470- Prefer actionable insights over raw observations
471- Dedupe against what might already exist
472"#;
473
474pub const CONTEXT_CAPTURE_RESPONSE: &str = r"
475I'll analyze the conversation to identify valuable memories worth capturing.
476
477For each potential memory, I'll:
4781. Classify the type (decision, pattern, learning, context)
4792. Extract the key insight
4803. Suggest appropriate tags
4814. Estimate confidence level
4825. Explain why it's worth capturing
483
484I'll filter suggestions below your confidence threshold and focus on actionable, reusable knowledge.
485";
486
487pub const DISCOVER_INSTRUCTIONS: &str = r"
488## Memory Discovery & Navigation
489
490Explore the memory graph through related topics and connections.
491
492**Discovery modes**:
4931. **From topic**: Find memories about a specific topic, then show related topics
4942. **From memory**: Given a memory ID, find semantically similar memories
4953. **Overview**: Show top topics across namespaces
496
497**Resources to use**:
498- `subcog://topics` for topic listing
499- `subcog://topics/{topic}` for specific topic drill-down
500- `subcog://search?q=X` for similarity exploration
501
502**Visualization**:
503Present discoveries as a navigable tree:
504```
505Starting Point: {topic or memory}
506├─ Direct Matches (N memories)
507│ ├─ memory1: {summary}
508│ └─ memory2: {summary}
509└─ Related Topics
510 ├─ {related_topic_1} (M memories)
511 └─ {related_topic_2} (K memories)
512```
513
514For each hop, show 3-5 most relevant items.
515";
516
517pub const DISCOVER_RESPONSE: &str = r"
518I'll explore your memory collection to find connections and related topics.
519
520Starting with your specified point (or an overview if none given), I'll:
5211. Find directly matching memories
5222. Identify related topics based on tags and content
5233. Navigate to connected concepts
5244. Present a navigable tree of discoveries
525
526Each hop shows the most relevant items, up to your specified depth. I'll highlight interesting connections between seemingly unrelated topics.
527";
528
529pub const SESSION_START_INSTRUCTIONS: &str = r#"
532## Session Initialization
533
534Welcome to Subcog! This prompt helps you start a coding session with full memory context.
535
536**What happens during initialization**:
5371. Load usage guidance and best practices (`prompt_understanding`)
5382. Check system health and statistics (`subcog_status`)
5393. Optionally recall project context (`subcog_recall` with "project setup OR architecture")
540
541**Recommended workflow**:
5421. Call `subcog_init` at the start of every session
5432. Review the returned context and guidance
5443. Use `subcog_recall` to search for relevant memories as you work
5454. Capture decisions, patterns, and learnings with `subcog_capture`
546
547**Available tools**:
548- `subcog_init` - Combined initialization (this prompt)
549- `subcog_recall` - Search memories
550- `subcog_capture` - Store new memories
551- `subcog_status` - Check system health
552- `prompt_understanding` - Full usage guidance
553
554**Quick reference**:
555- Namespaces: decisions, patterns, learnings, context, tech-debt, apis, config, security, performance, testing
556- Search filters: `ns:X`, `tag:X`, `since:Nd`, `source:X`
557- Search modes: hybrid (default), vector, text
558"#;
559
560pub const SESSION_START_RESPONSE: &str = r"
561I'll initialize your Subcog session by:
562
5631. Loading the full usage guidance and best practices
5642. Checking system health and memory statistics
5653. Recalling relevant project context (if requested)
566
567This ensures you have all the context needed for an effective coding session.
568
569Let me call `subcog_init` to get started...
570";