Skip to content

Commit 54734fa

Browse files
Copilotalexec
andauthored
Add optional persona support with first-position output (#36)
* Initial plan * Initial analysis - planning persona feature implementation Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Add optional persona support with -persona flag Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Update README with persona documentation and examples Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Fix error handling for persona and task file stat calls Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Update persona API: use -r flag and positional argument, remove template expansion Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> Co-authored-by: Alex Collins <alexec@users.noreply.github.com>
1 parent bffb667 commit 54734fa

File tree

4 files changed

+368
-27
lines changed

4 files changed

+368
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# Binary output
1515
coding-agent-context-cli
1616
coding-agent-context
17+
coding-context
1718

1819
# Build artifacts
1920
/dist/

README.md

Lines changed: 78 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ This tool is ideal for:
3333

3434
The basic workflow is:
3535

36-
1. **Organize your context** - Create memory files (shared context) and prompt files (task-specific instructions)
37-
2. **Run the CLI** - Execute `coding-context <task-name>` with optional parameters
36+
1. **Organize your context** - Create persona files (optional), memory files (shared context), and task files (task-specific instructions)
37+
2. **Run the CLI** - Execute `coding-context <task-name>` with optional `-persona` and parameters
3838
3. **Get assembled output** - The tool generates:
39-
- `prompt.md` - Combined context + task prompt with template variables filled in
39+
- `prompt.md` - Combined persona (if specified) + memories + task with template variables filled in
4040
- `bootstrap` - Executable script to set up the environment
4141
- `bootstrap.d/` - Individual bootstrap scripts from your memory files
4242
4. **Use with AI agents** - Share `prompt.md` with your AI coding agent, or run `./bootstrap` to prepare the environment first
4343

4444
**Visual flow:**
4545
```
46-
+---------------------+ +--------------------------+
47-
| Memory Files (*.md) | | Prompt Template |
48-
| | | (task-name.md) |
49-
+----------+----------+ +------------+-------------+
50-
| |
51-
| Filter by selectors | Apply template params
52-
v v
53-
+---------------------+ +--------------------------+
54-
| Filtered Memories +-------+ Rendered Prompt |
55-
+---------------------+ +------------+-------------+
56-
|
57-
v
58-
+----------------------------+
59-
| prompt.md (combined output)|
60-
+----------------------------+
46+
+----------------------+ +---------------------+ +--------------------------+
47+
| Persona File (*.md) | | Memory Files (*.md) | | Task Template |
48+
| (optional) | | | | (task-name.md) |
49+
+----------+-----------+ +----------+----------+ +------------+-------------+
50+
| | |
51+
| Apply template params | Filter by selectors | Apply template params
52+
v v v
53+
+----------------------+ +---------------------+ +--------------------------+
54+
| Rendered Persona +------>+ Filtered Memories +------>+ Rendered Task |
55+
+----------------------+ +---------------------+ +------------+-------------+
56+
|
57+
v
58+
+----------------------------+
59+
| prompt.md (combined output)|
60+
+----------------------------+
6161
```
6262

6363
## Installation
@@ -78,14 +78,16 @@ go install github.com/kitproj/coding-agent-context-cli@latest
7878
## Usage
7979

8080
```
81-
coding-context [options] <task-name>
81+
coding-context [options] <task-name> [persona-name]
8282
8383
Options:
8484
-b Automatically run the bootstrap script after generating it
8585
-m <path> Directory containing memories, or a single memory file (can be used multiple times)
8686
Defaults: AGENTS.md, .github/copilot-instructions.md, CLAUDE.md, .cursorrules,
8787
.cursor/rules/, .instructions.md, .continuerules, .prompts/memories,
8888
~/.config/prompts/memories, /var/local/prompts/memories
89+
-r <path> Directory containing personas, or a single persona file (can be used multiple times)
90+
Defaults: .prompts/personas, ~/.config/prompts/personas, /var/local/prompts/personas
8991
-t <path> Directory containing tasks, or a single task file (can be used multiple times)
9092
Defaults: .prompts/tasks, ~/.config/prompts/tasks, /var/local/prompts/tasks
9193
-o <directory> Output directory for generated files (default: .)
@@ -101,6 +103,12 @@ Options:
101103
coding-context -p feature="Authentication" -p language=Go add-feature
102104
```
103105

106+
**Example with persona:**
107+
```bash
108+
# Use a persona to set the context for the AI agent (persona is an optional positional argument)
109+
coding-context add-feature expert
110+
```
111+
104112
**Example with custom memory and task paths:**
105113
```bash
106114
# Specify explicit memory files or directories
@@ -124,11 +132,11 @@ coding-context -s env=production -S language=python deploy
124132

125133
## Quick Start
126134

127-
This 4-step guide shows how to set up and generate your first context:
135+
This guide shows how to set up and generate your first context:
128136

129137
**Step 1: Create a context directory structure**
130138
```bash
131-
mkdir -p .prompts/{tasks,memories}
139+
mkdir -p .prompts/{tasks,memories,personas}
132140
```
133141

134142
**Step 2: Create a memory file** (`.prompts/memories/project-info.md`)
@@ -142,7 +150,17 @@ Memory files are included in every generated context. They contain reusable info
142150
- Purpose: Manage AI agent context
143151
```
144152

145-
**Step 3: Create a prompt file** (`.prompts/tasks/my-task.md`)
153+
**Step 3: (Optional) Create a persona file** (`.prompts/personas/expert.md`)
154+
155+
Persona files define the role or character the AI agent should assume. They appear first in the output and do NOT support template variable expansion.
156+
157+
```markdown
158+
# Expert Developer
159+
160+
You are an expert developer with deep knowledge of best practices.
161+
```
162+
163+
**Step 4: Create a prompt file** (`.prompts/tasks/my-task.md`)
146164

147165
Prompt files define specific tasks. They can use template variables (like `${taskName}` or `$taskName`) that you provide via command-line parameters.
148166

@@ -154,16 +172,25 @@ Prompt files define specific tasks. They can use template variables (like `${tas
154172
Please help me with this task. The project uses ${language}.
155173
```
156174

157-
**Step 4: Generate your context file**
175+
**Step 5: Generate your context file**
158176

159177
```bash
178+
# Without persona
160179
coding-context -p taskName="Fix Bug" -p language=Go my-task
180+
181+
# With persona (as optional positional argument after task name)
182+
coding-context -p taskName="Fix Bug" -p language=Go my-task expert
161183
```
162184

163-
**Result:** This generates `./prompt.md` combining your memories and the task prompt with template variables filled in. You can now share this complete context with your AI coding agent!
185+
**Result:** This generates `./prompt.md` combining your persona (if specified), memories, and the task prompt with template variables filled in. You can now share this complete context with your AI coding agent!
164186

165-
**What you'll see in `prompt.md`:**
187+
**What you'll see in `prompt.md` (with persona):**
166188
```markdown
189+
# Expert Developer
190+
191+
You are an expert developer with deep knowledge of best practices.
192+
193+
167194
# Project Context
168195

169196
- Framework: Go CLI
@@ -187,15 +214,40 @@ The tool searches these directories for context files (in priority order):
187214
Each directory should contain:
188215
```
189216
.prompts/
217+
├── personas/ # Optional persona files (output first when specified)
218+
│ └── <persona-name>.md
190219
├── tasks/ # Task-specific prompt templates
191220
│ └── <task-name>.md
192-
└── memories/ # Reusable context files (included in all outputs)
221+
└── memories/ # Reusable context files (included in all outputs)
193222
└── *.md
194223
```
195224

196225

197226
## File Formats
198227

228+
### Persona Files
229+
230+
Optional persona files define the role or character the AI agent should assume. Personas are output **first** in the generated `prompt.md`, before memories and tasks.
231+
232+
**Important:** Persona files do NOT support template variable expansion. They are included as-is in the output.
233+
234+
**Example** (`.prompts/personas/expert.md`):
235+
```markdown
236+
---
237+
---
238+
# Expert Software Engineer
239+
240+
You are an expert software engineer with deep knowledge of best practices.
241+
You are known for writing clean, maintainable code and following industry standards.
242+
```
243+
244+
Run with:
245+
```bash
246+
coding-context add-feature expert
247+
```
248+
249+
This will look for `expert.md` in the persona directories. The persona is optional - if you don't specify a persona name as the second argument, the output will contain only memories and the task.
250+
199251
### Prompt Files
200252

201253
Markdown files with YAML frontmatter and Go template support.

0 commit comments

Comments
 (0)