Skip to content

Commit d65f48d

Browse files
CopilotalexecCopilot
authored
Fix documentation discrepancies with actual code behavior (#166)
* Initial plan * Add user-prompt argument to documentation and fix flag descriptions Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Fix search paths documentation to match code implementation Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Fix task invocation examples - remove incorrect slash prefix Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Correct agent flag documentation to match actual behavior Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Update main.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove incorrect agent filtering claims from documentation Agent filtering is not implemented - agent is only used for -w write path 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> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 623c200 commit d65f48d

8 files changed

Lines changed: 108 additions & 133 deletions

File tree

README.md

Lines changed: 48 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,17 @@ sudo chmod +x /usr/local/bin/coding-context
8080

8181
```
8282
Usage:
83-
coding-context [options] <task-name>
83+
coding-context [options] <task-name> [user-prompt]
84+
85+
Arguments:
86+
<task-name>
87+
The name of a task file to look up in task search paths (.agents/tasks).
88+
Task files are matched by filename (without .md extension).
89+
90+
[user-prompt] (optional)
91+
Optional text to append to the task. It can contain slash commands
92+
(e.g., '/command-name') which will be expanded, and parameter
93+
substitution (${param}).
8494
8595
Options:
8696
-C string
@@ -96,7 +106,7 @@ Options:
96106
Include rules with matching frontmatter. Can be specified multiple times as key=value.
97107
Note: Only matches top-level YAML fields in frontmatter.
98108
-a string
99-
Default agent to use if task doesn't specify one. Excludes that agent's own rule paths (since the agent reads those itself). Supported agents: cursor, opencode, copilot, claude, gemini, augment, windsurf, codex.
109+
Target agent to use (excludes rules from that agent's own paths). Supported agents: cursor, opencode, copilot, claude, gemini, augment, windsurf, codex.
100110
-w Write rules to agent's config file and output only task to stdout. Requires agent (via task or -a flag).
101111
```
102112

@@ -179,22 +189,22 @@ Each of these would have a corresponding `.md` file (e.g., `triage-bug.md`, `fix
179189

180190
The tool assembles the context in the following order:
181191

182-
1. **Rule Files**: It searches a list of predefined locations for rule files (`.md` or `.mdc`). These locations include the current directory, ancestor directories, user's home directory, and system-wide directories.
192+
1. **Rule Files**: It searches for rule files (`.md` or `.mdc`) in directories specified via `-d` flags and automatically-added working directory and home directory.
183193
2. **Rule Bootstrap Scripts**: For each rule file found (e.g., `my-rule.md`), it looks for an executable script named `my-rule-bootstrap`. If found, it runs the script before processing the rule file. These scripts are meant for bootstrapping the environment (e.g., installing tools) and their output is sent to `stderr`, not into the main context.
184194
3. **Filtering**: If `-s` (include) flag is used, it parses the YAML frontmatter of each rule file to decide whether to include it. Note that selectors can only match top-level YAML fields (e.g., `language: go`), not nested fields.
185195
4. **Task Prompt**: It searches for a task file matching the filename (without `.md` extension). Tasks are matched by filename, not by `task_name` in frontmatter. If selectors are provided with `-s`, they are used to filter between multiple task files with the same filename.
186196
5. **Task Bootstrap Script**: For the task file found (e.g., `fix-bug.md`), it looks for an executable script named `fix-bug-bootstrap`. If found, it runs the script before processing the task file. This allows task-specific environment setup or data preparation.
187-
6. **Parameter Expansion**: It substitutes variables in the task prompt using the `-p` flags.
188-
7. **Output**: It prints the content of all included rule files, followed by the expanded task prompt, to standard output.
189-
8. **Token Count**: A running total of estimated tokens is printed to standard error.
197+
6. **User Prompt Appending**: If a user-prompt argument is provided, it is appended to the task content after a delimiter (`---`).
198+
7. **Parameter Expansion**: It substitutes variables in the task prompt and user-prompt using the `-p` flags.
199+
8. **Output**: It prints the content of all included rule files, followed by the expanded task prompt, to standard output.
200+
9. **Token Count**: A running total of estimated tokens is printed to standard error.
190201

191202
### File Search Paths
192203

193204
The tool looks for task and rule files in the following locations, in order of precedence:
194205

195206
**Tasks:**
196207
- `./.agents/tasks/*.md` (task name matches filename without `.md` extension)
197-
- `~/.agents/tasks/*.md`
198208

199209
**Commands** (reusable content blocks referenced via slash commands like `/command-name` inside task content):
200210
- `./.agents/commands/*.md`
@@ -204,9 +214,9 @@ The tool looks for task and rule files in the following locations, in order of p
204214
**Rules:**
205215
The tool searches for a variety of files and directories, including:
206216
- `CLAUDE.local.md`
207-
- `.agents/rules`, `.cursor/rules`, `.augment/rules`, `.windsurf/rules`, `.opencode/agent`, `.opencode/rules`
208-
- `.github/copilot-instructions.md`, `.github/agents`, `.gemini/styleguide.md`
209-
- `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.codex/AGENTS.md`
217+
- `.agents/rules`, `.cursor/rules`, `.augment/rules`, `.windsurf/rules`, `.opencode/agent`
218+
- `.github/copilot-instructions.md`, `.github/agents`, `.gemini/styleguide.md`, `.augment/guidelines.md`
219+
- `AGENTS.md`, `CLAUDE.md`, `GEMINI.md`, `.cursorrules`, `.windsurfrules`
210220
- User-specific rules in `~/.agents/rules`, `~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md`, `~/.gemini/GEMINI.md`, `~/.opencode/rules`, etc.
211221

212222
### Remote File System Support
@@ -300,10 +310,10 @@ Deploy the application to production with all safety checks.
300310
You can then select the appropriate task using:
301311
```bash
302312
# Deploy to staging
303-
coding-context -s environment=staging /deploy
313+
coding-context -s environment=staging deploy
304314

305315
# Deploy to production
306-
coding-context -s environment=production /deploy
316+
coding-context -s environment=production deploy
307317
```
308318

309319
#### Task Frontmatter Selectors
@@ -328,11 +338,6 @@ When you run this task, it automatically applies the selectors:
328338
coding-context implement-feature
329339
```
330340

331-
This is equivalent to:
332-
```bash
333-
coding-context -s languages=go -s stage=implementation /implement-feature
334-
```
335-
336341
**Selectors support OR logic for the same key using arrays:**
337342
```markdown
338343
---
@@ -394,13 +399,12 @@ This is particularly useful in agentic workflows where an AI agent has already b
394399
- Skipping all rules output
395400

396401
**Example usage:**
397-
398402
```bash
399403
# Initial task invocation (includes all rules, uses task with resume: false)
400-
coding-context -s resume=false /fix-bug | ai-agent
404+
coding-context -s resume=false fix-bug | ai-agent
401405
402406
# Resume the task (skips rules, uses task with resume: true)
403-
coding-context -r /fix-bug | ai-agent
407+
coding-context -r fix-bug | ai-agent
404408
```
405409

406410
**Example task files for resume mode:**
@@ -449,7 +453,7 @@ languages:
449453
To include this rule only when working on Go code, you would use `-s languages=go`:
450454

451455
```bash
452-
coding-context -s languages=go /fix-bug
456+
coding-context -s languages=go fix-bug
453457
```
454458

455459
This will include all rules with `languages: [ go ]` in their frontmatter, excluding rules for other languages.
@@ -468,10 +472,10 @@ Then select only the relevant rules:
468472

469473
```bash
470474
# Work on Python code with Python-specific rules
471-
coding-context -s languages=python /fix-bug
475+
coding-context -s languages=python fix-bug
472476
473477
# Work on JavaScript code with JavaScript-specific rules
474-
coding-context -s languages=javascript /enhance-feature
478+
coding-context -s languages=javascript enhance-feature
475479
```
476480

477481
**Language Values**
@@ -503,42 +507,34 @@ If you need to filter on nested data, flatten your frontmatter structure to use
503507

504508
### Targeting a Specific Agent
505509

506-
When working with a specific AI coding agent, the agent itself will read its own configuration files. The `-a` flag lets you specify which agent you're using, automatically excluding that agent's specific rule paths while including rules from other agents and generic rules.
510+
The `-a` flag specifies which AI coding agent you're using. This information is currently used for:
511+
512+
1. **Write Rules Mode**: With the `-w` flag, determines where to write rules (e.g., `~/.github/agents/AGENTS.md` for `copilot`)
513+
514+
> **Note:** Agent-based rule filtering is not currently implemented. All rules are included regardless of the `-a` value.
507515

508516
**Supported agents:**
509-
- `cursor` - Excludes `.cursor/rules`, `.cursorrules`; includes other agents and generic rules
510-
- `opencode` - Excludes `.opencode/agent`, `.opencode/command`; includes other agents and generic rules
511-
- `copilot` - Excludes `.github/copilot-instructions.md`, `.github/agents`; includes other agents and generic rules
512-
- `claude` - Excludes `.claude/`, `CLAUDE.md`, `CLAUDE.local.md`; includes other agents and generic rules
513-
- `gemini` - Excludes `.gemini/`, `GEMINI.md`; includes other agents and generic rules
514-
- `augment` - Excludes `.augment/`; includes other agents and generic rules
515-
- `windsurf` - Excludes `.windsurf/`, `.windsurfrules`; includes other agents and generic rules
516-
- `codex` - Excludes `.codex/`, `AGENTS.md`; includes other agents and generic rules
517+
- `cursor` - Cursor IDE
518+
- `opencode` - OpenCode.ai
519+
- `copilot` - GitHub Copilot
520+
- `claude` - Anthropic Claude
521+
- `gemini` - Google Gemini
522+
- `augment` - Augment
523+
- `windsurf` - Windsurf
524+
- `codex` - Codex
517525

518-
**Example: Using Cursor:**
526+
**Example:**
519527

520528
```bash
521-
# When using Cursor, exclude .cursor/ and .cursorrules (Cursor reads those itself)
522-
# But include rules from other agents and generic rules
523-
coding-context -a cursor /fix-bug
529+
# Use with write rules mode
530+
coding-context -a copilot -w fix-bug
524531
```
525532

526533
**How it works:**
527-
- The `-a` flag sets the target agent
528-
- The target agent's own paths are excluded (e.g., `.cursor/` for cursor)
529-
- Rules from other agents are included (e.g., `.opencode/`, `.github/copilot-instructions.md`)
530-
- Generic rules (from `.agents/rules`) are always included
531-
- The agent name is automatically added as a selector, so generic rules can filter themselves with `agent: cursor` in frontmatter
532-
533-
**Example generic rule with agent filtering:**
534-
535-
```markdown
536-
---
537-
agent: cursor
538-
---
539-
# This rule only applies when using Cursor
540-
Use Cursor-specific features...
541-
```
534+
- The `-a` flag sets the target agent value
535+
- The agent value is stored in the context for use by the `-w` flag
536+
- With `-w`, the agent determines where to write rules to the user's home directory
537+
- All rules are currently included regardless of agent value
542538

543539
**Agent field in task frontmatter:**
544540

@@ -551,15 +547,7 @@ agent: cursor
551547
# This task automatically sets the agent to cursor
552548
```
553549

554-
This is useful for tasks designed for specific agents, ensuring the correct agent context is used regardless of command-line flags.
555-
556-
**Use cases:**
557-
- **Avoid duplication**: The agent reads its own config, so exclude it from the context
558-
- **Cross-agent rules**: Include rules from other agents that might be relevant
559-
- **Generic rules**: Always include generic rules, with optional agent-specific filtering
560-
- **Task-specific agents**: Tasks can enforce a specific agent context
561-
562-
The exclusion happens before rule processing, so excluded paths are never loaded or counted toward token estimates.
550+
This is useful for tasks designed for specific agents, ensuring the correct agent is set for determining the write path with `-w`.
563551

564552
### Bootstrap Scripts
565553

docs/how-to/create-tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Please review the code changes with focus on:
2222
- Security implications
2323
```
2424

25-
Save as `.agents/tasks/code-review.md` (or `.agents/commands/code-review.md`).
25+
Save as `.agents/tasks/code-review.md`.
2626

2727
Use with:
2828
```bash
@@ -51,7 +51,7 @@ coding-context \
5151
-p feature_name="User Authentication" \
5252
-p requirements="OAuth2 support, secure password storage" \
5353
-p success_criteria="All tests pass, security audit clean" \
54-
/implement-feature
54+
implement-feature
5555
```
5656

5757
## Multiple Tasks with Selectors

docs/how-to/github-actions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ Use the `-C` flag to run from a different directory:
209209
```yaml
210210
- name: Assemble Context
211211
run: |
212-
coding-context -C ./backend -s languages=go /fix-bug > context.txt
212+
coding-context -C ./backend -s languages=go fix-bug > context.txt
213213
```
214214

215215
## Best Practices

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sudo curl -fsL -o /usr/local/bin/coding-context \
1919
sudo chmod +x /usr/local/bin/coding-context
2020

2121
# Use with an AI agent
22-
coding-context -p issue_key=BUG-123 -s languages=go /fix-bug | llm -m claude-3-5-sonnet-20241022
22+
coding-context -p issue_key=BUG-123 -s languages=go fix-bug | llm -m claude-3-5-sonnet-20241022
2323
```
2424

2525
## Documentation Structure

0 commit comments

Comments
 (0)