Skip to content

Commit d06c24b

Browse files
committed
Add detailed documentation for Markdown-based prompt imports, including configuration, format, and usage examples
1 parent 5570f35 commit d06c24b

File tree

1 file changed

+163
-0
lines changed

1 file changed

+163
-0
lines changed

docs/mcp/prompts.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ prompts can serve as starting points for common tasks, code generation, or proje
1919
- [Import](#import)
2020
- [Import Capabilities](#import-capabilities)
2121
- [Example Import Configuration](#example-import-configuration)
22+
- [Markdown Import for Prompts](#markdown-import-for-prompts)
2223
- [Tagging Prompts](#tagging-prompts)
2324
- [Filtered Imports](#filtered-imports)
2425
- [Filtering by IDs](#filtering-by-ids)
@@ -336,6 +337,168 @@ import:
336337
> **Note**: There is an example of shared prompts
337338
> on [Gist](https://gist.github.com/butschster/1b7e597691cc1a6476b15dc120ecbddb) that can be used as a starting point.
338339

340+
## Markdown Import for Prompts
341+
342+
In addition to defining prompts directly in configuration files, CTX supports importing prompts from markdown files with
343+
YAML frontmatter metadata. This approach enables teams to manage prompt libraries using familiar markdown format while
344+
maintaining the power of structured configuration.
345+
346+
### How Markdown Import Works
347+
348+
When you specify a directory with `format: md` in your import configuration:
349+
350+
```yaml
351+
import:
352+
- path: ./prompts
353+
format: md
354+
```
355+
356+
CTX will:
357+
358+
1. **Recursively scan** the directory for `.md` and `.markdown` files
359+
2. **Parse YAML frontmatter** to extract prompt metadata and configuration
360+
3. **Auto-detect prompt types** based on metadata fields
361+
4. **Convert markdown content** to prompt messages
362+
5. **Register each file** as an individual prompt accessible via MCP
363+
364+
### Markdown Prompt Format
365+
366+
#### Basic Prompt with Frontmatter
367+
368+
```markdown
369+
---
370+
type: prompt
371+
id: python-code-helper
372+
title: "Python Programming Assistant"
373+
description: "Helps with Python coding tasks and best practices"
374+
tags: ["python", "programming", "development"]
375+
role: assistant
376+
schema:
377+
properties:
378+
task:
379+
type: string
380+
description: "What Python task you need help with"
381+
complexity:
382+
type: string
383+
description: "Complexity level"
384+
enum: ["beginner", "intermediate", "advanced"]
385+
required: ["task"]
386+
---
387+
388+
# Python Programming Assistant
389+
390+
I'm here to help you with Python programming! I'll provide guidance for **{{task}}** at a {{complexity}} level.
391+
392+
I can help with:
393+
394+
- Code writing and debugging
395+
- Best practices and patterns
396+
- Library recommendations
397+
- Performance optimization
398+
399+
Please share your Python code or describe what you're trying to accomplish.
400+
```
401+
402+
#### Prompt without Frontmatter
403+
404+
```markdown
405+
# Code Review Checklist
406+
407+
## Security Review
408+
409+
- Check for SQL injection vulnerabilities
410+
- Validate all user inputs
411+
- Review authentication and authorization
412+
413+
## Performance Review
414+
415+
- Review database queries for efficiency
416+
- Check for memory leaks
417+
- Validate caching strategies
418+
```
419+
420+
When no frontmatter is present, CTX automatically:
421+
422+
- Uses the first `#` header as the title/description
423+
- Converts the entire content to a single user message
424+
- Generates an ID from the filename
425+
426+
### Template Inheritance in Markdown
427+
428+
Markdown prompts can also use template inheritance:
429+
430+
```markdown
431+
---
432+
type: prompt
433+
id: laravel-controller
434+
description: "Generate Laravel controller with validation"
435+
extend:
436+
- id: base-php-template
437+
arguments:
438+
framework: "Laravel"
439+
type: "Controller"
440+
schema:
441+
properties:
442+
entity:
443+
type: string
444+
description: "Entity name (e.g., User, Product)"
445+
required: ["entity"]
446+
---
447+
448+
# Laravel Controller Generator
449+
450+
Create a {{entity}} controller following Laravel best practices with:
451+
452+
- Resource methods (index, show, store, update, destroy)
453+
- Form request validation
454+
- API resource transformers
455+
```
456+
457+
### Supported Frontmatter Fields
458+
459+
| Field | Type | Description |
460+
|---------------|--------|--------------------------------------------------|
461+
| `type` | string | Must be "prompt" (auto-detected if omitted) |
462+
| `id` | string | Unique identifier (auto-generated from filename) |
463+
| `title` | string | Human-readable title |
464+
| `description` | string | Detailed description of the prompt |
465+
| `tags` | array | Tags for categorization and filtering |
466+
| `role` | string | Default message role ("user" or "assistant") |
467+
| `schema` | object | JSON schema for prompt arguments |
468+
| `messages` | array | Explicit message definitions (overrides content) |
469+
| `extend` | array | Template inheritance configuration |
470+
471+
### Directory Organization
472+
473+
Organize your markdown prompts in logical directories:
474+
475+
```
476+
prompts/
477+
├── development/
478+
│ ├── code-review.md
479+
│ ├── debugging-guide.md
480+
│ └── refactoring-helper.md
481+
├── documentation/
482+
│ ├── api-docs-generator.md
483+
│ └── readme-writer.md
484+
└── project-management/
485+
├── issue-template.md
486+
└── sprint-planning.md
487+
```
488+
489+
Each file becomes an individual prompt accessible through the MCP interface.
490+
491+
### Title/Description Resolution
492+
493+
CTX uses this priority order for prompt titles and descriptions:
494+
495+
1. **`description`** field in frontmatter (highest priority)
496+
2. **`title`** field in frontmatter
497+
3. **First `#` header** in markdown content
498+
4. **Generated from filename** (lowest priority)
499+
500+
This flexibility allows for both structured metadata-driven prompts and simple markdown files that just need a header.
501+
339502
## Prompt Tagging and Filtering
340503

341504
CTX allows you to organize prompts with tags and selectively import them based on these tags or their IDs. This helps

0 commit comments

Comments
 (0)