@nano-step/skill-manager 4.0.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/README.md +218 -0
- package/bin/cli.js +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +34 -0
- package/dist/install.d.ts +1 -0
- package/dist/install.js +35 -0
- package/dist/remove.d.ts +1 -0
- package/dist/remove.js +32 -0
- package/dist/update.d.ts +1 -0
- package/dist/update.js +53 -0
- package/dist/utils.d.ts +30 -0
- package/dist/utils.js +154 -0
- package/package.json +47 -0
- package/templates/agent.json +11 -0
- package/templates/command-refresh.md +100 -0
- package/templates/command-workflow.md +188 -0
- package/templates/skill/SKILL.md +284 -0
- package/templates/skill/assets/tools-template.json +140 -0
- package/templates/skill/assets/workflow-schema.json +81 -0
- package/templates/skill/assets/workflow-templates.json +112 -0
- package/templates/skill/references/error-handling.md +260 -0
- package/templates/skill/references/result-handling.md +242 -0
- package/templates/skill/references/tool-categories.md +247 -0
- package/templates/skill/references/tool-execution.md +347 -0
- package/templates/skill/references/workflows.md +233 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
# Agent Skill Tool Execution Reference
|
|
2
|
+
# Scope: cache usage, routing, parameter mapping, orchestration.
|
|
3
|
+
# Do not include category catalogs, result summarization, or error templates here.
|
|
4
|
+
|
|
5
|
+
## Cache Access and Reading
|
|
6
|
+
Cache location: .opencode/agent-skill-tools.json
|
|
7
|
+
Purpose: fast tool routing without reloading full MCP schemas.
|
|
8
|
+
|
|
9
|
+
How to read the cache:
|
|
10
|
+
1. Check if file exists at project root `.opencode/agent-skill-tools.json`.
|
|
11
|
+
2. Parse JSON into a structured object.
|
|
12
|
+
3. Validate minimal fields: version, refreshed_at, tool_count, categories.
|
|
13
|
+
4. If missing or malformed, fall back to dynamic discovery.
|
|
14
|
+
|
|
15
|
+
Cache staleness heuristic:
|
|
16
|
+
- If refreshed_at is older than 24 hours, prefer refresh for long sessions.
|
|
17
|
+
- For short sessions, use cache but mention staleness when routing is ambiguous.
|
|
18
|
+
|
|
19
|
+
## Cache Schema (TypeScript Interface)
|
|
20
|
+
```ts
|
|
21
|
+
interface AgentSkillToolCache {
|
|
22
|
+
version: string;
|
|
23
|
+
refreshed_at: string; // ISO string
|
|
24
|
+
mcp_servers: string[];
|
|
25
|
+
tool_count: number;
|
|
26
|
+
categories: {
|
|
27
|
+
[name: string]: {
|
|
28
|
+
description: string;
|
|
29
|
+
keywords: string[];
|
|
30
|
+
tools: Array<{
|
|
31
|
+
id: string; // tool id or fully qualified name
|
|
32
|
+
description: string; // short summary
|
|
33
|
+
prefix?: string; // optional server prefix
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
uncategorized: Array<{
|
|
38
|
+
id: string;
|
|
39
|
+
description: string;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Routing Algorithm (4 Steps)
|
|
45
|
+
Step 1: Parse intent
|
|
46
|
+
- Extract verbs, objects, constraints, and explicit tool hints.
|
|
47
|
+
- Normalize to lowercase tokens.
|
|
48
|
+
|
|
49
|
+
Step 2: Match category
|
|
50
|
+
- Match extracted tokens against category keywords.
|
|
51
|
+
- Prefer explicit prefix matches (e.g., MetaMCP_chrome-devtools__).
|
|
52
|
+
- If multiple categories match, choose the one with highest keyword hits.
|
|
53
|
+
|
|
54
|
+
Step 3: Select tool
|
|
55
|
+
- Scan matched category tools for semantic match.
|
|
56
|
+
- Prefer exact tool-name hints from user text.
|
|
57
|
+
- If multiple tools plausible, choose most specific or ask for clarification.
|
|
58
|
+
|
|
59
|
+
Step 4: Execute
|
|
60
|
+
- Load tool schema (from cache or tool registry).
|
|
61
|
+
- Map parameters from intent to schema fields.
|
|
62
|
+
- Execute tool and return summarized output.
|
|
63
|
+
|
|
64
|
+
## Parameter Mapping Patterns
|
|
65
|
+
Mapping strategy:
|
|
66
|
+
- Match explicit parameter names in user text (uid, pageId, owner, repo).
|
|
67
|
+
- Convert common user phrases into schema fields.
|
|
68
|
+
- Use defaults only when tool schema allows optional params.
|
|
69
|
+
|
|
70
|
+
Common patterns:
|
|
71
|
+
- page selection
|
|
72
|
+
- "use page 2" -> { pageId: 2 }
|
|
73
|
+
- "open new tab" -> new_page { url: ... }
|
|
74
|
+
- element targeting
|
|
75
|
+
- "click uid btn-1" -> click { uid: "btn-1" }
|
|
76
|
+
- "drag a to b" -> drag { from_uid: "a", to_uid: "b" }
|
|
77
|
+
- navigation
|
|
78
|
+
- "go to https://x" -> navigate_page { type: "url", url: "https://x" }
|
|
79
|
+
- "reload hard" -> navigate_page { type: "reload", ignoreCache: true }
|
|
80
|
+
- network/console
|
|
81
|
+
- "show last xhr" -> list_network_requests { resourceTypes: ["xhr"] }
|
|
82
|
+
- "console errors" -> list_console_messages { types: ["error"] }
|
|
83
|
+
- GitHub
|
|
84
|
+
- "PR 123 in owner/repo" -> get_pull_request { owner, repo, pull_number: 123 }
|
|
85
|
+
- "issues labeled bug" -> list_issues { labels: ["bug"], state: "open" }
|
|
86
|
+
- GraphQL
|
|
87
|
+
- "list mutations" -> filter_mutations { search?: "" }
|
|
88
|
+
- "type User details" -> get_type_details { type_name: "User" }
|
|
89
|
+
- Docs
|
|
90
|
+
- "docs for react useState" -> resolve-library-id then query-docs
|
|
91
|
+
- Reasoning
|
|
92
|
+
- "analyze step by step" -> sequentialthinking with incrementing thoughtNumber
|
|
93
|
+
|
|
94
|
+
## Multi-Tool Orchestration
|
|
95
|
+
Use when a task requires sequential dependencies or cross-category steps.
|
|
96
|
+
|
|
97
|
+
Example 1: Browser + Console
|
|
98
|
+
1. take_snapshot -> get uid for button
|
|
99
|
+
2. click -> trigger action
|
|
100
|
+
3. list_console_messages -> capture errors
|
|
101
|
+
|
|
102
|
+
Example 2: Docs resolution chain
|
|
103
|
+
1. resolve-library-id -> get libraryId
|
|
104
|
+
2. query-docs -> retrieve examples
|
|
105
|
+
|
|
106
|
+
Example 3: GraphQL discovery + detail
|
|
107
|
+
1. filter_queries -> list query fields
|
|
108
|
+
2. get_field_details -> inspect specific query
|
|
109
|
+
|
|
110
|
+
Example 4: GitHub PR inspection
|
|
111
|
+
1. get_pull_request -> summary
|
|
112
|
+
2. get_pull_request_files -> file list
|
|
113
|
+
3. get_pull_request_status -> checks
|
|
114
|
+
|
|
115
|
+
## Cache vs Dynamic Discovery
|
|
116
|
+
Prefer cache when:
|
|
117
|
+
- Tool cache exists and is fresh.
|
|
118
|
+
- Task maps to known categories.
|
|
119
|
+
- The agent must be fast and token-efficient.
|
|
120
|
+
|
|
121
|
+
Prefer dynamic discovery when:
|
|
122
|
+
- Cache missing or malformed.
|
|
123
|
+
- Tools are new or recently updated.
|
|
124
|
+
- Task uses an uncategorized or unknown prefix.
|
|
125
|
+
|
|
126
|
+
Hybrid approach:
|
|
127
|
+
- Use cache for category match.
|
|
128
|
+
- Validate against runtime tool registry when exact tool names are needed.
|
|
129
|
+
|
|
130
|
+
## Execution Guardrails
|
|
131
|
+
- Ensure tool parameters match required schema types.
|
|
132
|
+
- Avoid passing undefined fields.
|
|
133
|
+
- For optional params, include only when explicitly set or needed.
|
|
134
|
+
- If user input is ambiguous, request clarification rather than guessing.
|
|
135
|
+
|
|
136
|
+
## Orchestration Output Format (Internal)
|
|
137
|
+
- Selected category
|
|
138
|
+
- Selected tool name
|
|
139
|
+
- Input parameters
|
|
140
|
+
- Dependent steps (if any)
|
|
141
|
+
- Execution order
|
|
142
|
+
|
|
143
|
+
Example internal routing trace:
|
|
144
|
+
```
|
|
145
|
+
intent: ["screenshot", "login page"]
|
|
146
|
+
category: browser
|
|
147
|
+
tool: MetaMCP_chrome-devtools__take_screenshot
|
|
148
|
+
params: { fullPage: true }
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## When to Use the Cache
|
|
152
|
+
- For repeated routing in a session.
|
|
153
|
+
- For large tool inventories where scanning the registry is expensive.
|
|
154
|
+
- For well-known categories and stable tool names.
|
|
155
|
+
|
|
156
|
+
## When to Avoid Cache
|
|
157
|
+
- During tool upgrades or when discrepancies are reported.
|
|
158
|
+
- When a tool id from cache fails execution.
|
|
159
|
+
- When the user references a new MCP server prefix.
|
|
160
|
+
|
|
161
|
+
## Execution Prerequisites
|
|
162
|
+
- Ensure selected tool exists in cache or registry.
|
|
163
|
+
- Confirm required parameters are present.
|
|
164
|
+
- Confirm required page context for browser tools.
|
|
165
|
+
- Validate file paths for uploads or outputs when required.
|
|
166
|
+
|
|
167
|
+
## Execution Patterns
|
|
168
|
+
Simple single-call execution:
|
|
169
|
+
1. Select tool
|
|
170
|
+
2. Map params
|
|
171
|
+
3. Execute
|
|
172
|
+
4. Return summarized output
|
|
173
|
+
|
|
174
|
+
Dependent execution:
|
|
175
|
+
1. Execute prerequisite tool
|
|
176
|
+
2. Extract identifiers
|
|
177
|
+
3. Execute dependent tool
|
|
178
|
+
4. Summarize combined result
|
|
179
|
+
|
|
180
|
+
Conditional execution:
|
|
181
|
+
1. Try preferred tool
|
|
182
|
+
2. If mismatch, choose fallback tool
|
|
183
|
+
3. Execute fallback and report reason
|
|
184
|
+
|
|
185
|
+
## Parameter Mapping Examples
|
|
186
|
+
Browser example:
|
|
187
|
+
```
|
|
188
|
+
User: "Click the submit button"
|
|
189
|
+
Steps: take_snapshot -> find uid -> click { uid }
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
GitHub example:
|
|
193
|
+
```
|
|
194
|
+
User: "List open PRs for owner/repo"
|
|
195
|
+
Tool: list_pull_requests { owner, repo, state: "open" }
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
GraphQL example:
|
|
199
|
+
```
|
|
200
|
+
User: "Show mutations containing auth"
|
|
201
|
+
Tool: filter_mutations { search: "auth" }
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Docs example:
|
|
205
|
+
```
|
|
206
|
+
User: "Docs for Next.js app router"
|
|
207
|
+
Tool 1: resolve-library-id { libraryName: "next.js", query: "app router" }
|
|
208
|
+
Tool 2: query-docs { libraryId, query: "app router" }
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Reasoning example:
|
|
212
|
+
```
|
|
213
|
+
User: "Break down this decision"
|
|
214
|
+
Tool: sequentialthinking { thought: "...", thoughtNumber: 1, totalThoughts: 4, nextThoughtNeeded: true }
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Parameter Validation Checklist
|
|
218
|
+
- [ ] Required params present
|
|
219
|
+
- [ ] Types match schema (number, string, boolean, arrays)
|
|
220
|
+
- [ ] Optional params omitted unless specified
|
|
221
|
+
- [ ] Enumerations validated (resourceTypes, state, sort)
|
|
222
|
+
|
|
223
|
+
## Orchestration Batching Guidance
|
|
224
|
+
- Chain tools only when outputs are required for the next step.
|
|
225
|
+
- Avoid parallel execution when steps depend on a prior result.
|
|
226
|
+
- Provide a short plan when multiple steps are needed.
|
|
227
|
+
|
|
228
|
+
## Dynamic Discovery Trigger Conditions
|
|
229
|
+
- Cache not available
|
|
230
|
+
- Tool id in cache but missing in registry
|
|
231
|
+
- User mentions an unrecognized prefix
|
|
232
|
+
- Tool description seems outdated
|
|
233
|
+
|
|
234
|
+
## Cache Refresh Recommendation Text
|
|
235
|
+
Recommended message:
|
|
236
|
+
```
|
|
237
|
+
Cache appears stale or missing. Run /agent-skill-refresh to rebuild tool metadata.
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Execution Output Metadata (Internal)
|
|
241
|
+
- timestamp
|
|
242
|
+
- tool id
|
|
243
|
+
- duration (if available)
|
|
244
|
+
- success/failure flag
|
|
245
|
+
- raw result size
|
|
246
|
+
|
|
247
|
+
## Execution Guardrails (Supplement)
|
|
248
|
+
- Do not invent parameters not supported by schema.
|
|
249
|
+
- Do not auto-retry on non-idempotent actions.
|
|
250
|
+
- For write actions, confirm target path when ambiguous.
|
|
251
|
+
|
|
252
|
+
## Batch Execution
|
|
253
|
+
|
|
254
|
+
Execute multiple tools in a single request for efficiency.
|
|
255
|
+
|
|
256
|
+
### Batch Syntax
|
|
257
|
+
```
|
|
258
|
+
BATCH: [
|
|
259
|
+
{"tool": "tool_name", "params": {...}},
|
|
260
|
+
{"tool": "tool_name2", "params": {...}}
|
|
261
|
+
]
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Batch Execution Flow
|
|
265
|
+
1. Parse BATCH JSON array
|
|
266
|
+
2. Validate all tool names exist
|
|
267
|
+
3. Execute tools sequentially (order preserved)
|
|
268
|
+
4. Collect results into array
|
|
269
|
+
5. Return combined results
|
|
270
|
+
|
|
271
|
+
### Batch Result Format
|
|
272
|
+
```json
|
|
273
|
+
[
|
|
274
|
+
{"tool": "screenshot", "status": "success", "result": {...}},
|
|
275
|
+
{"tool": "get_title", "status": "success", "result": "Page Title"}
|
|
276
|
+
]
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Batch Limits
|
|
280
|
+
- Maximum 10 tools per batch
|
|
281
|
+
- Each tool has independent retry budget
|
|
282
|
+
- Partial failures don't abort batch
|
|
283
|
+
|
|
284
|
+
## Tool Chaining
|
|
285
|
+
|
|
286
|
+
Execute tools in sequence with output passing between them.
|
|
287
|
+
|
|
288
|
+
### Chain Syntax
|
|
289
|
+
```
|
|
290
|
+
CHAIN: [
|
|
291
|
+
{"tool": "get_element", "params": {"selector": "#btn"}, "output_as": "element"},
|
|
292
|
+
{"tool": "click", "params": {"target": "$element"}}
|
|
293
|
+
]
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Variable Binding
|
|
297
|
+
- `output_as`: Store tool output in named variable
|
|
298
|
+
- `$varname`: Reference stored variable in params
|
|
299
|
+
- `$varname.field`: Access nested field in stored output
|
|
300
|
+
|
|
301
|
+
### Chain Execution Flow
|
|
302
|
+
1. Parse CHAIN JSON array
|
|
303
|
+
2. Execute first tool
|
|
304
|
+
3. Store output in variable (if output_as specified)
|
|
305
|
+
4. Substitute $variables in next tool's params
|
|
306
|
+
5. Execute next tool
|
|
307
|
+
6. Repeat until chain complete or failure
|
|
308
|
+
|
|
309
|
+
### Chain Failure Handling
|
|
310
|
+
```json
|
|
311
|
+
{
|
|
312
|
+
"completed": [{"tool": "A", "result": {...}}],
|
|
313
|
+
"failed": {"tool": "B", "error": "element not found"},
|
|
314
|
+
"skipped": ["C", "D"]
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Chain Limits
|
|
319
|
+
- Maximum 5 tools per chain
|
|
320
|
+
- Chain aborts on first failure
|
|
321
|
+
- Partial results preserved
|
|
322
|
+
|
|
323
|
+
## Direct Passthrough
|
|
324
|
+
|
|
325
|
+
Skip routing for known tool names.
|
|
326
|
+
|
|
327
|
+
### Detection Pattern
|
|
328
|
+
Tool name contains `__` (double underscore) → passthrough mode
|
|
329
|
+
|
|
330
|
+
### Passthrough Examples
|
|
331
|
+
```
|
|
332
|
+
MetaMCP_chrome-devtools__take_screenshot → execute directly
|
|
333
|
+
MetaMCP_github__get_pull_request {"owner": "x", "repo": "y"} → execute with params
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Passthrough Benefits
|
|
337
|
+
- No cache lookup overhead
|
|
338
|
+
- No category matching
|
|
339
|
+
- Fastest execution path
|
|
340
|
+
|
|
341
|
+
## Quick Checklist
|
|
342
|
+
- [ ] Cache loaded or fallback chosen.
|
|
343
|
+
- [ ] Intent tokens extracted.
|
|
344
|
+
- [ ] Category matched by keywords or prefix.
|
|
345
|
+
- [ ] Tool selected with minimal ambiguity.
|
|
346
|
+
- [ ] Parameters mapped to schema.
|
|
347
|
+
- [ ] Execute and return result summary.
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Agent Skill Workflow Reference
|
|
2
|
+
|
|
3
|
+
Define prerequisite steps that automatically execute before certain tool operations.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Workflows enforce best practices by requiring prerequisite steps before tool execution. For example, always inspect database structure before running queries, or take a page snapshot before clicking elements.
|
|
8
|
+
|
|
9
|
+
## Workflow Schema
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"workflow-name": {
|
|
14
|
+
"enabled": true,
|
|
15
|
+
"description": "Human-readable description",
|
|
16
|
+
"triggers": {
|
|
17
|
+
"category": "database",
|
|
18
|
+
"tools": ["execute_query", "select_query"],
|
|
19
|
+
"keywords": ["query", "select", "insert"]
|
|
20
|
+
},
|
|
21
|
+
"prerequisites": [
|
|
22
|
+
{
|
|
23
|
+
"step": 1,
|
|
24
|
+
"tool": "list_databases",
|
|
25
|
+
"description": "List available databases",
|
|
26
|
+
"required": true
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"step": 2,
|
|
30
|
+
"tool": "list_tables",
|
|
31
|
+
"description": "List tables in database",
|
|
32
|
+
"required": true
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"mode": "enforce",
|
|
36
|
+
"created_at": "2026-02-04T..."
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Trigger Types
|
|
42
|
+
|
|
43
|
+
Workflows trigger when ANY condition matches (OR logic):
|
|
44
|
+
|
|
45
|
+
| Trigger | Description | Example |
|
|
46
|
+
|---------|-------------|---------|
|
|
47
|
+
| `category` | Tool belongs to this category | `"database"` |
|
|
48
|
+
| `tools` | Tool name is in this list | `["execute_query", "select_query"]` |
|
|
49
|
+
| `keywords` | Task text contains these words | `["query", "select"]` |
|
|
50
|
+
|
|
51
|
+
## Execution Modes
|
|
52
|
+
|
|
53
|
+
| Mode | Behavior | Use Case |
|
|
54
|
+
|------|----------|----------|
|
|
55
|
+
| `enforce` | Auto-run prerequisites before main action | Critical safety (database, destructive ops) |
|
|
56
|
+
| `warn` | Show warning, allow skip | Important but skippable |
|
|
57
|
+
| `suggest` | Mention prerequisites, don't block | Nice-to-have patterns |
|
|
58
|
+
|
|
59
|
+
## Prerequisite Definition
|
|
60
|
+
|
|
61
|
+
Each prerequisite step has:
|
|
62
|
+
|
|
63
|
+
| Field | Required | Description |
|
|
64
|
+
|-------|----------|-------------|
|
|
65
|
+
| `step` | Yes | Execution order (1-based) |
|
|
66
|
+
| `tool` | Yes | Tool name to execute |
|
|
67
|
+
| `description` | Yes | Why this step is needed |
|
|
68
|
+
| `required` | No | Can this step be skipped? (default: true) |
|
|
69
|
+
| `params` | No | Default parameters for the tool |
|
|
70
|
+
|
|
71
|
+
## Session State
|
|
72
|
+
|
|
73
|
+
Completed prerequisites are tracked in `.opencode/.agent-skill-session.json`:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"session_id": "abc123",
|
|
78
|
+
"started_at": "2026-02-04T10:00:00Z",
|
|
79
|
+
"completed": {
|
|
80
|
+
"database-safe-query": {
|
|
81
|
+
"list_databases": {
|
|
82
|
+
"at": "2026-02-04T10:05:00Z",
|
|
83
|
+
"result": "Found 3 databases: main, analytics, test"
|
|
84
|
+
},
|
|
85
|
+
"list_tables": {
|
|
86
|
+
"at": "2026-02-04T10:05:30Z",
|
|
87
|
+
"result": "Found 12 tables in main"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Session Rules
|
|
95
|
+
|
|
96
|
+
- Prerequisites only run once per session per workflow
|
|
97
|
+
- Session expires after 24 hours (configurable)
|
|
98
|
+
- New session clears all completion state
|
|
99
|
+
- Result summaries are truncated to 200 chars
|
|
100
|
+
|
|
101
|
+
## Built-in Templates
|
|
102
|
+
|
|
103
|
+
### Database Template
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
{
|
|
107
|
+
"name": "database-safe-query",
|
|
108
|
+
"triggers": {
|
|
109
|
+
"category": "database",
|
|
110
|
+
"keywords": ["query", "select", "insert", "update", "delete"]
|
|
111
|
+
},
|
|
112
|
+
"prerequisites": [
|
|
113
|
+
{"step": 1, "tool": "list_databases", "description": "Know available databases"},
|
|
114
|
+
{"step": 2, "tool": "list_tables", "description": "Know table structure"},
|
|
115
|
+
{"step": 3, "tool": "inspect_table", "description": "Check columns and types"},
|
|
116
|
+
{"step": 4, "tool": "get_indexes", "description": "Check indexes", "required": false}
|
|
117
|
+
],
|
|
118
|
+
"mode": "enforce"
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Browser Template
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"name": "browser-safe-interaction",
|
|
127
|
+
"triggers": {
|
|
128
|
+
"category": "browser",
|
|
129
|
+
"tools": ["click", "fill", "submit"]
|
|
130
|
+
},
|
|
131
|
+
"prerequisites": [
|
|
132
|
+
{"step": 1, "tool": "take_snapshot", "description": "Capture page state and UIDs"}
|
|
133
|
+
],
|
|
134
|
+
"mode": "enforce"
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### GitHub PR Template
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"name": "github-pr-review",
|
|
143
|
+
"triggers": {
|
|
144
|
+
"tools": ["merge_pull_request", "create_pull_request_review"]
|
|
145
|
+
},
|
|
146
|
+
"prerequisites": [
|
|
147
|
+
{"step": 1, "tool": "get_pull_request", "description": "Get PR details"},
|
|
148
|
+
{"step": 2, "tool": "get_pull_request_files", "description": "List changed files"},
|
|
149
|
+
{"step": 3, "tool": "get_pull_request_status", "description": "Check CI status"}
|
|
150
|
+
],
|
|
151
|
+
"mode": "warn"
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Workflow Execution Flow
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
Task: "Query all users with status active"
|
|
159
|
+
│
|
|
160
|
+
├─ 1. Check for workflow triggers
|
|
161
|
+
│ └─ Match: "database-safe-query" (keyword: "query")
|
|
162
|
+
│
|
|
163
|
+
├─ 2. Check session state
|
|
164
|
+
│ └─ Prerequisites not completed
|
|
165
|
+
│
|
|
166
|
+
├─ 3. Mode is "enforce" → Run prerequisites
|
|
167
|
+
│ ├─ Step 1: list_databases → "3 databases found"
|
|
168
|
+
│ ├─ Step 2: list_tables → "users, orders, products"
|
|
169
|
+
│ └─ Step 3: inspect_table → "id, name, email, status"
|
|
170
|
+
│
|
|
171
|
+
├─ 4. Update session state
|
|
172
|
+
│
|
|
173
|
+
└─ 5. Execute main action
|
|
174
|
+
└─ SELECT * FROM users WHERE status = 'active'
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Error Handling
|
|
178
|
+
|
|
179
|
+
### Prerequisite Failure
|
|
180
|
+
|
|
181
|
+
If a prerequisite fails:
|
|
182
|
+
1. Retry mechanism applies (3 attempts)
|
|
183
|
+
2. If all retries fail, workflow aborts
|
|
184
|
+
3. Error report includes which step failed
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
Workflow 'database-safe-query' failed at step 2 (list_tables):
|
|
188
|
+
Error: Connection refused
|
|
189
|
+
Suggestion: Check database connection settings
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Multiple Workflow Matches
|
|
193
|
+
|
|
194
|
+
If multiple workflows match:
|
|
195
|
+
1. First defined workflow is used
|
|
196
|
+
2. Warning logged about conflict
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
Multiple workflows matched. Using 'database-safe-query'.
|
|
200
|
+
Also matched: 'custom-db-workflow'
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Managing Workflows
|
|
204
|
+
|
|
205
|
+
Use `/agent-skill-workflow` command:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# List all workflows
|
|
209
|
+
/agent-skill-workflow list
|
|
210
|
+
|
|
211
|
+
# Add from template
|
|
212
|
+
/agent-skill-workflow add --template database
|
|
213
|
+
|
|
214
|
+
# Add custom workflow
|
|
215
|
+
/agent-skill-workflow add my-workflow
|
|
216
|
+
|
|
217
|
+
# Edit existing
|
|
218
|
+
/agent-skill-workflow edit my-workflow
|
|
219
|
+
|
|
220
|
+
# Disable temporarily
|
|
221
|
+
/agent-skill-workflow disable my-workflow
|
|
222
|
+
|
|
223
|
+
# Remove
|
|
224
|
+
/agent-skill-workflow remove my-workflow
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Best Practices
|
|
228
|
+
|
|
229
|
+
1. **Start with templates** - Use built-in templates, customize as needed
|
|
230
|
+
2. **Use enforce sparingly** - Only for critical safety workflows
|
|
231
|
+
3. **Keep prerequisites minimal** - Each step adds latency
|
|
232
|
+
4. **Mark optional steps** - Use `required: false` for nice-to-have steps
|
|
233
|
+
5. **Review session state** - Check `.agent-skill-session.json` if prerequisites seem stuck
|