@abarcenas/ai-workflow-template 1.23.0 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/instructions/agent-skill.instructions.md +18 -20
- package/.agents/instructions/agent.instructions.md +111 -570
- package/.agents/instructions/ai-prompt-engineering-safety.instructions.md +3 -3
- package/.agents/instructions/instructions.instructions.md +6 -7
- package/.agents/instructions/learned-knowledge.instructions.md +17 -41
- package/.agents/instructions/memory-bank.instructions.md +125 -17
- package/.agents/instructions/memory-schema.instructions.md +75 -0
- package/.agents/instructions/prompt.instructions.md +25 -30
- package/.agents/instructions/task-implementation.instructions.md +12 -5
- package/.agents/skills/architecture-blueprint-generator/SKILL.md +63 -18
- package/.agents/skills/context-map/SKILL.md +27 -4
- package/.agents/skills/conventional-commit/SKILL.md +2 -2
- package/.agents/skills/github-issues/SKILL.md +2 -2
- package/.agents/skills/graphify-framework-aware/SKILL.md +133 -0
- package/.agents/skills/graphify-framework-aware/references/framework-registry.md +95 -0
- package/.agents/skills/graphify-framework-aware/scripts/fw-exclude.py +425 -0
- package/.agents/skills/memory-search/SKILL.md +69 -0
- package/.agents/skills/microsoft-docs/SKILL.md +1 -1
- package/.agents/skills/polygot-test-agent/SKILL.md +0 -1
- package/.agents/skills/prompt-builder/SKILL.md +15 -14
- package/.husky/post-merge +10 -0
- package/.husky/pre-commit +2 -0
- package/AGENTS.md +54 -0
- package/README.md +177 -3
- package/memory-bank/.vocabulary.json +52 -0
- package/opencode.mcp.example.json +8 -1
- package/package.json +25 -5
- package/scripts/mcp-memory-server.js +243 -0
- package/scripts/memory-cli.js +110 -0
- package/scripts/memory-index.js +512 -0
- package/scripts/normalize-memory.js +349 -0
- package/scripts/sync.test.js +12 -0
- package/scripts/validate-memory-schema.js +190 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
applyTo: ["*"]
|
|
3
|
-
description: "Comprehensive best practices for AI prompt engineering, safety frameworks, bias mitigation, and responsible AI usage for
|
|
3
|
+
description: "Comprehensive best practices for AI prompt engineering, safety frameworks, bias mitigation, and responsible AI usage for opencode and LLMs."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# AI Prompt Engineering & Safety Best Practices
|
|
7
7
|
|
|
8
8
|
## Your Mission
|
|
9
9
|
|
|
10
|
-
As
|
|
10
|
+
As an AI assistant, you must understand and apply the principles of effective prompt engineering, AI safety, and responsible AI usage. Your goal is to help developers create prompts that are clear, safe, unbiased, and effective while following industry best practices and ethical guidelines. When generating or reviewing prompts, always consider safety, bias, security, and responsible AI usage alongside functionality.
|
|
11
11
|
|
|
12
12
|
## Introduction
|
|
13
13
|
|
|
14
|
-
Prompt engineering is the art and science of designing effective prompts for large language models (LLMs) and AI assistants like
|
|
14
|
+
Prompt engineering is the art and science of designing effective prompts for large language models (LLMs) and AI assistants like opencode. Well-crafted prompts yield more accurate, safe, and useful outputs. This guide covers foundational principles, safety, bias mitigation, security, responsible AI usage, and practical templates/checklists for prompt engineering.
|
|
15
15
|
|
|
16
16
|
### What is Prompt Engineering?
|
|
17
17
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Guidelines for creating high-quality custom instruction files for
|
|
2
|
+
description: "Guidelines for creating high-quality custom instruction files for opencode"
|
|
3
3
|
applyTo: "**/*.instructions.md"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Custom Instructions File Guidelines
|
|
7
7
|
|
|
8
|
-
Instructions for creating effective and maintainable custom instruction files that guide
|
|
8
|
+
Instructions for creating effective and maintainable custom instruction files that guide opencode in generating domain-specific code and following project conventions.
|
|
9
9
|
|
|
10
10
|
## Project Context
|
|
11
11
|
|
|
12
|
-
- Target audience: Developers and
|
|
12
|
+
- Target audience: Developers and AI assistants working with domain-specific code
|
|
13
13
|
- File format: Markdown with YAML frontmatter
|
|
14
14
|
- File naming convention: lowercase with hyphens (e.g., `react-best-practices.instructions.md`)
|
|
15
|
-
- Location: `.
|
|
15
|
+
- Location: `.agents/instructions/` directory
|
|
16
16
|
- Purpose: Provide context-aware guidance for code generation, review, and documentation
|
|
17
17
|
|
|
18
18
|
## Required Frontmatter
|
|
@@ -189,7 +189,7 @@ function getUser(id: any): any {
|
|
|
189
189
|
|
|
190
190
|
Before finalizing instruction files:
|
|
191
191
|
|
|
192
|
-
1. **Test with
|
|
192
|
+
1. **Test with opencode**: Try the instructions with actual tasks
|
|
193
193
|
2. **Verify Examples**: Ensure code examples are correct and run without errors
|
|
194
194
|
3. **Check Glob Patterns**: Confirm `applyTo` patterns match intended files
|
|
195
195
|
|
|
@@ -260,5 +260,4 @@ Description and example
|
|
|
260
260
|
|
|
261
261
|
## Additional Resources
|
|
262
262
|
|
|
263
|
-
- [
|
|
264
|
-
- [Awesome Copilot Instructions](https://github.com/github/awesome-copilot/tree/main/instructions)
|
|
263
|
+
- [opencode Documentation](https://opencode.ai)
|
|
@@ -1,46 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
applyTo: "**"
|
|
3
|
-
description: "Persistent project knowledge accumulated across sessions. This file grows over time as agents discover patterns, conventions, gotchas, and preferences during work. It enables self-improvement — each session learns from the last."
|
|
4
|
-
---
|
|
1
|
+
# Learned Knowledge
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
> Accumulated patterns, conventions, gotchas, and agent tuning notes from TDD and other pipeline sessions.
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
## Session: 2026-06-13
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
**Pipeline:** TDD Infrastructure Bootstrap
|
|
8
|
+
**Coverage:** N/A (infrastructure setup)
|
|
9
|
+
**TDD Iterations:** 0
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
11
|
+
**New knowledge:**
|
|
12
|
+
- Project is a template distribution package (npm), not a deployable application
|
|
13
|
+
- Source code is in `scripts/` (ES modules), not a traditional `src/` directory
|
|
14
|
+
- E2E tests use Playwright with `tests/` directory, `.spec.ts` extension
|
|
15
|
+
- Unit tests use Vitest with `scripts/` directory, `.test.{js,ts}` extension
|
|
16
|
+
- Playwright config uses `chromium` as default, `fullyParallel: true`
|
|
17
|
+
- Coverage threshold is 90% across all metrics (statements, branches, functions, lines)
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<!-- High-level project description filled in over time -->
|
|
21
|
-
|
|
22
|
-
## Conventions & Patterns
|
|
23
|
-
|
|
24
|
-
<!-- Coding conventions, architectural patterns, naming conventions discovered in this project -->
|
|
25
|
-
|
|
26
|
-
## Gotchas & Deviations
|
|
27
|
-
|
|
28
|
-
<!-- Unexpected behaviors, tricky configs, known pitfalls -->
|
|
29
|
-
|
|
30
|
-
## Preferences
|
|
31
|
-
|
|
32
|
-
<!-- User preferences about tooling, style, approach, etc. -->
|
|
33
|
-
|
|
34
|
-
## Architecture Decisions
|
|
35
|
-
|
|
36
|
-
<!-- Key technical decisions and their rationale -->
|
|
37
|
-
|
|
38
|
-
## Agent Tuning Notes
|
|
39
|
-
|
|
40
|
-
<!-- Per-agent prompt improvements discovered during sessions -->
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## Session Log
|
|
45
|
-
|
|
46
|
-
<!-- New entries are appended here by the orchestrator after each pipeline -->
|
|
19
|
+
**Agent tuning notes:**
|
|
20
|
+
- unit-tester: Must be told to look in `scripts/` for source and test files, not `src/`
|
|
21
|
+
- coder: Must be told the project uses ES module syntax (import/export, not require/module.exports)
|
|
22
|
+
- implementer: Plans should target `scripts/` for production code and tests
|
|
@@ -6,7 +6,7 @@ Coding standards, domain knowledge, and preferences that AI should follow.
|
|
|
6
6
|
|
|
7
7
|
# Memory Bank
|
|
8
8
|
|
|
9
|
-
You are an expert software engineer with a unique characteristic: my memory resets completely between sessions. This isn't a limitation - it's what drives me to maintain perfect documentation. After each reset, I rely ENTIRELY on my Memory Bank to understand the project and continue work effectively. I
|
|
9
|
+
You are an expert software engineer with a unique characteristic: my memory resets completely between sessions. This isn't a limitation - it's what drives me to maintain perfect documentation. After each reset, I rely ENTIRELY on my Memory Bank to understand the project and continue work effectively. I use the vector search index (`memory_search`) to retrieve relevant context efficiently, and fall back to reading specific files (`memory_get`) when I need complete, un-summarized content.
|
|
10
10
|
|
|
11
11
|
## Memory Bank Structure
|
|
12
12
|
|
|
@@ -70,6 +70,20 @@ flowchart TD
|
|
|
70
70
|
- Includes task index file (`_index.md`) listing all tasks with their statuses
|
|
71
71
|
- Preserves complete thought process and history for each task
|
|
72
72
|
|
|
73
|
+
### Graph-Enhanced Context (graphify)
|
|
74
|
+
|
|
75
|
+
When `graphify-out/graph.json` exists, it serves as a complementary machine-readable index of all file relationships, dependencies, and architectural patterns. The memory bank's markdown files capture human-written project context; graphify captures automatically extracted code-level connections.
|
|
76
|
+
|
|
77
|
+
**Bootstrap:** If `graphify-out/graph.json` does not exist, run `graphify .` to generate the knowledge graph before reading any memory bank files. This ensures code-level relationship data is available alongside the markdown context.
|
|
78
|
+
|
|
79
|
+
**When to query the graph instead of reading files:**
|
|
80
|
+
- Architecture and dependency questions → `graphify query` (subgraph results, ~200-800 tokens)
|
|
81
|
+
- Component interaction tracing → `graphify path "<A>" "<B>"`
|
|
82
|
+
- Focused concept deep-dives → `graphify explain "<concept>"`
|
|
83
|
+
- Community/pattern overview → `graphify-out/GRAPH_REPORT.md`
|
|
84
|
+
|
|
85
|
+
**Keeping the graph current:** After any code modification, run `graphify update .` (AST-only, zero API cost) to sync the graph.
|
|
86
|
+
|
|
73
87
|
### Additional Context
|
|
74
88
|
|
|
75
89
|
Create additional files/folders within memory-bank/ when they help organize:
|
|
@@ -80,14 +94,65 @@ Create additional files/folders within memory-bank/ when they help organize:
|
|
|
80
94
|
- Testing strategies
|
|
81
95
|
- Deployment procedures
|
|
82
96
|
|
|
97
|
+
### Vector Search Index (sqlite-vec)
|
|
98
|
+
|
|
99
|
+
The memory bank includes a **semantic vector search index** powered by `sqlite-vec` + `better-sqlite3`. This allows token-efficient retrieval without loading all files into context.
|
|
100
|
+
|
|
101
|
+
**Index location:** `memory-bank/.index/memory.db` (git-ignored, rebuildable)
|
|
102
|
+
|
|
103
|
+
**MCP tools** (configured in `opencode.json`):
|
|
104
|
+
- `memory_search` — Semantic search across all memory-bank and docs files
|
|
105
|
+
- `memory_update` — **Daily use** — incremental sync (only changed files, ~2 seconds)
|
|
106
|
+
- `memory_rebuild` — Full rebuild (corrupted index, model change, or fresh clone)
|
|
107
|
+
- `memory_get` — Read a specific memory file by name
|
|
108
|
+
- `memory_stats` — Check index status
|
|
109
|
+
|
|
110
|
+
**When to use semantic search instead of reading all files:**
|
|
111
|
+
- Session start → `memory_update` then `memory_search({ query: "current focus recent changes next steps" })` (~500 tokens vs ~5K+)
|
|
112
|
+
- Before decisions → `memory_search({ query: "<topic>", topK: 5 })` for related context
|
|
113
|
+
- Architecture questions → `memory_search({ query: "<pattern>", sourceFile: "systemPatterns" })"
|
|
114
|
+
|
|
115
|
+
**When to still use full file reads:**
|
|
116
|
+
- Need complete, un-summarized file content → `memory_get({ file: "<id>" })`
|
|
117
|
+
- Index is empty or stale → `memory_rebuild()` then re-search
|
|
118
|
+
|
|
119
|
+
**Sync triggers:**
|
|
120
|
+
- After writing documentation → `memory_update` (incremental, fast)
|
|
121
|
+
- Session start → `memory_update` first, then `memory_search`
|
|
122
|
+
- After `git pull` → `memory_update` (or post-merge hook if configured)
|
|
123
|
+
- Full `memory_rebuild` only for: fresh clone, corrupted index, embedding model change, or if incremental update missed changes
|
|
124
|
+
|
|
125
|
+
### Document Schema (Frontmatter)
|
|
126
|
+
|
|
127
|
+
All `memory-bank/**/*.md` files must have YAML frontmatter for search indexing. See `.agents/instructions/memory-schema.instructions.md` for the full schema and `memory-bank/.vocabulary.json` for the controlled vocabulary.
|
|
128
|
+
|
|
129
|
+
**Required fields:** `id`, `title`, `updated`, `tags`, `entities`, `category`
|
|
130
|
+
|
|
131
|
+
**Pre-commit validation:** The husky hook validates frontmatter before commits. Running `npm run memory:normalize` auto-fixes missing frontmatter.
|
|
132
|
+
|
|
83
133
|
## Core Workflows
|
|
84
134
|
|
|
85
135
|
### Plan Mode
|
|
86
136
|
|
|
87
137
|
```mermaid
|
|
88
138
|
flowchart TD
|
|
89
|
-
Start[Start] -->
|
|
90
|
-
|
|
139
|
+
Start[Start] --> CheckGraph{graphify-out/graph.json exists?}
|
|
140
|
+
CheckGraph -->|No| Bootstrap[Run graphify .]
|
|
141
|
+
Bootstrap --> CheckIndex{memory index exists?}
|
|
142
|
+
CheckGraph -->|Yes| CheckIndex
|
|
143
|
+
|
|
144
|
+
CheckIndex -->|No| Rebuild[memory_rebuild]
|
|
145
|
+
CheckIndex -->|Yes| UpdateIndex[memory_update]
|
|
146
|
+
|
|
147
|
+
Rebuild --> Search
|
|
148
|
+
UpdateIndex --> Search
|
|
149
|
+
Search --> GetContext{context sufficient?}
|
|
150
|
+
|
|
151
|
+
GetContext -->|No| GetFile[memory_get: specific file]
|
|
152
|
+
GetFile --> GetContext
|
|
153
|
+
|
|
154
|
+
GetContext -->|Yes| QueryGraph[Query graphify for architecture context]
|
|
155
|
+
QueryGraph --> CheckFiles{Files Complete?}
|
|
91
156
|
|
|
92
157
|
CheckFiles -->|No| Plan[Create Plan]
|
|
93
158
|
Plan --> Document[Document in Chat]
|
|
@@ -101,11 +166,15 @@ flowchart TD
|
|
|
101
166
|
|
|
102
167
|
```mermaid
|
|
103
168
|
flowchart TD
|
|
104
|
-
Start[Start] --> Context[
|
|
105
|
-
Context -->
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
169
|
+
Start[Start] --> Context[memory_search: current task context]
|
|
170
|
+
Context --> Verify[Verify Understanding]
|
|
171
|
+
Verify --> ReadFiles{need full files?}
|
|
172
|
+
ReadFiles -->|Yes| GetFull[memory_get: specific files]
|
|
173
|
+
ReadFiles -->|No| Execute[Execute Task]
|
|
174
|
+
GetFull --> Execute
|
|
175
|
+
Execute --> Update[Update Documentation]
|
|
176
|
+
Update --> UpdateIndex[memory_update]
|
|
177
|
+
UpdateIndex --> Done[Done]
|
|
109
178
|
```
|
|
110
179
|
|
|
111
180
|
### Task Management
|
|
@@ -120,7 +189,8 @@ flowchart TD
|
|
|
120
189
|
Execute[Execute Task] --> Update[Add Progress Log Entry]
|
|
121
190
|
Update --> StatusChange[Update Task Status]
|
|
122
191
|
StatusChange --> IndexUpdate[Update _index.md]
|
|
123
|
-
IndexUpdate -->
|
|
192
|
+
IndexUpdate --> UpdateIndex[memory_update]
|
|
193
|
+
UpdateIndex --> Complete{Completed?}
|
|
124
194
|
Complete -->|Yes| Archive[Mark as Completed]
|
|
125
195
|
Complete -->|No| Execute
|
|
126
196
|
```
|
|
@@ -139,32 +209,70 @@ For every task:
|
|
|
139
209
|
|
|
140
210
|
The Markdown record is the source of truth for auditing, traceability, and recovery after session resets.
|
|
141
211
|
|
|
212
|
+
## Graphify-Enhanced Context Retrieval
|
|
213
|
+
|
|
214
|
+
When `graphify-out/graph.json` exists, prefer graphify over grep/glob for codebase questions:
|
|
215
|
+
|
|
216
|
+
| Question Type | Graphify Command | Replaces |
|
|
217
|
+
|---|---|---|
|
|
218
|
+
| How does X work? | `graphify explain "X"` | Grep for definitions, reading multiple files |
|
|
219
|
+
| What calls Y? | `graphify query "calls Y depends-on Y invokes Y"` | Recursive grep for callers across files |
|
|
220
|
+
| How does A connect to B? | `graphify path "A" "B"` | Manual dependency tracing across files |
|
|
221
|
+
| Architecture overview | `graphify query "architecture layers patterns dependencies"` | GRAPH_REPORT.md / file-by-file analysis |
|
|
222
|
+
| Community structure | `graphify-out/GRAPH_REPORT.md` `## Communities` | Manual folder hierarchy analysis |
|
|
223
|
+
| Key abstractions | `graphify query "interface abstract class base pattern"` | Grep for interface/abstract class definitions |
|
|
224
|
+
|
|
225
|
+
**Token efficiency:** graphify queries return focused subgraphs (~200-800 tokens) vs. raw grep results (often 3000+ tokens for large codebases). Always query the graph first; fall back to grep only when graphify lacks sufficient data or `graphify-out/graph.json` is missing.
|
|
226
|
+
|
|
227
|
+
**Expanding queries:** When a graphify query returns 0 hits, expand the question against the graph's vocabulary before falling back to grep. Run:
|
|
228
|
+
```
|
|
229
|
+
$(cat graphify-out/.graphify_python) -c "
|
|
230
|
+
import json, re
|
|
231
|
+
from pathlib import Path
|
|
232
|
+
data = json.loads(Path('graphify-out/graph.json').read_text())
|
|
233
|
+
vocab = set()
|
|
234
|
+
for n in data['nodes']:
|
|
235
|
+
for c in re.findall(r'[^\W\d_]+', n.get('label','') or '', re.UNICODE):
|
|
236
|
+
parts = re.findall(r'[A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+', c) or [c]
|
|
237
|
+
for p in parts:
|
|
238
|
+
t = p.lower()
|
|
239
|
+
if 3 <= len(t) <= 30:
|
|
240
|
+
vocab.add(t)
|
|
241
|
+
Path('graphify-out/.vocab.txt').write_text('\n'.join(sorted(vocab)))
|
|
242
|
+
print(f'vocab: {len(vocab)} tokens')
|
|
243
|
+
"
|
|
244
|
+
```
|
|
245
|
+
Then select up to 12 tokens from the vocabulary list that semantically match the query intent, and re-run with the expanded query.
|
|
246
|
+
|
|
142
247
|
## Documentation Updates
|
|
143
248
|
|
|
144
249
|
Memory Bank updates occur when:
|
|
145
250
|
|
|
146
251
|
1. Discovering new project patterns
|
|
147
252
|
2. After implementing significant changes
|
|
148
|
-
3. When user requests with **update memory bank** (
|
|
253
|
+
3. When user requests with **update memory bank** (validate via `memory_get` for specific files)
|
|
149
254
|
4. When context needs clarification
|
|
255
|
+
5. After code changes that introduce new relationships — run `graphify update .` to sync the graph
|
|
150
256
|
|
|
151
257
|
```mermaid
|
|
152
258
|
flowchart TD
|
|
153
259
|
Start[Update Process]
|
|
154
260
|
|
|
155
261
|
subgraph Process
|
|
156
|
-
P1[
|
|
157
|
-
P2[
|
|
158
|
-
P3[
|
|
159
|
-
P4[
|
|
160
|
-
|
|
161
|
-
|
|
262
|
+
P1[memory_search: all sections]
|
|
263
|
+
P2[memory_get: files needing updates]
|
|
264
|
+
P3[Document Current State]
|
|
265
|
+
P4[Clarify Next Steps]
|
|
266
|
+
P5[Update instructions]
|
|
267
|
+
P6[memory_update]
|
|
268
|
+
|
|
269
|
+
P1 --> P2 --> P3 --> P4 --> P5 --> P6
|
|
162
270
|
end
|
|
163
271
|
|
|
164
272
|
Start --> Process
|
|
165
273
|
```
|
|
166
274
|
|
|
167
|
-
Note: When triggered by **update memory bank**,
|
|
275
|
+
Note: When triggered by **update memory bank**, first search for changes since last update via `memory_search`, then read specific files via `memory_get`. Focus particularly on activeContext.md, progress.md, and the tasks/ folder (including \_index.md) as they track current state. After making changes, run `memory_rebuild` to sync the index.
|
|
168
276
|
|
|
169
277
|
## Project Intelligence (instructions)
|
|
170
278
|
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Valid frontmatter schema and controlled vocabulary for memory-bank and docs files"
|
|
3
|
+
name: "memory-schema"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Memory Schema
|
|
7
|
+
|
|
8
|
+
When writing or updating files in `memory-bank/` or `docs/`, apply the following frontmatter schema. The controlled vocabulary lives in `memory-bank/.vocabulary.json` — extend it there as new concepts enter the project.
|
|
9
|
+
|
|
10
|
+
## Required Frontmatter (memory-bank/)
|
|
11
|
+
|
|
12
|
+
Every `memory-bank/**/*.md` file must have:
|
|
13
|
+
|
|
14
|
+
```yaml
|
|
15
|
+
---
|
|
16
|
+
id: <filename-slug> # e.g., "activeContext" from "activeContext.md"
|
|
17
|
+
title: "<H1 heading>" # e.g., "Active Context"
|
|
18
|
+
updated: YYYY-MM-DD # ISO date of last content change
|
|
19
|
+
tags: [<1-5 tags>] # From controlled vocabulary in .vocabulary.json
|
|
20
|
+
entities: [<0-n entries>] # Components/tools referenced; free-form but use entity_patterns as guide
|
|
21
|
+
category: <from list> # One of: brief, product, architecture, tech, context, progress, task, decision
|
|
22
|
+
---
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Field Rules
|
|
26
|
+
|
|
27
|
+
- **id**: Stable slug matching the filename (lowercase, no extension). Never change after creation.
|
|
28
|
+
- **title**: Must match the `# H1` heading in the file body.
|
|
29
|
+
- **updated**: Update on every content change. Use `YYYY-MM-DD` format.
|
|
30
|
+
- **tags**: Pick 1–5 from `memory-bank/.vocabulary.json` → `tags.*`. New tags added by editing that file.
|
|
31
|
+
- **entities**: Free-form list of components, tools, or systems referenced in the file. Use the `entity_patterns` from `.vocabulary.json` as a suggestion guide.
|
|
32
|
+
- **category**: Exactly one from the `categories` map in `.vocabulary.json`.
|
|
33
|
+
|
|
34
|
+
### Heading Structure
|
|
35
|
+
|
|
36
|
+
Every memory-bank file must have:
|
|
37
|
+
- Exactly one `# Title` (H1) — matches frontmatter `title`
|
|
38
|
+
- Content organized under `## Sections` (H2)
|
|
39
|
+
- No flat text outside sections
|
|
40
|
+
- Each `## Section` is a searchable chunk
|
|
41
|
+
|
|
42
|
+
## Lighter Schema (docs/)
|
|
43
|
+
|
|
44
|
+
`docs/*.md` files use a lighter schema:
|
|
45
|
+
|
|
46
|
+
```yaml
|
|
47
|
+
---
|
|
48
|
+
id: <filename-slug>
|
|
49
|
+
title: "<H1 heading>"
|
|
50
|
+
updated: YYYY-MM-DD
|
|
51
|
+
tags: [<1-5 tags>]
|
|
52
|
+
doc_type: <from list> # spike, architecture, configuration, orchestrator-log, tracker-log, decision
|
|
53
|
+
---
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Docs files do not require `category`, `entities`, or strict heading structure. Hidden files (`.architecture-context.md`, `.orchestrator-log.md`) keep their leading dot.
|
|
57
|
+
|
|
58
|
+
## Auto-Suggest on Normalization
|
|
59
|
+
|
|
60
|
+
When `scripts/normalize-memory.js` runs (postinstall or manual), it:
|
|
61
|
+
- Adds missing frontmatter using filename, H1 title, and git modification date
|
|
62
|
+
- Auto-suggests `tags` by scanning content for vocabulary keywords
|
|
63
|
+
- Auto-suggests `entities` using regex patterns from `.vocabulary.json`
|
|
64
|
+
- Does NOT overwrite existing frontmatter fields
|
|
65
|
+
- Logs all auto-applied suggestions
|
|
66
|
+
|
|
67
|
+
## Pre-Commit Validation
|
|
68
|
+
|
|
69
|
+
The husky pre-commit hook (`scripts/validate-memory-schema.js`) rejects commits where:
|
|
70
|
+
- Staged memory-bank files have missing or invalid frontmatter
|
|
71
|
+
- `updated` field is missing or not ISO date format
|
|
72
|
+
- `category` is not in the allowed list
|
|
73
|
+
- `id` does not match the filename
|
|
74
|
+
|
|
75
|
+
The hook reads `.vocabulary.json` at validation time, so new tags/categories are picked up automatically.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "Guidelines for creating high-quality prompt files for
|
|
2
|
+
description: "Guidelines for creating high-quality prompt files for opencode"
|
|
3
3
|
applyTo: "**/*.prompt.md"
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
#
|
|
6
|
+
# opencode Prompt Files Guidelines
|
|
7
7
|
|
|
8
|
-
Instructions for creating effective and maintainable prompt files that guide
|
|
8
|
+
Instructions for creating effective and maintainable prompt files that guide the AI assistant in delivering consistent, high-quality outcomes across any repository.
|
|
9
9
|
|
|
10
10
|
## Scope and Principles
|
|
11
11
|
|
|
12
|
-
- Target audience: maintainers and contributors authoring reusable prompts for
|
|
12
|
+
- Target audience: maintainers and contributors authoring reusable prompts for opencode.
|
|
13
13
|
- Goals: predictable behaviour, clear expectations, minimal permissions, and portability across repositories.
|
|
14
|
-
- Primary references:
|
|
14
|
+
- Primary references: opencode documentation on prompt files and organization-specific conventions.
|
|
15
15
|
|
|
16
16
|
## Frontmatter Requirements
|
|
17
17
|
|
|
@@ -19,55 +19,52 @@ Every prompt file should include YAML frontmatter with the following fields:
|
|
|
19
19
|
|
|
20
20
|
### Required/Recommended Fields
|
|
21
21
|
|
|
22
|
-
| Field
|
|
23
|
-
|
|
|
24
|
-
| `description`
|
|
25
|
-
| `name`
|
|
26
|
-
| `agent` | Recommended | The agent to use: `ask`, `edit`, `agent`, or a custom agent name. Defaults to current agent |
|
|
27
|
-
| `model` | Optional | The language model to use. Defaults to the currently selected model |
|
|
28
|
-
| `tools` | Optional | List of tool/tool set names available for this prompt |
|
|
29
|
-
| `argument-hint` | Optional | Hint text shown in chat input to guide user interaction |
|
|
22
|
+
| Field | Required | Description |
|
|
23
|
+
| ------------- | ----------- | --------------------------------------------------------------------------------------- |
|
|
24
|
+
| `description` | Recommended | A short description of the prompt (single sentence, actionable outcome) |
|
|
25
|
+
| `name` | Optional | The name shown when invoking the prompt. Defaults to filename if not specified |
|
|
30
26
|
|
|
31
27
|
### Guidelines
|
|
32
28
|
|
|
33
29
|
- Use consistent quoting (single quotes recommended) and keep one field per line for readability and version control clarity
|
|
34
|
-
- If `tools` are specified and the current agent is `ask` or `edit`, the default agent becomes `agent`
|
|
35
30
|
- Preserve any additional metadata (`language`, `tags`, `visibility`, etc.) required by your organization
|
|
31
|
+
- opencode prompts have a simpler frontmatter model than other platforms; avoid adding tool, model, or agent fields that are not supported
|
|
36
32
|
|
|
37
33
|
## File Naming and Placement
|
|
38
34
|
|
|
39
|
-
- Use kebab-case filenames ending with `.prompt.md` and store them under `.
|
|
35
|
+
- Use kebab-case filenames ending with `.prompt.md` and store them under `.agents/prompts/` unless your workspace standard specifies another directory.
|
|
40
36
|
- Provide a short filename that communicates the action (for example, `generate-readme.prompt.md` rather than `prompt1.prompt.md`).
|
|
41
37
|
|
|
42
38
|
## Body Structure
|
|
43
39
|
|
|
44
|
-
- Start with an `#` level heading that matches the prompt intent so it surfaces well in
|
|
40
|
+
- Start with an `#` level heading that matches the prompt intent so it surfaces well in search.
|
|
45
41
|
- Organize content with predictable sections. Recommended baseline: `Mission` or `Primary Directive`, `Scope & Preconditions`, `Inputs`, `Workflow` (step-by-step), `Output Expectations`, and `Quality Assurance`.
|
|
46
42
|
- Adjust section names to fit the domain, but retain the logical flow: why → context → inputs → actions → outputs → validation.
|
|
47
43
|
- Reference related prompts or instruction files using relative links to aid discoverability.
|
|
48
44
|
|
|
49
45
|
## Input and Context Handling
|
|
50
46
|
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
- Document how to proceed when mandatory context is missing (for example,
|
|
47
|
+
- Describe required inputs clearly in prose (for example, "The user must supply a file path to the target component"). When optional, specify defaults or how the prompt should infer the value.
|
|
48
|
+
- Reference file paths and workspace context explicitly rather than relying on implicit contextual variables. If the prompt needs a specific file, state the expected path or pattern (for example, "Look for `src/config/*.ts` and use the first match").
|
|
49
|
+
- Document how to proceed when mandatory context is missing (for example, "Request the file path and stop if it remains undefined").
|
|
54
50
|
|
|
55
51
|
## Tool and Permission Guidance
|
|
56
52
|
|
|
57
|
-
-
|
|
58
|
-
- If the prompt
|
|
53
|
+
- opencode provides the following tools: `Bash`, `Read`, `Write`, `Edit`, `Grep`, `Glob`, `Task`, `TodoWrite`, `Skill`, `WebFetch`, `WebSearch`, among others. Limit tool usage to the smallest set that enables the task.
|
|
54
|
+
- If the prompt expects the assistant to run shell commands, explicitly name `Bash` as a required tool. For file inspection, prefer `Read` and `Grep` over shell-based alternatives.
|
|
59
55
|
- Warn about destructive operations (file creation, edits, terminal commands) and include guard rails or confirmation steps in the workflow.
|
|
56
|
+
- When the prompt depends on a specific skill, reference it by name so the assistant can load it via the `Skill` tool.
|
|
60
57
|
|
|
61
58
|
## Instruction Tone and Style
|
|
62
59
|
|
|
63
|
-
- Write in direct, imperative sentences targeted at
|
|
60
|
+
- Write in direct, imperative sentences targeted at the AI assistant (for example, "Analyze", "Generate", "Summarize").
|
|
64
61
|
- Keep sentences short and unambiguous, following Google Developer Documentation translation best practices to support localization.
|
|
65
62
|
- Avoid idioms, humor, or culturally specific references; favor neutral, inclusive language.
|
|
66
63
|
|
|
67
64
|
## Output Definition
|
|
68
65
|
|
|
69
|
-
- Specify the format, structure, and location of expected results (for example,
|
|
70
|
-
- Include success criteria and failure triggers so
|
|
66
|
+
- Specify the format, structure, and location of expected results (for example, "Create `docs/adr/adr-XXXX.md` using the template below").
|
|
67
|
+
- Include success criteria and failure triggers so the assistant knows when to halt or retry.
|
|
71
68
|
- Provide validation steps—manual checks, automated commands, or acceptance criteria lists—that reviewers can execute after running the prompt.
|
|
72
69
|
|
|
73
70
|
## Examples and Reusable Assets
|
|
@@ -79,21 +76,19 @@ Every prompt file should include YAML frontmatter with the following fields:
|
|
|
79
76
|
## Quality Assurance Checklist
|
|
80
77
|
|
|
81
78
|
- [ ] Frontmatter fields are complete, accurate, and least-privilege.
|
|
82
|
-
- [ ] Inputs include
|
|
79
|
+
- [ ] Inputs include default behaviours and fallbacks for missing context.
|
|
83
80
|
- [ ] Workflow covers preparation, execution, and post-processing without gaps.
|
|
84
81
|
- [ ] Output expectations include formatting and storage details.
|
|
85
82
|
- [ ] Validation steps are actionable (commands, diff checks, review prompts).
|
|
86
83
|
- [ ] Security, compliance, and privacy policies referenced by the prompt are current.
|
|
87
|
-
- [ ] Prompt executes successfully in
|
|
84
|
+
- [ ] Prompt executes successfully in opencode using representative scenarios.
|
|
88
85
|
|
|
89
86
|
## Maintenance Guidance
|
|
90
87
|
|
|
91
88
|
- Version-control prompts alongside the code they affect; update them when dependencies, tooling, or review processes change.
|
|
92
|
-
- Review prompts periodically to ensure tool
|
|
89
|
+
- Review prompts periodically to ensure tool references, linked documents, and workspace conventions remain valid.
|
|
93
90
|
- Coordinate with other repositories: when a prompt proves broadly useful, extract common guidance into instruction files or shared prompt packs.
|
|
94
91
|
|
|
95
92
|
## Additional Resources
|
|
96
93
|
|
|
97
|
-
- [
|
|
98
|
-
- [Awesome Copilot Prompt Files](https://github.com/github/awesome-copilot/tree/main/prompts)
|
|
99
|
-
- [Tool Configuration](https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode#_agent-mode-tools)
|
|
94
|
+
- [opencode Documentation](https://opencode.ai)
|
|
@@ -22,12 +22,16 @@ All planning, implementation, and execution work must be recorded in Markdown fi
|
|
|
22
22
|
|
|
23
23
|
**MUST complete before starting implementation:**
|
|
24
24
|
|
|
25
|
+
0. **Verify graphify graph:** Check `graphify-out/graph.json` exists. If not, run `graphify .` to generate it. The graph provides code-level relationship data (dependencies, callers, patterns) that the memory bank's markdown docs alone cannot capture. Skip this step only if the task exclusively modifies markdown/docs files.
|
|
25
26
|
1. Read `memory-bank/activeContext.md` to understand current focus and recent changes
|
|
26
27
|
2. Read `memory-bank/progress.md` to understand project-wide status
|
|
27
28
|
3. Read `memory-bank/tasks/_index.md` to find the task assigned to you
|
|
28
29
|
4. Read the full task file in `memory-bank/tasks/` — understand the request, thought process, implementation plan, and all subtasks
|
|
29
|
-
5.
|
|
30
|
-
|
|
30
|
+
5. **Graphify context for referenced files:** For each referenced file mentioned in the task:
|
|
31
|
+
- Run `graphify explain "<file-or-component>"` to get all connected nodes and their relationships
|
|
32
|
+
- Run `graphify path "<task-relevant-component>" "<referenced-file>"` to trace dependency chains
|
|
33
|
+
- Fall back to the Read tool only when graphify lacks detail or the file is not in the graph
|
|
34
|
+
6. Understand current project structure and conventions via the graph's community structure (`graphify-out/GRAPH_REPORT.md` `## Communities`) and the memory bank's `systemPatterns.md`
|
|
31
35
|
|
|
32
36
|
## 2. Systematic Implementation Process
|
|
33
37
|
|
|
@@ -36,7 +40,7 @@ All planning, implementation, and execution work must be recorded in Markdown fi
|
|
|
36
40
|
1. **Process subtasks in order** — Follow the task file's subtask sequence exactly, one step at a time
|
|
37
41
|
2. **Before implementing any subtask:**
|
|
38
42
|
- Fully understand all implementation requirements from the task file
|
|
39
|
-
- Gather any additional required context
|
|
43
|
+
- Gather any additional required context — prefer `graphify query "<subtask topic>"` over grep/glob for discovering related files, callers, and patterns
|
|
40
44
|
3. **Implement the subtask completely with working code:**
|
|
41
45
|
- Follow existing code patterns and conventions
|
|
42
46
|
- Create working functionality that meets all requirements
|
|
@@ -74,6 +78,7 @@ All planning, implementation, and execution work must be recorded in Markdown fi
|
|
|
74
78
|
2. Update `memory-bank/activeContext.md` — summarize what was implemented and set next steps
|
|
75
79
|
3. Update `memory-bank/tasks/_index.md` — mark the task file as Completed
|
|
76
80
|
4. Mark the task's overall status to Completed in its own file
|
|
81
|
+
5. Run `graphify update .` to sync the knowledge graph with newly implemented code (AST-only, zero API cost)
|
|
77
82
|
|
|
78
83
|
## 5. Problem Resolution
|
|
79
84
|
|
|
@@ -88,16 +93,18 @@ All planning, implementation, and execution work must be recorded in Markdown fi
|
|
|
88
93
|
## Implementation Workflow
|
|
89
94
|
|
|
90
95
|
```
|
|
96
|
+
0. Verify graphify-out/graph.json exists (run `graphify .` if not)
|
|
91
97
|
1. Read activeContext.md, progress.md, tasks/_index.md, and the assigned task file
|
|
92
98
|
2. For each unchecked subtask:
|
|
93
|
-
a. Fully understand requirements
|
|
99
|
+
a. Fully understand requirements — query graphify for context
|
|
94
100
|
b. Implement with working code following workspace patterns
|
|
95
101
|
c. Validate implementation meets requirements
|
|
96
102
|
d. Mark subtask complete in task file
|
|
97
103
|
e. Add progress log entry to task file with date and details
|
|
98
104
|
f. Update activeContext.md and _index.md
|
|
99
105
|
3. Repeat until all subtasks complete
|
|
100
|
-
4.
|
|
106
|
+
4. Run `graphify update .` to sync graph
|
|
107
|
+
5. Update progress.md, activeContext.md, _index.md with final status
|
|
101
108
|
```
|
|
102
109
|
|
|
103
110
|
## Success Criteria
|