@tyvm/knowhow 0.0.109 → 0.0.110
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/autodoc/README.md +324 -0
- package/autodoc/chat-guide.md +268 -365
- package/autodoc/cli-reference.md +399 -473
- package/autodoc/config-reference.md +431 -330
- package/autodoc/embeddings-guide.md +223 -322
- package/autodoc/generate-guide.md +261 -301
- package/autodoc/language-plugin-guide.md +221 -247
- package/autodoc/modules-guide.md +242 -215
- package/autodoc/plugins-guide.md +470 -469
- package/autodoc/quickstart-guide.md +67 -70
- package/autodoc/skills-guide.md +455 -339
- package/autodoc/worker-guide.md +301 -308
- package/package.json +1 -1
- package/scripts/build-for-node.sh +10 -24
- package/src/agents/tools/list.ts +2 -2
- package/src/ai.ts +81 -37
- package/src/chat/CliChatService.ts +1 -1
- package/src/chat/modules/AgentModule.ts +7 -2
- package/src/chat/modules/SessionsModule.ts +40 -1
- package/src/chat/modules/SystemModule.ts +2 -2
- package/src/clients/anthropic.ts +1 -1
- package/src/clients/index.ts +25 -6
- package/src/clients/openai.ts +8 -5
- package/src/clients/types.ts +29 -6
- package/src/clients/withRetry.ts +89 -0
- package/src/commands/agent.ts +30 -0
- package/src/commands/modules.ts +417 -47
- package/src/config.ts +1 -1
- package/src/fileSync.ts +20 -12
- package/src/hashes.ts +43 -22
- package/src/index.ts +4 -2
- package/src/processors/Base64ImageDetector.ts +73 -0
- package/src/services/MediaProcessorService.ts +79 -10
- package/src/services/modules/index.ts +47 -18
- package/tests/processors/Base64ImageDetector.test.ts +160 -0
- package/tests/unit/clients/AIClient.test.ts +446 -0
- package/tests/unit/clients/withRetry.test.ts +319 -0
- package/tests/unit/commands/github-credentials.test.ts +1 -2
- package/ts_build/package.json +1 -1
- package/ts_build/src/agents/tools/list.js +2 -2
- package/ts_build/src/agents/tools/list.js.map +1 -1
- package/ts_build/src/ai.d.ts +3 -3
- package/ts_build/src/ai.js +51 -23
- package/ts_build/src/ai.js.map +1 -1
- package/ts_build/src/chat/CliChatService.js +1 -1
- package/ts_build/src/chat/CliChatService.js.map +1 -1
- package/ts_build/src/chat/modules/AgentModule.js +5 -2
- package/ts_build/src/chat/modules/AgentModule.js.map +1 -1
- package/ts_build/src/chat/modules/SessionsModule.js +30 -1
- package/ts_build/src/chat/modules/SessionsModule.js.map +1 -1
- package/ts_build/src/chat/modules/SystemModule.js +2 -2
- package/ts_build/src/chat/modules/SystemModule.js.map +1 -1
- package/ts_build/src/clients/anthropic.js +1 -1
- package/ts_build/src/clients/anthropic.js.map +1 -1
- package/ts_build/src/clients/index.js +7 -6
- package/ts_build/src/clients/index.js.map +1 -1
- package/ts_build/src/clients/openai.js +4 -4
- package/ts_build/src/clients/openai.js.map +1 -1
- package/ts_build/src/clients/types.d.ts +12 -6
- package/ts_build/src/clients/withRetry.d.ts +2 -0
- package/ts_build/src/clients/withRetry.js +60 -0
- package/ts_build/src/clients/withRetry.js.map +1 -0
- package/ts_build/src/commands/agent.js +25 -0
- package/ts_build/src/commands/agent.js.map +1 -1
- package/ts_build/src/commands/modules.js +359 -32
- package/ts_build/src/commands/modules.js.map +1 -1
- package/ts_build/src/config.js +1 -1
- package/ts_build/src/config.js.map +1 -1
- package/ts_build/src/fileSync.d.ts +2 -2
- package/ts_build/src/fileSync.js +13 -11
- package/ts_build/src/fileSync.js.map +1 -1
- package/ts_build/src/hashes.d.ts +2 -2
- package/ts_build/src/hashes.js +40 -16
- package/ts_build/src/hashes.js.map +1 -1
- package/ts_build/src/index.js +1 -1
- package/ts_build/src/index.js.map +1 -1
- package/ts_build/src/processors/Base64ImageDetector.d.ts +3 -0
- package/ts_build/src/processors/Base64ImageDetector.js +42 -0
- package/ts_build/src/processors/Base64ImageDetector.js.map +1 -1
- package/ts_build/src/services/MediaProcessorService.d.ts +5 -4
- package/ts_build/src/services/MediaProcessorService.js +53 -8
- package/ts_build/src/services/MediaProcessorService.js.map +1 -1
- package/ts_build/src/services/modules/index.js +35 -12
- package/ts_build/src/services/modules/index.js.map +1 -1
- package/ts_build/tests/processors/Base64ImageDetector.test.js +111 -0
- package/ts_build/tests/processors/Base64ImageDetector.test.js.map +1 -1
- package/ts_build/tests/unit/clients/AIClient.test.d.ts +1 -0
- package/ts_build/tests/unit/clients/AIClient.test.js +339 -0
- package/ts_build/tests/unit/clients/AIClient.test.js.map +1 -0
- package/ts_build/tests/unit/clients/withRetry.test.d.ts +1 -0
- package/ts_build/tests/unit/clients/withRetry.test.js +225 -0
- package/ts_build/tests/unit/clients/withRetry.test.js.map +1 -0
- package/ts_build/tests/unit/commands/github-credentials.test.js +1 -2
- package/ts_build/tests/unit/commands/github-credentials.test.js.map +1 -1
package/autodoc/skills-guide.md
CHANGED
|
@@ -1,468 +1,584 @@
|
|
|
1
|
-
```md
|
|
2
1
|
# Skills Guide (Knowhow CLI)
|
|
3
2
|
|
|
4
3
|
## 1) What skills are
|
|
5
4
|
|
|
6
|
-
**Skills** are reusable instruction
|
|
5
|
+
**Skills** are reusable instruction bundles stored in files named **`SKILL.md`**.
|
|
6
|
+
When a user asks for something that matches a skill’s **name**, Knowhow automatically loads that skill’s full markdown content and provides it as context to the agent.
|
|
7
|
+
|
|
8
|
+
A skill file is ordinary markdown, but it includes **frontmatter metadata** at the top:
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
- `name` — the skill trigger name (must match what users say)
|
|
11
|
+
- `description` — a short summary shown during “skill discovery”
|
|
12
|
+
- **Body** — the complete instructions the agent should follow
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
**File naming rule:** the plugin scans for files literally named **`SKILL.md`** (case-sensitive on most systems).
|
|
11
15
|
|
|
12
16
|
---
|
|
13
17
|
|
|
14
|
-
## 2) How skills work
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
...
|
|
28
|
-
---
|
|
18
|
+
## 2) How skills work
|
|
19
|
+
|
|
20
|
+
### What the SkillsPlugin does
|
|
21
|
+
Knowhow’s **Skills Plugin** (`src/plugins/SkillsPlugin.ts`) performs three steps:
|
|
22
|
+
|
|
23
|
+
1. **Load config**
|
|
24
|
+
- Reads `.knowhow/knowhow.json` via `getConfig()`
|
|
25
|
+
- Looks for a `skills` array:
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"skills": ["some/directory", "..."]
|
|
29
|
+
}
|
|
29
30
|
```
|
|
30
|
-
- Each frontmatter line is parsed by splitting on the first `:` to extract fields like:
|
|
31
|
-
- `name: ...`
|
|
32
|
-
- `description: ...`
|
|
33
|
-
5. **Matches skills to the user prompt** using substring logic:
|
|
34
|
-
```ts
|
|
35
|
-
userPrompt.toLowerCase().includes(skill.name.toLowerCase())
|
|
36
|
-
```
|
|
37
|
-
**Important implication:** matching is **not exact**—it uses `includes()`.
|
|
38
|
-
- If your skill `name` is `deploy`, it may trigger on: “deploy”, “redeploy”, “deployment”, “deploying”.
|
|
39
|
-
|
|
40
|
-
6. **If one or more skills match**:
|
|
41
|
-
- The plugin reads each matched `SKILL.md` file
|
|
42
|
-
- It injects content into the agent context in a wrapper:
|
|
43
|
-
- Prepends:
|
|
44
|
-
- `## Skill: <name>`
|
|
45
|
-
- `File: <filePath>`
|
|
46
|
-
- Then includes the **entire `SKILL.md` file content**.
|
|
47
|
-
|
|
48
|
-
7. **If no skill name matches**:
|
|
49
|
-
- The plugin returns a **skills discovery summary** listing each discovered skill:
|
|
50
|
-
- skill name
|
|
51
|
-
- file path
|
|
52
|
-
- description
|
|
53
|
-
- This summary is injected as context so the user can reference the correct skill name.
|
|
54
31
|
|
|
55
|
-
|
|
32
|
+
2. **Scan skill directories**
|
|
33
|
+
- For each directory in `skills`, it:
|
|
34
|
+
- Expands `~` to `process.env.HOME`
|
|
35
|
+
- Recursively searches all subdirectories
|
|
36
|
+
- Finds files named `SKILL.md`
|
|
37
|
+
- Reads each file and extracts frontmatter `name` + `description`
|
|
38
|
+
- Each skill is indexed as:
|
|
39
|
+
- `name`
|
|
40
|
+
- `description`
|
|
41
|
+
- `filePath`
|
|
42
|
+
|
|
43
|
+
3. **Match user input to skills**
|
|
44
|
+
- If the user prompt contains a skill name **as a substring** (case-insensitive), e.g.:
|
|
45
|
+
- user: “Please do a **database migration**”
|
|
46
|
+
- skill name: “database migration”
|
|
47
|
+
- Then the plugin loads the **entire SKILL.md content** for every matched skill.
|
|
48
|
+
|
|
49
|
+
### What gets injected into the agent
|
|
50
|
+
For each matched skill, the plugin returns a block like:
|
|
56
51
|
|
|
57
|
-
|
|
52
|
+
```md
|
|
53
|
+
## Skill: <skill.name>
|
|
54
|
+
File: <skill.filePath>
|
|
58
55
|
|
|
59
|
-
|
|
56
|
+
<full SKILL.md content>
|
|
57
|
+
```
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
- `name` — the skill name (must match what users are likely to say; see substring matching)
|
|
63
|
-
- `description` — a short description shown during discovery
|
|
59
|
+
If multiple skills match, the plugin provides multiple blocks.
|
|
64
60
|
|
|
65
|
-
###
|
|
66
|
-
|
|
61
|
+
### Skill discovery behavior (no matches)
|
|
62
|
+
If **no** skill name is found in the user prompt, the plugin returns a **summary**:
|
|
67
63
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
---
|
|
64
|
+
- “Available skills:”
|
|
65
|
+
- Each skill listed as:
|
|
66
|
+
- `- <name> (<filePath>): <description>`
|
|
67
|
+
- Plus a reminder:
|
|
68
|
+
- “To use a skill, reference its name in your request and I will load the full instructions.”
|
|
74
69
|
|
|
75
|
-
|
|
70
|
+
So users can learn what skills exist by asking something that doesn’t match any skill name.
|
|
76
71
|
|
|
77
|
-
|
|
72
|
+
---
|
|
78
73
|
|
|
79
|
-
##
|
|
80
|
-
...
|
|
74
|
+
## 3) `SKILL.md` format
|
|
81
75
|
|
|
82
|
-
|
|
83
|
-
...
|
|
84
|
-
```
|
|
76
|
+
A skill file must follow this structure:
|
|
85
77
|
|
|
86
|
-
### Frontmatter example
|
|
87
78
|
```md
|
|
88
79
|
---
|
|
89
|
-
name:
|
|
90
|
-
description:
|
|
80
|
+
name: <skill name>
|
|
81
|
+
description: <short description>
|
|
91
82
|
---
|
|
83
|
+
|
|
84
|
+
<instructions and examples here>
|
|
92
85
|
```
|
|
93
86
|
|
|
87
|
+
### Frontmatter rules (important)
|
|
88
|
+
From the plugin’s `parseFrontmatter()` implementation:
|
|
89
|
+
|
|
90
|
+
- It expects frontmatter to begin at the **start** of the file with:
|
|
91
|
+
- `---` then newline
|
|
92
|
+
- It captures content until the next `---`
|
|
93
|
+
- Each frontmatter line is parsed as:
|
|
94
|
+
- `key: <value>`
|
|
95
|
+
- If a value contains `:` characters, they are preserved because the parser:
|
|
96
|
+
- splits on the first `:`
|
|
97
|
+
- rejoins the rest
|
|
98
|
+
|
|
99
|
+
### Body content
|
|
100
|
+
Everything after the closing `---` is treated as the **full skill instructions** and gets injected into the agent context.
|
|
101
|
+
|
|
94
102
|
---
|
|
95
103
|
|
|
96
104
|
## 4) Configuring skills
|
|
97
105
|
|
|
98
|
-
Add
|
|
106
|
+
Add a `skills` array in your `knowhow.json`:
|
|
99
107
|
|
|
100
|
-
Example:
|
|
108
|
+
### Example: local project config
|
|
109
|
+
`.knowhow/knowhow.json`
|
|
101
110
|
```json
|
|
102
111
|
{
|
|
103
|
-
"plugins": {
|
|
104
|
-
"skills": true
|
|
105
|
-
},
|
|
106
112
|
"skills": [
|
|
107
|
-
"
|
|
108
|
-
"
|
|
113
|
+
".knowhow/skills",
|
|
114
|
+
"skills"
|
|
109
115
|
]
|
|
110
116
|
}
|
|
111
117
|
```
|
|
112
118
|
|
|
113
|
-
Notes
|
|
114
|
-
-
|
|
115
|
-
-
|
|
116
|
-
-
|
|
119
|
+
**Notes**
|
|
120
|
+
- Directories are scanned **recursively**
|
|
121
|
+
- Every `SKILL.md` found contributes a skill
|
|
122
|
+
- Unreadable/missing directories are ignored
|
|
123
|
+
|
|
124
|
+
### Path shorthand
|
|
125
|
+
The plugin supports `~`:
|
|
126
|
+
- `~/some/path` → resolved using `process.env.HOME`
|
|
117
127
|
|
|
118
128
|
---
|
|
119
129
|
|
|
120
|
-
## 5) Skill discovery
|
|
130
|
+
## 5) Skill discovery
|
|
121
131
|
|
|
122
|
-
If
|
|
132
|
+
If a user’s request does **not** include any configured skill names (as substring matches), the agent will receive the plugin’s “Available skills” summary.
|
|
123
133
|
|
|
124
|
-
|
|
125
|
-
|
|
134
|
+
To get a skill loaded, the user must:
|
|
135
|
+
- mention the skill name **in the request text**
|
|
136
|
+
- in any casing (the match is case-insensitive)
|
|
126
137
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
**Author takeaway:** choose `name` values that users will naturally include in their requests.
|
|
138
|
+
**Tip:** choose `name` strings that users will naturally include verbatim (e.g., “code review”, “deploy”, “database migration”).
|
|
130
139
|
|
|
131
140
|
---
|
|
132
141
|
|
|
133
142
|
## 6) Writing effective skills (best practices)
|
|
134
143
|
|
|
135
|
-
### A) Use clear,
|
|
136
|
-
|
|
144
|
+
### A) Use a clear, human-friendly `name`
|
|
145
|
+
- Pick wording users are likely to type.
|
|
146
|
+
- Keep it consistent and not overly broad.
|
|
147
|
+
- Avoid punctuation-heavy names; they are harder to match reliably.
|
|
148
|
+
|
|
149
|
+
### B) Put the most important instructions early
|
|
150
|
+
Agents work better when:
|
|
151
|
+
- prerequisites and scope are near the top
|
|
152
|
+
- steps are structured and scannable
|
|
153
|
+
|
|
154
|
+
### C) Use step-by-step structure
|
|
155
|
+
Prefer numbered lists, short sections, and checklists.
|
|
137
156
|
|
|
138
|
-
|
|
139
|
-
|
|
157
|
+
### D) Include code examples and templates
|
|
158
|
+
If the skill involves commands, configs, queries, or scripts:
|
|
159
|
+
- provide copy/paste examples
|
|
160
|
+
- show placeholders clearly (e.g., `<SERVICE>`, `<ENV>`)
|
|
140
161
|
|
|
141
|
-
###
|
|
142
|
-
|
|
143
|
-
- “
|
|
162
|
+
### E) Handle edge cases explicitly
|
|
163
|
+
Include a section like:
|
|
164
|
+
- “Edge cases / when to stop”
|
|
165
|
+
- “Common pitfalls”
|
|
166
|
+
- “If you lack access/inputs, ask these questions”
|
|
144
167
|
|
|
145
|
-
###
|
|
146
|
-
|
|
147
|
-
- `
|
|
168
|
+
### F) Match the plugin’s matching behavior
|
|
169
|
+
Because the plugin triggers when:
|
|
170
|
+
- `userPrompt.toLowerCase().includes(skill.name.toLowerCase())`
|
|
148
171
|
|
|
149
|
-
|
|
150
|
-
Add sections such as:
|
|
151
|
-
- Common failures
|
|
152
|
-
- Rollback plan
|
|
153
|
-
- Verification steps
|
|
154
|
-
- What to do if an environment variable is missing
|
|
155
|
-
- What to do if a deployment health check fails
|
|
172
|
+
…avoid names that require exact formatting users won’t reproduce.
|
|
156
173
|
|
|
157
|
-
|
|
158
|
-
Tell the agent what “done” means:
|
|
159
|
-
- expected outputs
|
|
160
|
-
- checklist completion
|
|
161
|
-
- verification queries/commands that must pass
|
|
174
|
+
**Example:** If you name a skill `DB migrate`, users may type `database migration` instead and won’t match. Prefer a common phrase.
|
|
162
175
|
|
|
163
176
|
---
|
|
164
177
|
|
|
165
178
|
## 7) Example skills (complete `SKILL.md` files)
|
|
166
179
|
|
|
167
|
-
Below are complete
|
|
180
|
+
Below are **complete** examples you can place in directories scanned by your `skills` config.
|
|
168
181
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
### Example 1: `deploy` skill
|
|
182
|
+
### Example A: `deploy` skill
|
|
172
183
|
|
|
173
|
-
**File:**
|
|
184
|
+
**File:** `.knowhow/skills/deploy/SKILL.md` (path arbitrary; filename must be `SKILL.md`)
|
|
174
185
|
```md
|
|
175
186
|
---
|
|
176
187
|
name: deploy
|
|
177
|
-
description: Deploy an application safely
|
|
188
|
+
description: Deploy an application safely using a repeatable, checklist-driven process (plan, validate, release, verify, rollback).
|
|
178
189
|
---
|
|
179
190
|
|
|
180
191
|
# Deploy Skill
|
|
181
192
|
|
|
182
|
-
Use this
|
|
183
|
-
|
|
184
|
-
##
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
2.
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
193
|
+
Use this skill to guide a safe deployment for a typical web/service app. Adapt steps to your stack (Kubernetes, systemd, Heroku, Docker Compose, etc.).
|
|
194
|
+
|
|
195
|
+
## Inputs to request (if missing)
|
|
196
|
+
If the user did not provide these, ask:
|
|
197
|
+
1. Deployment target (e.g., `staging`, `production`, a specific environment name)
|
|
198
|
+
2. Release artifact (e.g., docker image tag, build number, commit SHA)
|
|
199
|
+
3. Deployment method/tooling (e.g., Helm, kubectl, Terraform, SSH scripts, GitHub Actions)
|
|
200
|
+
4. Any required approvals or maintenance windows
|
|
201
|
+
5. Current rollback strategy
|
|
202
|
+
|
|
203
|
+
## Step-by-step deployment process
|
|
204
|
+
|
|
205
|
+
### 1) Plan & confirm scope
|
|
206
|
+
- Identify what will change:
|
|
207
|
+
- code changes
|
|
208
|
+
- config changes
|
|
209
|
+
- infrastructure changes
|
|
210
|
+
- Confirm:
|
|
211
|
+
- target environment
|
|
212
|
+
- expected downtime (if any)
|
|
213
|
+
- dependencies (databases, queues, caches)
|
|
214
|
+
|
|
215
|
+
### 2) Pre-deploy validation
|
|
216
|
+
- Verify health of the current environment:
|
|
217
|
+
- uptime/error rates
|
|
218
|
+
- logs for obvious incidents
|
|
219
|
+
- Confirm required secrets/configs exist for the target environment.
|
|
220
|
+
- If migrations are involved, identify:
|
|
221
|
+
- migration ordering and whether they are backward-compatible
|
|
222
|
+
|
|
223
|
+
### 3) Choose a release strategy
|
|
224
|
+
Pick one:
|
|
225
|
+
- **Blue/Green** (preferred for minimal disruption)
|
|
226
|
+
- **Rolling** (common for Kubernetes/stateful services)
|
|
227
|
+
- **Canary** (gradual traffic shift)
|
|
228
|
+
- **Restart-based** (simpler but higher risk)
|
|
229
|
+
|
|
230
|
+
State which one you will use and why.
|
|
231
|
+
|
|
232
|
+
### 4) Execute deployment
|
|
233
|
+
Provide the exact commands/steps for the user’s stack.
|
|
234
|
+
|
|
235
|
+
#### Kubernetes/Helm template
|
|
211
236
|
```bash
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
237
|
+
# Example variables:
|
|
238
|
+
# RELEASE=<release-name>
|
|
239
|
+
# NAMESPACE=<namespace>
|
|
240
|
+
# CHART=<chart-dir-or-name>
|
|
241
|
+
# IMAGE_TAG=<tag>
|
|
242
|
+
|
|
243
|
+
helm upgrade --install "$RELEASE" "$CHART" \
|
|
244
|
+
--namespace "$NAMESPACE" \
|
|
245
|
+
--set image.tag="$IMAGE_TAG"
|
|
215
246
|
```
|
|
216
247
|
|
|
217
|
-
|
|
248
|
+
#### Docker Compose template
|
|
218
249
|
```bash
|
|
219
|
-
|
|
250
|
+
# Example:
|
|
251
|
+
# IMAGE_TAG=<tag>
|
|
252
|
+
export IMAGE_TAG="$IMAGE_TAG"
|
|
253
|
+
|
|
220
254
|
docker compose pull
|
|
221
|
-
docker compose up -d
|
|
222
|
-
docker compose ps
|
|
255
|
+
docker compose up -d --no-deps
|
|
223
256
|
```
|
|
224
257
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
-
|
|
252
|
-
|
|
253
|
-
-
|
|
254
|
-
|
|
258
|
+
### 5) Post-deploy verification (must-do)
|
|
259
|
+
After the deploy completes:
|
|
260
|
+
- Check application health endpoints
|
|
261
|
+
- Confirm critical workflows:
|
|
262
|
+
- login/session
|
|
263
|
+
- primary read/write operations
|
|
264
|
+
- queue consumers / background jobs (if applicable)
|
|
265
|
+
- Monitor logs for errors for at least **10–15 minutes** (or the team’s standard)
|
|
266
|
+
|
|
267
|
+
### 6) Communicate & close out
|
|
268
|
+
Report:
|
|
269
|
+
- what changed
|
|
270
|
+
- verification results
|
|
271
|
+
- link(s) to release notes/build artifacts
|
|
272
|
+
- next steps (if any)
|
|
273
|
+
|
|
274
|
+
## Rollback plan (include before executing)
|
|
275
|
+
Before the deployment, define rollback triggers:
|
|
276
|
+
- error budget exceeded
|
|
277
|
+
- health checks failing
|
|
278
|
+
- latency spike
|
|
279
|
+
- incident detected
|
|
280
|
+
|
|
281
|
+
Provide concrete rollback actions, e.g.:
|
|
282
|
+
- Helm rollback to previous revision:
|
|
283
|
+
```bash
|
|
284
|
+
helm rollback "$RELEASE" <revision-number> --namespace "$NAMESPACE"
|
|
285
|
+
```
|
|
286
|
+
- Or redeploy prior image tag.
|
|
287
|
+
|
|
288
|
+
## Edge cases / stop conditions
|
|
289
|
+
- Stop and ask questions if:
|
|
290
|
+
- you don’t know the release artifact
|
|
291
|
+
- there are pending schema changes without a migration plan
|
|
292
|
+
- rollback strategy is unclear
|
|
293
|
+
- If migrations exist, consider ordering:
|
|
294
|
+
1) deploy backward-compatible code
|
|
295
|
+
2) apply migrations
|
|
296
|
+
3) deploy forward code
|
|
297
|
+
|
|
298
|
+
## Output format (what to respond with)
|
|
299
|
+
When executing, respond with:
|
|
300
|
+
1. Deployment plan summary
|
|
301
|
+
2. Exact steps/commands
|
|
302
|
+
3. Verification checklist
|
|
303
|
+
4. Rollback instructions and triggers
|
|
255
304
|
```
|
|
256
305
|
|
|
257
306
|
---
|
|
258
307
|
|
|
259
|
-
### Example
|
|
308
|
+
### Example B: `code review` skill
|
|
260
309
|
|
|
261
|
-
**File:**
|
|
310
|
+
**File:** `.knowhow/skills/code-review/SKILL.md`
|
|
262
311
|
```md
|
|
263
312
|
---
|
|
264
313
|
name: code review
|
|
265
|
-
description: Perform a structured code review with
|
|
314
|
+
description: Perform a structured code review with a checklist, risk assessment, and actionable feedback.
|
|
266
315
|
---
|
|
267
316
|
|
|
268
317
|
# Code Review Skill
|
|
269
318
|
|
|
270
|
-
Use this
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
-
|
|
287
|
-
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
-
|
|
293
|
-
-
|
|
294
|
-
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
300
|
-
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
-
|
|
305
|
-
-
|
|
306
|
-
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
-
|
|
310
|
-
-
|
|
311
|
-
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
319
|
+
Use this skill to review a code change (PR/diff). Provide feedback that is:
|
|
320
|
+
- specific
|
|
321
|
+
- actionable
|
|
322
|
+
- prioritized by risk/impact
|
|
323
|
+
|
|
324
|
+
## Inputs to request (if missing)
|
|
325
|
+
Ask for:
|
|
326
|
+
1. Language/framework
|
|
327
|
+
2. Repo context (where relevant)
|
|
328
|
+
3. The diff/patch (or key files)
|
|
329
|
+
4. Purpose of change (bug fix? feature?)
|
|
330
|
+
5. Constraints (performance/security/compliance)
|
|
331
|
+
|
|
332
|
+
## Review workflow
|
|
333
|
+
|
|
334
|
+
### 1) High-level summary
|
|
335
|
+
- What does the change aim to do?
|
|
336
|
+
- What files/components are most impacted?
|
|
337
|
+
|
|
338
|
+
### 2) Checklist review (use this order)
|
|
339
|
+
|
|
340
|
+
#### Correctness
|
|
341
|
+
- Does the code match the intended behavior?
|
|
342
|
+
- Are there off-by-one / null / boundary cases?
|
|
343
|
+
- Are errors handled and surfaced appropriately?
|
|
344
|
+
|
|
345
|
+
#### Security
|
|
346
|
+
- Input validation and sanitization
|
|
347
|
+
- Authz/authn checks
|
|
348
|
+
- Secrets handling (no secrets in logs)
|
|
349
|
+
- Injection risks (SQL/command/template)
|
|
350
|
+
- CSRF/XSS risks (web)
|
|
351
|
+
|
|
352
|
+
#### Performance
|
|
353
|
+
- Hot paths and unnecessary allocations
|
|
354
|
+
- N+1 queries / repeated work
|
|
355
|
+
- Unbounded loops or expensive operations
|
|
356
|
+
|
|
357
|
+
#### Maintainability
|
|
358
|
+
- Naming clarity
|
|
359
|
+
- DRY vs duplication
|
|
360
|
+
- Testability (pure functions, seams for mocks)
|
|
361
|
+
- Code structure and separation of concerns
|
|
362
|
+
|
|
363
|
+
#### Observability
|
|
364
|
+
- Useful logs (without leaking sensitive data)
|
|
365
|
+
- Metrics/events where appropriate
|
|
366
|
+
- Error logs include sufficient context
|
|
367
|
+
|
|
368
|
+
#### Testing
|
|
369
|
+
- Unit tests for logic
|
|
370
|
+
- Integration tests for boundaries
|
|
371
|
+
- Regression tests for bug fixes
|
|
372
|
+
- Edge cases covered
|
|
373
|
+
|
|
374
|
+
### 3) Risk assessment (must include)
|
|
375
|
+
Create a short risk table:
|
|
376
|
+
|
|
377
|
+
| Area | Risk level (Low/Med/High) | Why | Suggestion |
|
|
378
|
+
|------|------------------------------|-----|------------|
|
|
379
|
+
|
|
380
|
+
### 4) Actionable feedback
|
|
381
|
+
For each issue:
|
|
382
|
+
- Explain why it’s a problem
|
|
383
|
+
- Provide a suggested change (or example)
|
|
384
|
+
- Label severity: **Must-fix / Should-fix / Nice-to-have**
|
|
385
|
+
|
|
386
|
+
### 5) Questions for the author (if needed)
|
|
387
|
+
Ask clarifying questions only when assumptions would otherwise be unsafe.
|
|
388
|
+
|
|
389
|
+
## Example response structure
|
|
390
|
+
Return your output using:
|
|
391
|
+
|
|
392
|
+
1. Summary
|
|
393
|
+
2. Review (grouped by Correctness/Security/Performance/etc.)
|
|
394
|
+
3. Risk table
|
|
395
|
+
4. Must-fix / Should-fix items (with suggestions)
|
|
396
|
+
5. Tests recommendations
|
|
397
|
+
6. Questions (if any)
|
|
398
|
+
|
|
399
|
+
## Edge cases / constraints
|
|
400
|
+
- If the diff is incomplete, ask for the missing portions instead of guessing.
|
|
401
|
+
- If you cannot assess security due to missing auth context, explicitly state that limitation and request needed info.
|
|
321
402
|
```
|
|
322
403
|
|
|
323
404
|
---
|
|
324
405
|
|
|
325
|
-
### Example
|
|
406
|
+
### Example C: `database migration` skill
|
|
326
407
|
|
|
327
|
-
**File:**
|
|
408
|
+
**File:** `.knowhow/skills/database-migration/SKILL.md`
|
|
328
409
|
```md
|
|
329
410
|
---
|
|
330
411
|
name: database migration
|
|
331
|
-
description: Plan and execute
|
|
412
|
+
description: Plan and execute database migrations with safety (backward compatibility, ordering, verification, rollback).
|
|
332
413
|
---
|
|
333
414
|
|
|
334
415
|
# Database Migration Skill
|
|
335
416
|
|
|
336
|
-
Use this
|
|
337
|
-
|
|
338
|
-
##
|
|
339
|
-
|
|
340
|
-
1.
|
|
341
|
-
2.
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
1.
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
-
|
|
373
|
-
-
|
|
374
|
-
|
|
375
|
-
###
|
|
376
|
-
|
|
377
|
-
-
|
|
378
|
-
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
###
|
|
417
|
+
Use this skill to guide migrations for relational databases (Postgres/MySQL/etc.) with production-safety principles.
|
|
418
|
+
|
|
419
|
+
## Inputs to request (if missing)
|
|
420
|
+
Ask:
|
|
421
|
+
1. Database type/version (e.g., Postgres 14)
|
|
422
|
+
2. Migration type:
|
|
423
|
+
- schema change
|
|
424
|
+
- data backfill
|
|
425
|
+
- index changes
|
|
426
|
+
- constraints
|
|
427
|
+
3. Migration tool (e.g., Flyway, Liquibase, Alembic, Prisma Migrate, custom scripts)
|
|
428
|
+
4. Environment (staging vs production)
|
|
429
|
+
5. Constraints:
|
|
430
|
+
- availability requirements
|
|
431
|
+
- expected load window
|
|
432
|
+
- maximum acceptable migration duration
|
|
433
|
+
6. Whether the app code will be deployed concurrently
|
|
434
|
+
|
|
435
|
+
## Safety principles (follow in order)
|
|
436
|
+
1. **Backward compatible first**
|
|
437
|
+
2. Prefer **expand → migrate → contract**
|
|
438
|
+
3. Keep transactions short when possible
|
|
439
|
+
4. Avoid long locks (reindex/alter carefully)
|
|
440
|
+
5. Validate before/after with queries
|
|
441
|
+
|
|
442
|
+
## Migration plan template
|
|
443
|
+
|
|
444
|
+
### Step 1) Understand current state
|
|
445
|
+
- Identify current schema
|
|
446
|
+
- Identify dependencies:
|
|
447
|
+
- foreign keys
|
|
448
|
+
- views
|
|
449
|
+
- triggers
|
|
450
|
+
- application queries
|
|
451
|
+
|
|
452
|
+
### Step 2) Define the target
|
|
453
|
+
- What new columns/tables/indexes/constraints are desired?
|
|
454
|
+
- What data transformations are needed?
|
|
455
|
+
|
|
456
|
+
### Step 3) Plan expand/migrate/contract (example)
|
|
457
|
+
#### Expand (backward compatible)
|
|
458
|
+
- Add new nullable column(s)
|
|
459
|
+
- Add new tables
|
|
460
|
+
- Add indexes concurrently (if supported)
|
|
461
|
+
- Do **not** add NOT NULL or strict constraints yet
|
|
462
|
+
|
|
463
|
+
#### Migrate (populate data)
|
|
464
|
+
- Backfill in batches
|
|
465
|
+
- Ensure idempotency
|
|
466
|
+
- Rate limit if needed
|
|
467
|
+
|
|
468
|
+
#### Contract (enforce invariants)
|
|
469
|
+
- Set NOT NULL after backfill completion
|
|
470
|
+
- Add constraints
|
|
471
|
+
- Drop old columns only after code is updated and verified
|
|
472
|
+
|
|
473
|
+
### Step 4) Order of deployments
|
|
474
|
+
If app code changes too, use:
|
|
475
|
+
1. Deploy backward-compatible code
|
|
476
|
+
2. Run expand migration
|
|
477
|
+
3. Deploy code that writes new format (optional)
|
|
478
|
+
4. Run data backfill
|
|
479
|
+
5. Deploy forward code
|
|
480
|
+
6. Run contract migration
|
|
481
|
+
|
|
482
|
+
## Concrete examples
|
|
483
|
+
|
|
484
|
+
### Example: Backfill a new column in batches (SQL pseudocode)
|
|
393
485
|
```sql
|
|
394
|
-
--
|
|
395
|
-
ALTER TABLE users ADD COLUMN
|
|
486
|
+
-- Add column first (expand)
|
|
487
|
+
ALTER TABLE users ADD COLUMN display_name TEXT;
|
|
396
488
|
|
|
397
|
-
--
|
|
489
|
+
-- Backfill in batches (migrate)
|
|
490
|
+
-- Repeat until affected_rows = 0
|
|
398
491
|
UPDATE users
|
|
399
|
-
SET
|
|
400
|
-
WHERE
|
|
401
|
-
|
|
402
|
-
-- 3) Validate before enforcing (example checks)
|
|
403
|
-
SELECT count(*) FROM users WHERE email_normalized IS NULL;
|
|
404
|
-
|
|
405
|
-
-- 4) Contract: enforce constraint
|
|
406
|
-
ALTER TABLE users ALTER COLUMN email_normalized SET NOT NULL;
|
|
492
|
+
SET display_name = username
|
|
493
|
+
WHERE display_name IS NULL
|
|
494
|
+
LIMIT 10000;
|
|
407
495
|
```
|
|
408
496
|
|
|
409
|
-
|
|
497
|
+
> If your DB doesn’t support `LIMIT` on UPDATE, use a CTE or batch-selection strategy.
|
|
498
|
+
|
|
499
|
+
### Example: Index creation carefully (Postgres-style)
|
|
500
|
+
- Create index concurrently to reduce locking:
|
|
410
501
|
```sql
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
ON users(email_normalized);
|
|
502
|
+
CREATE INDEX CONCURRENTLY users_display_name_idx
|
|
503
|
+
ON users (display_name);
|
|
414
504
|
```
|
|
415
505
|
|
|
416
|
-
##
|
|
417
|
-
|
|
418
|
-
-
|
|
419
|
-
-
|
|
420
|
-
-
|
|
421
|
-
-
|
|
422
|
-
-
|
|
423
|
-
-
|
|
506
|
+
## Verification checklist (before and after)
|
|
507
|
+
### Before
|
|
508
|
+
- Confirm migration has a dry run plan
|
|
509
|
+
- Confirm rollback method exists
|
|
510
|
+
- Record:
|
|
511
|
+
- row counts
|
|
512
|
+
- min/max timestamps
|
|
513
|
+
- key aggregates
|
|
514
|
+
|
|
515
|
+
### After
|
|
516
|
+
- Re-run invariants:
|
|
517
|
+
- null counts for new required columns
|
|
518
|
+
- foreign key validity checks
|
|
519
|
+
- Check application health
|
|
520
|
+
- Monitor errors/latency for the migration window
|
|
521
|
+
|
|
522
|
+
## Rollback strategy
|
|
523
|
+
Define one of:
|
|
524
|
+
- **Down migration** (if safe/possible)
|
|
525
|
+
- **Reverse via feature flag**
|
|
526
|
+
- **Recreate old schema** (last resort)
|
|
527
|
+
- **Data rollback** (restore from snapshot/backups)
|
|
528
|
+
|
|
529
|
+
State rollback triggers explicitly (e.g., health checks failing, lock contention too high).
|
|
530
|
+
|
|
531
|
+
## Edge cases
|
|
532
|
+
- If adding NOT NULL column without default to a large table:
|
|
533
|
+
- do it via expand/migrate/contract
|
|
534
|
+
- If updating huge datasets:
|
|
535
|
+
- batch and monitor impact
|
|
536
|
+
- If migrations aren’t idempotent:
|
|
537
|
+
- redesign to be re-runnable safely
|
|
424
538
|
```
|
|
425
539
|
|
|
426
540
|
---
|
|
427
541
|
|
|
428
542
|
## 8) Global skills
|
|
429
543
|
|
|
430
|
-
|
|
544
|
+
If you want skills to be available **across projects**, store them in:
|
|
431
545
|
|
|
432
546
|
**`~/.knowhow/skills/`**
|
|
433
547
|
|
|
434
|
-
Then
|
|
435
|
-
```json
|
|
436
|
-
{
|
|
437
|
-
"skills": [
|
|
438
|
-
"~/.knowhow/skills"
|
|
439
|
-
]
|
|
440
|
-
}
|
|
441
|
-
```
|
|
548
|
+
Then include that directory in your `skills` configuration (either in global config or project config, depending on how your setup uses `knowhow.json`).
|
|
442
549
|
|
|
443
|
-
Recommended structure
|
|
550
|
+
### Recommended structure
|
|
444
551
|
```text
|
|
445
552
|
~/.knowhow/skills/
|
|
446
553
|
deploy/
|
|
447
554
|
SKILL.md
|
|
448
555
|
code-review/
|
|
449
556
|
SKILL.md
|
|
450
|
-
|
|
557
|
+
database-migration/
|
|
451
558
|
SKILL.md
|
|
452
559
|
```
|
|
453
560
|
|
|
454
|
-
|
|
561
|
+
### Example `knowhow.json` (point to global + local)
|
|
562
|
+
```json
|
|
563
|
+
{
|
|
564
|
+
"skills": [
|
|
565
|
+
"~/.knowhow/skills",
|
|
566
|
+
".knowhow/skills"
|
|
567
|
+
]
|
|
568
|
+
}
|
|
569
|
+
```
|
|
455
570
|
|
|
456
571
|
---
|
|
457
572
|
|
|
458
|
-
##
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
573
|
+
## Quick checklist for creating a new skill
|
|
574
|
+
|
|
575
|
+
1. Create a folder (any name) and place a file named **`SKILL.md`**
|
|
576
|
+
2. Add frontmatter at the top:
|
|
577
|
+
- `name: ...`
|
|
578
|
+
- `description: ...`
|
|
579
|
+
3. Write clear, step-by-step instructions in the body
|
|
580
|
+
4. Include examples and edge cases
|
|
581
|
+
5. Add the directory to the `skills` array in `.knowhow/knowhow.json`
|
|
582
|
+
6. Test by prompting the agent using the exact skill name phrase (case-insensitive substring match)
|
|
583
|
+
|
|
584
|
+
If you want, tell me your workflow (tools/stack) and I can generate a tailored set of `SKILL.md` templates for your team.
|