@tyvm/knowhow 0.0.89 → 0.0.90
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/CONFIG.md +52 -0
- package/README.md +344 -29
- package/WORKER.md +169 -334
- package/autodoc/chat-guide.md +540 -0
- package/autodoc/cli-reference.md +765 -0
- package/autodoc/config-reference.md +541 -0
- package/autodoc/embeddings-guide.md +566 -0
- package/autodoc/generate-guide.md +477 -0
- package/autodoc/language-plugin-guide.md +443 -0
- package/autodoc/modules-guide.md +352 -0
- package/autodoc/plugins-guide.md +720 -0
- package/autodoc/quickstart-guide.md +129 -0
- package/autodoc/skills-guide.md +468 -0
- package/autodoc/worker-guide.md +526 -0
- package/package.json +1 -1
- package/src/ai.ts +33 -2
- package/src/config.ts +28 -4
- package/src/index.ts +22 -2
- package/src/processors/TokenCompressor.ts +2 -2
- package/src/processors/ToolResponseCache.ts +3 -3
- package/src/processors/tools/grepToolResponse.ts +9 -4
- package/src/processors/tools/jqToolResponse.ts +11 -6
- package/src/processors/tools/listStoredToolResponses.ts +1 -1
- package/src/processors/tools/tailToolResponse.ts +9 -4
- package/ts_build/package.json +1 -1
- package/ts_build/src/ai.js +18 -1
- package/ts_build/src/ai.js.map +1 -1
- package/ts_build/src/config.js +17 -2
- package/ts_build/src/config.js.map +1 -1
- package/ts_build/src/index.js +12 -2
- package/ts_build/src/index.js.map +1 -1
- package/ts_build/src/processors/TokenCompressor.js +2 -2
- package/ts_build/src/processors/TokenCompressor.js.map +1 -1
- package/ts_build/src/processors/ToolResponseCache.js +3 -3
- package/ts_build/src/processors/ToolResponseCache.js.map +1 -1
- package/ts_build/src/processors/tools/grepToolResponse.d.ts +3 -1
- package/ts_build/src/processors/tools/grepToolResponse.js +8 -2
- package/ts_build/src/processors/tools/grepToolResponse.js.map +1 -1
- package/ts_build/src/processors/tools/jqToolResponse.d.ts +3 -1
- package/ts_build/src/processors/tools/jqToolResponse.js +10 -4
- package/ts_build/src/processors/tools/jqToolResponse.js.map +1 -1
- package/ts_build/src/processors/tools/listStoredToolResponses.js +1 -1
- package/ts_build/src/processors/tools/listStoredToolResponses.js.map +1 -1
- package/ts_build/src/processors/tools/tailToolResponse.d.ts +3 -1
- package/ts_build/src/processors/tools/tailToolResponse.js +8 -2
- package/ts_build/src/processors/tools/tailToolResponse.js.map +1 -1
- package/autodoc/chat.mdx +0 -20
- package/autodoc/cli.mdx +0 -11
- package/autodoc/plugins/asana.mdx +0 -47
- package/autodoc/plugins/downloader/downloader.mdx +0 -38
- package/autodoc/plugins/downloader/plugin.mdx +0 -37
- package/autodoc/plugins/downloader/types.mdx +0 -42
- package/autodoc/plugins/embedding.mdx +0 -41
- package/autodoc/plugins/figma.mdx +0 -45
- package/autodoc/plugins/github.mdx +0 -40
- package/autodoc/plugins/jira.mdx +0 -46
- package/autodoc/plugins/language.mdx +0 -37
- package/autodoc/plugins/linear.mdx +0 -35
- package/autodoc/plugins/notion.mdx +0 -38
- package/autodoc/plugins/plugins.mdx +0 -59
- package/autodoc/plugins/types.mdx +0 -51
- package/autodoc/plugins/vim.mdx +0 -39
- package/autodoc/tools/addInternalTools.mdx +0 -1
- package/autodoc/tools/agentCall.mdx +0 -1
- package/autodoc/tools/asana/definitions.mdx +0 -10
- package/autodoc/tools/asana/index.mdx +0 -12
- package/autodoc/tools/askHuman.mdx +0 -1
- package/autodoc/tools/callPlugin.mdx +0 -1
- package/autodoc/tools/embeddingSearch.mdx +0 -1
- package/autodoc/tools/execCommand.mdx +0 -1
- package/autodoc/tools/fileSearch.mdx +0 -1
- package/autodoc/tools/finalAnswer.mdx +0 -1
- package/autodoc/tools/github/definitions.mdx +0 -6
- package/autodoc/tools/github/index.mdx +0 -8
- package/autodoc/tools/index.mdx +0 -14
- package/autodoc/tools/lintFile.mdx +0 -7
- package/autodoc/tools/list.mdx +0 -16
- package/autodoc/tools/modifyFile.mdx +0 -7
- package/autodoc/tools/patch.mdx +0 -9
- package/autodoc/tools/readBlocks.mdx +0 -1
- package/autodoc/tools/readFile.mdx +0 -1
- package/autodoc/tools/scanFile.mdx +0 -1
- package/autodoc/tools/textSearch.mdx +0 -6
- package/autodoc/tools/types/fileblock.mdx +0 -1
- package/autodoc/tools/visionTool.mdx +0 -1
- package/autodoc/tools/writeFile.mdx +0 -1
- package/test-comprehensive.ts +0 -31
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Knowhow Quickstart
|
|
2
|
+
|
|
3
|
+
Knowhow is an AI CLI (plugins + agents) for generating docs, creating embeddings, and running chat/agents.
|
|
4
|
+
|
|
5
|
+
Project home: https://knowhow.tyvm.ai
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1) Installation
|
|
10
|
+
|
|
11
|
+
### npm (global install)
|
|
12
|
+
```bash
|
|
13
|
+
npm i -g @tyvm/knowhow
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### npx (run without installing globally)
|
|
17
|
+
```bash
|
|
18
|
+
npx @tyvm/knowhow@latest --version
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Now you can run:
|
|
22
|
+
```bash
|
|
23
|
+
knowhow --help
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 2) Initialize a project (`knowhow init`)
|
|
29
|
+
|
|
30
|
+
From your project directory:
|
|
31
|
+
```bash
|
|
32
|
+
knowhow init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This creates:
|
|
36
|
+
|
|
37
|
+
- **Local config** (in your current directory):
|
|
38
|
+
- `.knowhow/` directory
|
|
39
|
+
- `.knowhow/knowhow.json` (your config)
|
|
40
|
+
- `.knowhow/prompts/` (prompt templates)
|
|
41
|
+
- `.knowhow/docs/` (generated docs)
|
|
42
|
+
- `.knowhow/embeddings/` (generated embeddings)
|
|
43
|
+
- `.knowhow/language.json`
|
|
44
|
+
- `.knowhow/.ignore`, `.knowhow/.hashes.json`, `.knowhow/.jwt` (JWT placeholder)
|
|
45
|
+
|
|
46
|
+
- **Global template config** (in your home directory):
|
|
47
|
+
- `~/.knowhow/` (stores template copies used by `init`)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 3) Login (`knowhow login`)
|
|
52
|
+
|
|
53
|
+
Login uses **browser-based OAuth** by default (you approve in a browser, the CLI polls for approval, then retrieves a JWT).
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
knowhow login
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If you prefer to paste a token manually:
|
|
60
|
+
```bash
|
|
61
|
+
knowhow login --jwt
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
What it does:
|
|
65
|
+
- Performs browser login flow against **https://knowhow.tyvm.ai**
|
|
66
|
+
- Stores the returned **JWT** in:
|
|
67
|
+
- `.knowhow/.jwt` (permissioned to be read/write only by you)
|
|
68
|
+
- Updates `knowhow.json` by adding a **model provider** entry for the `knowhow` proxy (so Knowhow-backed models work with your config)
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 4) Basic first run
|
|
73
|
+
|
|
74
|
+
After `init` + `login`, you can immediately start a chat UI:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
knowhow chat
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
You can also ask directly (no agent overhead):
|
|
81
|
+
```bash
|
|
82
|
+
knowhow ask --input "What should I work on next?"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
(Optionally) search embeddings:
|
|
86
|
+
```bash
|
|
87
|
+
knowhow search --input "How do plugins work in Knowhow?"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 5) Key concepts (quick mental model)
|
|
93
|
+
|
|
94
|
+
- **`knowhow.json` (config file)**
|
|
95
|
+
The main project configuration inside `.knowhow/knowhow.json`. It controls:
|
|
96
|
+
- **plugins** (enabled/disabled)
|
|
97
|
+
- **sources** (what to generate and where)
|
|
98
|
+
- **embedSources** (what to embed and where)
|
|
99
|
+
- **embeddingModel**, agents, model providers, worker settings, etc.
|
|
100
|
+
|
|
101
|
+
- **Plugins**
|
|
102
|
+
Small capability modules (e.g., language, git, embeddings, etc.). Knowhow enables/loads them based on `knowhow.json`.
|
|
103
|
+
|
|
104
|
+
- **Sources**
|
|
105
|
+
Inputs that Knowhow can **generate** from. Each source defines things like:
|
|
106
|
+
- `input` glob/pattern
|
|
107
|
+
- `output` path
|
|
108
|
+
- `prompt` template to use
|
|
109
|
+
|
|
110
|
+
- **Embeddings (and `embedSources`)**
|
|
111
|
+
Defines what files to chunk/embed and where to write embedding JSON outputs (typically under `.knowhow/embeddings/`).
|
|
112
|
+
|
|
113
|
+
- **Worker**
|
|
114
|
+
A separate runnable process to execute work in a sandbox/isolated way. You can start/register workers with:
|
|
115
|
+
```bash
|
|
116
|
+
knowhow worker --register
|
|
117
|
+
```
|
|
118
|
+
and manage them with:
|
|
119
|
+
```bash
|
|
120
|
+
knowhow workers --list
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
See you inside the CLI. 👍
|
|
126
|
+
|
|
127
|
+
**Links**
|
|
128
|
+
- https://knowhow.tyvm.ai
|
|
129
|
+
- https://x.com/micahriggan
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
```md
|
|
2
|
+
# Skills Guide (Knowhow CLI)
|
|
3
|
+
|
|
4
|
+
## 1) What skills are
|
|
5
|
+
|
|
6
|
+
**Skills** are reusable instruction sets stored in files named **`SKILL.md`**.
|
|
7
|
+
|
|
8
|
+
When a user’s request mentions the *skill name*, Knowhow loads the matching **full `SKILL.md` content** and injects it into the agent context, so the agent follows your standardized procedure (checklists, commands, rollback plans, etc.).
|
|
9
|
+
|
|
10
|
+
Each `SKILL.md` file must include **frontmatter metadata** at the top so Knowhow can identify and match the skill.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 2) How skills work (SkillsPlugin behavior)
|
|
15
|
+
|
|
16
|
+
Knowhow’s **Skills Plugin** (`src/plugins/SkillsPlugin.ts`) works as follows:
|
|
17
|
+
|
|
18
|
+
1. **Reads configuration** via `getConfig()`.
|
|
19
|
+
2. Loads the configured **skills directories** from `knowhow.json` under a `skills` array.
|
|
20
|
+
3. **Recursively scans** each directory:
|
|
21
|
+
- Searches for any file named **exactly** `SKILL.md`
|
|
22
|
+
- Uses recursive directory traversal (`readdir` + recursion)
|
|
23
|
+
4. **Parses frontmatter** from each `SKILL.md`:
|
|
24
|
+
- Frontmatter must start with:
|
|
25
|
+
```md
|
|
26
|
+
---
|
|
27
|
+
...
|
|
28
|
+
---
|
|
29
|
+
```
|
|
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
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 3) `SKILL.md` format
|
|
58
|
+
|
|
59
|
+
A `SKILL.md` file must contain:
|
|
60
|
+
|
|
61
|
+
### Required frontmatter fields
|
|
62
|
+
- `name` — the skill name (must match what users are likely to say; see substring matching)
|
|
63
|
+
- `description` — a short description shown during discovery
|
|
64
|
+
|
|
65
|
+
### Body content
|
|
66
|
+
Everything after frontmatter is the full instruction set. The plugin injects the **entire file** into context when the skill matches.
|
|
67
|
+
|
|
68
|
+
### Full template
|
|
69
|
+
```md
|
|
70
|
+
---
|
|
71
|
+
name: <skill name>
|
|
72
|
+
description: <short description>
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
# <Section title>
|
|
76
|
+
|
|
77
|
+
Step-by-step instructions...
|
|
78
|
+
|
|
79
|
+
## Examples
|
|
80
|
+
...
|
|
81
|
+
|
|
82
|
+
## Edge cases / gotchas
|
|
83
|
+
...
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Frontmatter example
|
|
87
|
+
```md
|
|
88
|
+
---
|
|
89
|
+
name: deploy
|
|
90
|
+
description: Deploy an application safely with verification and rollback steps.
|
|
91
|
+
---
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 4) Configuring skills
|
|
97
|
+
|
|
98
|
+
Add your skill directories to `knowhow.json` using a `skills` array.
|
|
99
|
+
|
|
100
|
+
Example:
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"plugins": {
|
|
104
|
+
"skills": true
|
|
105
|
+
},
|
|
106
|
+
"skills": [
|
|
107
|
+
"./skills",
|
|
108
|
+
"~/.knowhow/skills"
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Notes:
|
|
114
|
+
- Paths may be relative or absolute.
|
|
115
|
+
- `~` is expanded using the user’s home directory (`process.env.HOME`).
|
|
116
|
+
- The plugin scans **recursively**, so `./skills/<any-folders>/SKILL.md` is fine.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 5) Skill discovery (when no skill matches)
|
|
121
|
+
|
|
122
|
+
If the user request does **not** contain any skill name, Knowhow injects a context item like:
|
|
123
|
+
|
|
124
|
+
- **`Available skills:`**
|
|
125
|
+
- `- <name> (<filePath>): <description>`
|
|
126
|
+
|
|
127
|
+
…and then suggests the user reference a skill by name.
|
|
128
|
+
|
|
129
|
+
**Author takeaway:** choose `name` values that users will naturally include in their requests.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 6) Writing effective skills (best practices)
|
|
134
|
+
|
|
135
|
+
### A) Use clear, natural `name` values
|
|
136
|
+
Because matching is substring-based (`includes()`), avoid names that are likely to match unintentionally.
|
|
137
|
+
|
|
138
|
+
- ✅ Good: `deploy`, `code review`, `database migration`
|
|
139
|
+
- ⚠️ Risky: `run`, `update`, `manage`, `test` (may trigger on many unrelated phrases)
|
|
140
|
+
|
|
141
|
+
### B) Write step-by-step instructions
|
|
142
|
+
Use numbered/structured steps with decision points, e.g.:
|
|
143
|
+
- “If you have X, do A; otherwise do B.”
|
|
144
|
+
|
|
145
|
+
### C) Include copy/paste-ready code examples
|
|
146
|
+
Provide exact commands/snippets with clear placeholders:
|
|
147
|
+
- `APP_NAME`, `NAMESPACE`, `RELEASE_TAG`, `MIGRATION_NAME`, etc.
|
|
148
|
+
|
|
149
|
+
### D) Cover edge cases and failure modes
|
|
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
|
|
156
|
+
|
|
157
|
+
### E) Make the “success criteria” explicit
|
|
158
|
+
Tell the agent what “done” means:
|
|
159
|
+
- expected outputs
|
|
160
|
+
- checklist completion
|
|
161
|
+
- verification queries/commands that must pass
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## 7) Example skills (complete `SKILL.md` files)
|
|
166
|
+
|
|
167
|
+
Below are complete, copyable examples. Save each as **`SKILL.md`** inside a directory included by your `skills` config.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
### Example 1: `deploy` skill
|
|
172
|
+
|
|
173
|
+
**File:** `./skills/deploy/SKILL.md`
|
|
174
|
+
```md
|
|
175
|
+
---
|
|
176
|
+
name: deploy
|
|
177
|
+
description: Deploy an application safely with verification and rollback steps.
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
# Deploy Skill
|
|
181
|
+
|
|
182
|
+
Use this checklist to deploy an application reliably. Tailor steps to your stack (Node/Python/Go/etc.), but keep the flow the same.
|
|
183
|
+
|
|
184
|
+
## 1) Pre-deploy verification
|
|
185
|
+
1. Confirm the target environment:
|
|
186
|
+
- `dev`, `staging`, or `production`
|
|
187
|
+
2. Confirm the artifact/version to deploy:
|
|
188
|
+
- Commit SHA or release tag
|
|
189
|
+
3. Confirm required secrets/config exist:
|
|
190
|
+
- API keys
|
|
191
|
+
- database connection strings
|
|
192
|
+
- environment variables required by the app
|
|
193
|
+
|
|
194
|
+
## 2) Readiness checks
|
|
195
|
+
1. Check current health:
|
|
196
|
+
- Ensure the service is reachable
|
|
197
|
+
2. Check recent errors:
|
|
198
|
+
- Look for failing pods/services/jobs
|
|
199
|
+
3. Estimate downtime expectations:
|
|
200
|
+
- Can deployments be zero-downtime?
|
|
201
|
+
|
|
202
|
+
## 3) Deploy procedure (generic)
|
|
203
|
+
1. Backup/ensure rollback readiness
|
|
204
|
+
- If using containers: ensure you can redeploy the previous image tag
|
|
205
|
+
2. Deploy the new artifact
|
|
206
|
+
- Update deployment manifest / pipeline configuration
|
|
207
|
+
3. Apply changes
|
|
208
|
+
- Run CI/CD or execute deployment commands (examples below)
|
|
209
|
+
|
|
210
|
+
### Example: Kubernetes rollout
|
|
211
|
+
```bash
|
|
212
|
+
kubectl config use-context <context>
|
|
213
|
+
kubectl set image deployment/<app> <container>=<image>:<tag> -n <namespace>
|
|
214
|
+
kubectl rollout status deployment/<app> -n <namespace> --timeout=5m
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Example: Docker Compose
|
|
218
|
+
```bash
|
|
219
|
+
export IMAGE_TAG="<tag>"
|
|
220
|
+
docker compose pull
|
|
221
|
+
docker compose up -d
|
|
222
|
+
docker compose ps
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## 4) Post-deploy verification
|
|
226
|
+
1. Health endpoints
|
|
227
|
+
- Verify `/health` or equivalent returns 200
|
|
228
|
+
2. Smoke tests
|
|
229
|
+
- Login flow (if applicable)
|
|
230
|
+
- Minimal read/write operation
|
|
231
|
+
3. Check logs for startup errors
|
|
232
|
+
- Look for crashes, migrations failing, missing env vars
|
|
233
|
+
|
|
234
|
+
## 5) Rollback plan (define before you need it)
|
|
235
|
+
If verification fails:
|
|
236
|
+
1. Identify the previous version/image
|
|
237
|
+
2. Roll back
|
|
238
|
+
- Kubernetes:
|
|
239
|
+
```bash
|
|
240
|
+
kubectl rollout undo deployment/<app> -n <namespace>
|
|
241
|
+
kubectl rollout status deployment/<app> -n <namespace> --timeout=5m
|
|
242
|
+
```
|
|
243
|
+
- Compose/Docker:
|
|
244
|
+
```bash
|
|
245
|
+
export IMAGE_TAG="<previous-tag>"
|
|
246
|
+
docker compose up -d
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## 6) Report the outcome
|
|
250
|
+
Provide:
|
|
251
|
+
- Environment name
|
|
252
|
+
- Version/artifact deployed
|
|
253
|
+
- Verification results (what succeeded)
|
|
254
|
+
- Any follow-up tasks or incidents
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### Example 2: `code review` skill (checklist)
|
|
260
|
+
|
|
261
|
+
**File:** `./skills/code-review/SKILL.md`
|
|
262
|
+
```md
|
|
263
|
+
---
|
|
264
|
+
name: code review
|
|
265
|
+
description: Perform a structured code review with correctness, security, and style checks.
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
# Code Review Skill
|
|
269
|
+
|
|
270
|
+
Use this checklist for reviewing PRs or patches. If you lack context (language/framework/test coverage), ask targeted questions.
|
|
271
|
+
|
|
272
|
+
## 0) First pass (understand)
|
|
273
|
+
1. What is the change trying to accomplish?
|
|
274
|
+
2. Does the change align with the existing codebase patterns?
|
|
275
|
+
3. Are there any new dependencies or risky integrations?
|
|
276
|
+
|
|
277
|
+
## 1) Correctness & behavior
|
|
278
|
+
- [ ] All intended behaviors are implemented
|
|
279
|
+
- [ ] Edge cases are handled (empty input, nulls, timeouts, boundaries)
|
|
280
|
+
- [ ] Error handling is consistent and actionable
|
|
281
|
+
- [ ] Tests exist and cover the changed logic
|
|
282
|
+
- [ ] Performance implications are understood (e.g., new loops, DB queries)
|
|
283
|
+
|
|
284
|
+
## 2) Security review
|
|
285
|
+
- [ ] Input validation is present where needed
|
|
286
|
+
- [ ] Secrets are not logged or exposed
|
|
287
|
+
- [ ] AuthZ/AuthN is enforced (no missing permission checks)
|
|
288
|
+
- [ ] Injection risks are mitigated (SQL/command/template)
|
|
289
|
+
- [ ] File/path handling is safe (no traversal)
|
|
290
|
+
|
|
291
|
+
## 3) API / interface correctness
|
|
292
|
+
- [ ] Contracts are updated consistently (types, docs, callers)
|
|
293
|
+
- [ ] Backwards compatibility is preserved if required
|
|
294
|
+
- [ ] Status codes / error shapes are stable
|
|
295
|
+
|
|
296
|
+
## 4) Code quality & maintainability
|
|
297
|
+
- [ ] Naming is clear and consistent
|
|
298
|
+
- [ ] Complexity is reasonable; no deeply nested logic
|
|
299
|
+
- [ ] Duplicated logic is refactored when appropriate
|
|
300
|
+
- [ ] Comments explain “why”, not “what”
|
|
301
|
+
|
|
302
|
+
## 5) Tests
|
|
303
|
+
- [ ] Unit tests cover core logic
|
|
304
|
+
- [ ] Integration tests cover boundaries (DB/network/interfaces)
|
|
305
|
+
- [ ] Test data is minimal and deterministic
|
|
306
|
+
- [ ] Flaky tests are avoided
|
|
307
|
+
|
|
308
|
+
## 6) Documentation
|
|
309
|
+
- [ ] README or inline docs updated if user-facing behavior changed
|
|
310
|
+
- [ ] Migration notes added when needed
|
|
311
|
+
- [ ] Examples updated
|
|
312
|
+
|
|
313
|
+
## 7) Final response format
|
|
314
|
+
Return the review as:
|
|
315
|
+
|
|
316
|
+
1. Summary of key changes
|
|
317
|
+
2. Must-fix issues (severity: critical/high)
|
|
318
|
+
3. Should-fix issues (medium/low)
|
|
319
|
+
4. Nice-to-have improvements
|
|
320
|
+
5. Suggested diffs (if possible) or questions for the author
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
### Example 3: `database migration` skill
|
|
326
|
+
|
|
327
|
+
**File:** `./skills/db-migration/SKILL.md`
|
|
328
|
+
```md
|
|
329
|
+
---
|
|
330
|
+
name: database migration
|
|
331
|
+
description: Plan and execute a safe database migration with validation and rollback.
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
# Database Migration Skill
|
|
335
|
+
|
|
336
|
+
Use this playbook to design and run a database migration safely in real environments.
|
|
337
|
+
|
|
338
|
+
## 1) Clarify migration intent
|
|
339
|
+
Answer:
|
|
340
|
+
1. What schema change is required? (add/rename/remove column/table, indexes, constraints)
|
|
341
|
+
2. Does it require data backfill?
|
|
342
|
+
3. Is it online/zero-downtime or will it incur downtime?
|
|
343
|
+
|
|
344
|
+
## 2) Safety prerequisites
|
|
345
|
+
- Ensure you have:
|
|
346
|
+
- A backup strategy (automated snapshot or external backup)
|
|
347
|
+
- A way to rollback (or a forward-fix plan if rollback is unsafe)
|
|
348
|
+
- Confirm:
|
|
349
|
+
- Migration tool (e.g., Alembic, Flyway, Liquibase, Rails)
|
|
350
|
+
- Database engine (Postgres/MySQL/etc.)
|
|
351
|
+
- Staging validation environment mirrors production settings
|
|
352
|
+
|
|
353
|
+
## 3) Use a safe migration pattern
|
|
354
|
+
Common safe approach for risky changes:
|
|
355
|
+
1. Additive first
|
|
356
|
+
- Add new columns/constraints as nullable or non-enforcing
|
|
357
|
+
2. Backfill
|
|
358
|
+
- Populate existing rows with a controlled job
|
|
359
|
+
3. Validate
|
|
360
|
+
- Confirm data correctness (counts, null rates, invariants)
|
|
361
|
+
4. Switch reads/writes
|
|
362
|
+
- Update application code to use the new schema
|
|
363
|
+
5. Finalize
|
|
364
|
+
- Tighten constraints (NOT NULL, FK constraints, unique indexes)
|
|
365
|
+
6. Clean up
|
|
366
|
+
- Remove old columns after a safe window
|
|
367
|
+
|
|
368
|
+
## 4) Concrete checklist
|
|
369
|
+
|
|
370
|
+
### Schema change checklist
|
|
371
|
+
- [ ] Avoid dropping columns/constraints in the first pass if downtime is not acceptable
|
|
372
|
+
- [ ] Prefer “expand/contract” patterns when possible
|
|
373
|
+
- [ ] Index changes are planned to avoid locking storms
|
|
374
|
+
|
|
375
|
+
### Backfill checklist
|
|
376
|
+
- [ ] Batch updates (avoid locking large tables)
|
|
377
|
+
- [ ] Add progress logging
|
|
378
|
+
- [ ] Validate after backfill (row counts, distribution checks)
|
|
379
|
+
|
|
380
|
+
### Verification checklist
|
|
381
|
+
- [ ] Run migration in staging first
|
|
382
|
+
- [ ] Confirm application health (no errors on startup)
|
|
383
|
+
- [ ] Verify critical queries
|
|
384
|
+
|
|
385
|
+
### Rollback checklist
|
|
386
|
+
Choose one:
|
|
387
|
+
- [ ] True rollback supported by the migration tool
|
|
388
|
+
- [ ] Or forward-only correction plan (recommended if true rollback is unsafe)
|
|
389
|
+
|
|
390
|
+
## 5) Example SQL patterns (Postgres)
|
|
391
|
+
|
|
392
|
+
### Add nullable column + backfill + enforce NOT NULL
|
|
393
|
+
```sql
|
|
394
|
+
-- 1) Expand: add column as nullable
|
|
395
|
+
ALTER TABLE users ADD COLUMN email_normalized text;
|
|
396
|
+
|
|
397
|
+
-- 2) Backfill in a controlled way (example)
|
|
398
|
+
UPDATE users
|
|
399
|
+
SET email_normalized = lower(email)
|
|
400
|
+
WHERE email_normalized IS NULL;
|
|
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;
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Create index with lower blocking risk (conceptual)
|
|
410
|
+
```sql
|
|
411
|
+
-- If supported, use CONCURRENTLY to reduce blocking
|
|
412
|
+
CREATE INDEX CONCURRENTLY idx_users_email_normalized
|
|
413
|
+
ON users(email_normalized);
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
## 6) What to output as the agent response
|
|
417
|
+
Provide:
|
|
418
|
+
- Migration plan (phases)
|
|
419
|
+
- Estimated risk level and why
|
|
420
|
+
- Exact commands (tool-specific)
|
|
421
|
+
- Validation queries/tests
|
|
422
|
+
- Rollback or forward-fix plan
|
|
423
|
+
- Execution order and required application deploy timing
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
## 8) Global skills
|
|
429
|
+
|
|
430
|
+
To reuse skills across multiple projects, store them in:
|
|
431
|
+
|
|
432
|
+
**`~/.knowhow/skills/`**
|
|
433
|
+
|
|
434
|
+
Then ensure your `knowhow.json` includes that directory in the `skills` array, for example:
|
|
435
|
+
```json
|
|
436
|
+
{
|
|
437
|
+
"skills": [
|
|
438
|
+
"~/.knowhow/skills"
|
|
439
|
+
]
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
Recommended structure (nested organization is fine because scanning is recursive):
|
|
444
|
+
```text
|
|
445
|
+
~/.knowhow/skills/
|
|
446
|
+
deploy/
|
|
447
|
+
SKILL.md
|
|
448
|
+
code-review/
|
|
449
|
+
SKILL.md
|
|
450
|
+
db-migration/
|
|
451
|
+
SKILL.md
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
The plugin does not require the folder name to match the skill name—only the `SKILL.md` frontmatter `name` matters.
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## Summary checklist (quick reference)
|
|
459
|
+
|
|
460
|
+
- ✅ Name skill file: **`SKILL.md`**
|
|
461
|
+
- ✅ Add frontmatter at the top:
|
|
462
|
+
- `name: ...`
|
|
463
|
+
- `description: ...`
|
|
464
|
+
- ✅ Write clear step-by-step instructions + examples
|
|
465
|
+
- ✅ Include edge cases / rollback / verification
|
|
466
|
+
- ✅ Configure directories in `knowhow.json` under `skills`
|
|
467
|
+
- ✅ For global reuse, use `~/.knowhow/skills/`
|
|
468
|
+
```
|