@zalom/plastic 1.0.0-beta.8 → 1.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.
Files changed (116) hide show
  1. package/PLASTIC-reference.md +133 -0
  2. package/PLASTIC.md +407 -84
  3. package/README.md +99 -82
  4. package/agents/plastic-brainstorming.md +12 -9
  5. package/agents/plastic-enforcer.md +52 -12
  6. package/agents/plastic-executor.md +10 -10
  7. package/agents/plastic-future-intent-researcher.md +4 -8
  8. package/agents/plastic-intent-curator.md +12 -14
  9. package/agents/plastic-intent-discovery.md +35 -0
  10. package/agents/plastic-planner.md +15 -10
  11. package/agents/plastic-spec-specialist.md +15 -10
  12. package/bin/plastic.js +7 -3
  13. package/hooks/code-gate +10 -1
  14. package/hooks/hooks.json +28 -3
  15. package/hooks/lock-gate +21 -0
  16. package/hooks/retrieval-gate +10 -0
  17. package/hooks/savepoint-pre +10 -0
  18. package/hooks/statusline +48 -6
  19. package/package.json +2 -1
  20. package/scripts/agent-report +21 -0
  21. package/scripts/dashboard.rb +98 -23
  22. package/scripts/doctor.rb +404 -5
  23. package/scripts/hook-auto-arm +1 -1
  24. package/scripts/hook-bash-gate +22 -4
  25. package/scripts/hook-code-gate +11 -6
  26. package/scripts/hook-continue +17 -0
  27. package/scripts/hook-create-gate +45 -9
  28. package/scripts/hook-gate-check +24 -23
  29. package/scripts/hook-lock-gate +83 -0
  30. package/scripts/hook-retrieval-gate +148 -0
  31. package/scripts/hook-savepoint-pre +32 -0
  32. package/scripts/hook-session-start +1 -1
  33. package/scripts/insight-append +51 -0
  34. package/scripts/install.rb +44 -7
  35. package/scripts/lib/agent_models.rb +43 -0
  36. package/scripts/lib/bridge.rb +924 -84
  37. package/scripts/lib/dashboard_banner.rb +42 -0
  38. package/scripts/lib/frontmatter_writer.rb +130 -0
  39. package/scripts/lib/graph_rebuild.rb +328 -0
  40. package/scripts/lib/hook_registry.rb +95 -0
  41. package/scripts/lib/insights.rb +86 -0
  42. package/scripts/lib/installer_core.rb +104 -60
  43. package/scripts/lib/link_suggestions.rb +319 -0
  44. package/scripts/lib/links_projection.rb +160 -0
  45. package/scripts/lib/links_section.rb +207 -0
  46. package/scripts/lib/lock.rb +375 -0
  47. package/scripts/lib/power_tools.rb +22 -21
  48. package/scripts/lib/preflight.rb +79 -0
  49. package/scripts/lib/qmd_sync.rb +15 -0
  50. package/scripts/lib/retrieval_gate.rb +211 -0
  51. package/scripts/lib/worktree.rb +384 -0
  52. package/scripts/link-suggest +213 -0
  53. package/scripts/new-intent +138 -29
  54. package/scripts/plastic-lock +164 -0
  55. package/scripts/project-links +287 -0
  56. package/scripts/read-config +4 -0
  57. package/scripts/rebuild-graph +244 -0
  58. package/scripts/spawn-preamble +11 -3
  59. package/scripts/update.rb +16 -7
  60. package/skills/auto/SKILL.md +126 -19
  61. package/skills/auto/references/agent-architecture.md +7 -4
  62. package/skills/auto/references/agent-report-contract.md +36 -1
  63. package/skills/auto/references/end-tail.md +56 -0
  64. package/skills/auto/references/human-report-contract.md +55 -0
  65. package/skills/auto/references/tiers.md +77 -0
  66. package/skills/brainstorming/SKILL.md +7 -34
  67. package/skills/brainstorming/references/design-principles.md +49 -0
  68. package/skills/continuing/SKILL.md +26 -7
  69. package/skills/creating-intent/SKILL.md +13 -28
  70. package/skills/creating-intent/references/lifecycle.md +9 -4
  71. package/skills/creating-project/SKILL.md +11 -74
  72. package/skills/creating-project/references/project-scaffolding.md +97 -0
  73. package/skills/creating-skills/SKILL.md +65 -0
  74. package/skills/creating-skills/evals/evals.json +108 -0
  75. package/skills/creating-skills/references/agents.md +168 -0
  76. package/skills/creating-skills/references/evals.md +41 -0
  77. package/skills/creating-skills/references/hooks.md +248 -0
  78. package/skills/creating-skills/references/progressive-disclosure.md +176 -0
  79. package/skills/creating-skills/references/scripts.md +166 -0
  80. package/skills/creating-skills/references/skills.md +165 -0
  81. package/skills/creating-skills/scripts/scaffold.rb +313 -0
  82. package/skills/dashboard/SKILL.md +13 -11
  83. package/skills/dashboard/references/classification.md +22 -0
  84. package/skills/doctor/SKILL.md +10 -7
  85. package/skills/executing-plan/SKILL.md +4 -4
  86. package/skills/humanizer/SKILL.md +39 -0
  87. package/skills/humanizer/evals/evals.json +70 -0
  88. package/skills/humanizer/references/always-on-snippet.md +9 -0
  89. package/skills/humanizer/references/examples.md +48 -0
  90. package/skills/install/SKILL.md +75 -84
  91. package/skills/intent-curator/SKILL.md +5 -1
  92. package/skills/intent-discovery/SKILL.md +47 -0
  93. package/skills/intent-starting/SKILL.md +130 -0
  94. package/skills/intent-starting/evals/evals.json +117 -0
  95. package/skills/intent-starting/references/boarding-matrix.md +35 -0
  96. package/skills/linking-intents/SKILL.md +48 -12
  97. package/skills/linking-intents/references/zettelkasten.md +7 -0
  98. package/skills/lock/SKILL.md +41 -0
  99. package/skills/managing-index/SKILL.md +6 -0
  100. package/skills/managing-index/references/zettelkasten-linking.md +6 -1
  101. package/skills/releasing/SKILL.md +44 -29
  102. package/skills/releasing/references/promotion-and-tagging.md +60 -0
  103. package/skills/roadmap/SKILL.md +51 -0
  104. package/skills/roadmap/references/file-format.md +91 -0
  105. package/skills/roadmap/references/operations.md +78 -0
  106. package/skills/uninstall/SKILL.md +29 -11
  107. package/skills/update/SKILL.md +34 -23
  108. package/skills/versions/SKILL.md +27 -12
  109. package/skills/writing-plans/SKILL.md +10 -88
  110. package/skills/writing-plans/references/plan-format.md +102 -0
  111. package/templates/config.yml +8 -0
  112. package/templates/outcome.md +3 -0
  113. package/templates/revisions.md +58 -0
  114. package/templates/roadmap.md +30 -0
  115. package/skills/writing-instructions/SKILL.md +0 -159
  116. package/skills/writing-instructions/references/agentskills-spec.md +0 -135
@@ -0,0 +1,102 @@
1
+ # Plan, Checklist, and Action Format
2
+
3
+ The exact templates for `plan.md`'s header and task structure, and for the
4
+ `checklist.md` and `actions/ACTION_N.md` artifacts. Read this before writing
5
+ plan.md so the shape matches on the first pass.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Plan Document Header](#plan-document-header)
10
+ - [Task Structure (worked example)](#task-structure-worked-example)
11
+ - [checklist.md format](#checklistmd-format)
12
+ - [actions/ACTION_N.md format](#actionsaction_nmd-format)
13
+
14
+ ## Plan Document Header
15
+
16
+ **Every plan MUST start with this header:**
17
+
18
+ ```markdown
19
+ # [Feature Name] Implementation Plan
20
+
21
+ > **For agentic workers:** Use `plastic-executing-plan` to implement this plan task-by-task.
22
+
23
+ **Goal:** [One sentence describing what this builds]
24
+
25
+ **Architecture:** [2-3 sentences about approach]
26
+
27
+ **Tech Stack:** [Key technologies/libraries]
28
+
29
+ **Intent:** {id} — {name}
30
+
31
+ ---
32
+ ```
33
+
34
+ ## Task Structure (worked example)
35
+
36
+ ````markdown
37
+ ### Task N: [Component Name]
38
+
39
+ **Files:**
40
+ - Create: `exact/path/to/file.rb`
41
+ - Modify: `exact/path/to/existing.rb:123-145`
42
+ - Test: `test/exact/path/to/test.rb`
43
+
44
+ - [ ] **Step 1: Write the failing test**
45
+
46
+ ```ruby
47
+ def test_specific_behavior
48
+ result = function(input)
49
+ assert_equal expected, result
50
+ end
51
+ ```
52
+
53
+ - [ ] **Step 2: Run test to verify it fails**
54
+
55
+ Run: `ruby -Itest test/path/test.rb --name test_specific_behavior`
56
+ Expected: FAIL with "undefined method"
57
+
58
+ - [ ] **Step 3: Write minimal implementation**
59
+
60
+ ```ruby
61
+ def function(input)
62
+ expected
63
+ end
64
+ ```
65
+
66
+ - [ ] **Step 4: Run test to verify it passes**
67
+
68
+ Run: `ruby -Itest test/path/test.rb --name test_specific_behavior`
69
+ Expected: PASS
70
+
71
+ - [ ] **Step 5: Commit**
72
+
73
+ ```bash
74
+ git add test/path/test.rb lib/path/file.rb
75
+ git commit -m "feat: add specific feature"
76
+ ```
77
+ ````
78
+
79
+ ## checklist.md format
80
+
81
+ Execution registry with one checkbox per task. Format:
82
+
83
+ ```markdown
84
+ # Checklist — Intent {id}: {name}
85
+
86
+ - [ ] Task 1: {task title}
87
+ - [ ] Task 2: {task title}
88
+ - [ ] Task 3: {task title}
89
+ ...
90
+ ```
91
+
92
+ ## actions/ACTION_N.md format
93
+
94
+ One file per task. Each action is self-contained — a subagent can execute it without reading the plan.
95
+
96
+ ```markdown
97
+ # Action {N}: {task title}
98
+
99
+ {Full task text copied from plan.md — all steps, all code, all commands. Nothing omitted.}
100
+ ```
101
+
102
+ Create the `actions/` directory inside the intent directory: `{intent_dir}/actions/`
@@ -11,3 +11,11 @@ agent:
11
11
  parallel_mode: linear
12
12
  architect:
13
13
  style:
14
+
15
+ # Per-agent model override (intent 116). Uncomment and set to a Claude Code
16
+ # alias (opus, sonnet, haiku) to override the shipped tier for one agent. With
17
+ # no entry, the shipped default applies. Never resolves to Fable.
18
+ # agents:
19
+ # models:
20
+ # plastic-executor: sonnet
21
+ # plastic-enforcer: opus
@@ -1,3 +1,6 @@
1
+ ---
2
+ disposition: delivered|abandoned
3
+ ---
1
4
  # Outcome: <intent name>
2
5
 
3
6
  ## Summary
@@ -0,0 +1,58 @@
1
+ # revisions.md
2
+
3
+ <!--
4
+ FORM reference. A live revisions.md exists in an intent directory ONLY when structural
5
+ maintenance actually happened. It is never scaffolded at intent birth, it carries no
6
+ placeholder sentinel, and its mere presence signals that this intent underwent structural
7
+ (not conceptual) change.
8
+
9
+ Rules:
10
+ - Append-only. Newest entry at the BOTTOM. Never edit or reorder past entries.
11
+ - One entry per relocated item (one section, one file, or one ref per entry).
12
+ - Move-and-record: remove the misplaced thing from its artifact and preserve it IN FULL
13
+ here. Never rewrite, summarize, or reinterpret delivered meaning. A change to delivered
14
+ meaning is a new intent, not a revision.
15
+ - Header form: "## Revision vN - YYYY-MM-DD-HH:MM" (N increments by one per entry).
16
+
17
+ Fields:
18
+ - Why: one sentence naming the broken rule, ending with "[rule: <tag>]".
19
+ - Prior location: the artifact plus the section or path the content came from.
20
+ - Content held: the verbatim removed content, as an indented block (block form), OR
21
+ - Change: a one-line "removed X (before: ... -> after: ...)" for a frontmatter
22
+ edit, used instead of a Content held block.
23
+
24
+ Stray file: embed the file's full content as the Content held block and delete the
25
+ original; Prior location names the filename. revisions.md is the single container.
26
+
27
+ Violation-tag catalog (starter set; free-text tags are allowed):
28
+ - unsanctioned-section : a top-level section the sanctioned-section rule now rejects
29
+ - phantom-section : a section referenced but not present or not sanctioned
30
+ - stray-file : a file that does not belong in the intent directory
31
+ - dangling-ref : a link or reference to something that no longer exists
32
+ - broken-chain : a chain frontmatter edge to an intent that no longer exists
33
+ - broken-source : a sources frontmatter edge to an intent that no longer exists
34
+ - misplaced-content : content that belongs in a different artifact or section
35
+
36
+ The examples below show the three variants. Delete them when you write the first real
37
+ entry; keep the "# revisions.md" title line above.
38
+ -->
39
+
40
+ ## Revision v1 - 2026-06-30-14:35
41
+ - Why: unsanctioned top-level section left over from an early draft [rule: unsanctioned-section]
42
+ - Prior location: intent.md - ## Scope
43
+ - Content held:
44
+
45
+ ## Scope
46
+ <the full content that was removed, verbatim>
47
+
48
+ ## Revision v2 - 2026-06-30-15:02
49
+ - Why: chain edge to an intent that no longer exists [rule: broken-chain]
50
+ - Prior location: intent.md frontmatter - chain
51
+ - Change: removed "99x" (before: ["4a1a", "99x"] -> after: ["4a1a"])
52
+
53
+ ## Revision v3 - 2026-06-30-15:20
54
+ - Why: a stray notes file that does not belong in the intent directory [rule: stray-file]
55
+ - Prior location: notes-old.md
56
+ - Content held:
57
+
58
+ <the full content of notes-old.md, verbatim; the original file is then deleted>
@@ -0,0 +1,30 @@
1
+ # Roadmap: <name>
2
+
3
+ (one-line meta: what this roadmap delivers, and which tier it lives in. `roadmaps/` is a sibling
4
+ of `INDEX.md` — a project's root or the global `~/.plastic/`, never inside `store/`. When this
5
+ roadmap's goal is reached, move this file from `roadmaps/{slug}.md` to
6
+ `roadmaps/archived/{slug}.md`; `roadmaps/` itself lists only live roadmaps.)
7
+
8
+ ## Goal
9
+ (a checkable prose condition — one or a few sentences a human or coordinator reads to decide the
10
+ roadmap is done. Not an executable checker.)
11
+
12
+ ## Waves
13
+ Entries in a wave are parallel-safe; waves run top to bottom. The checkbox is checked once an entry
14
+ is delivered, unchecked otherwise; the trailing token after the em-dash is the precise mirrored
15
+ status (queued | delivering | delivered | abandoned | blocked) from INDEX.md. INDEX always wins on
16
+ any conflict between the checkbox/token here and INDEX's real status.
17
+
18
+ ### Wave 1
19
+ - [ ] <intent-id> <title> — queued
20
+ - [ ] <intent-id> <title> — queued
21
+
22
+ ### Wave 2
23
+ - [x] <intent-id> <title> — delivered
24
+
25
+ ## Log
26
+ (append-only, dated, one line per event. Each line is one plain-language, EM-to-CTO-voice sentence:
27
+ what shipped and its impact for a non-expert reader, no jargon or internal codenames, ending with a
28
+ link to that entry-intent's `outcome.md`. Never restate outcome detail here; link to it instead.
29
+ Newest at the bottom.)
30
+ - 2026-01-01 00:00 UTC Shipped the first wave of this roadmap; see store/<intent-id>--<slug>/outcome.md.
@@ -1,159 +0,0 @@
1
- ---
2
- name: plastic-writing-instructions
3
- description: >
4
- Write or restructure agent instructions, conventions files, and SKILL.md
5
- content using progressive disclosure and the agentskills.io specification.
6
- Use when creating PLASTIC.md, rewriting convention docs, authoring new
7
- skills, restructuring large instruction files to fit context budgets,
8
- or when instructions feel too long, too vague, or agents aren't following
9
- them. Also use when the user says "progressive disclosure", "restructure
10
- instructions", or "the instructions are too big".
11
- ---
12
-
13
- # Writing Agent Instructions
14
-
15
- Based on the [agentskills.io specification](https://agentskills.io).
16
-
17
- ## Progressive Disclosure Architecture
18
-
19
- All agent instructions follow three loading stages. Design for this — it's the
20
- architecture, not a nice-to-have.
21
-
22
- | Stage | What loads | Budget | Design for |
23
- |-------|-----------|--------|------------|
24
- | **Discovery** | name + description | ~100 tokens | Trigger accuracy |
25
- | **Activation** | Full instruction body | <5000 tokens / <500 lines | Core procedures |
26
- | **Execution** | references/, scripts/, assets/ | As needed | Deep detail |
27
-
28
- **The description carries the entire burden of triggering.** If agents aren't
29
- activating your skill, the description is the problem.
30
-
31
- ## Procedure
32
-
33
- ### Step 1: Audit the content
34
-
35
- Before writing or restructuring, classify every piece of content:
36
-
37
- | Classification | Where it goes | Example |
38
- |---------------|---------------|---------|
39
- | **Trigger context** | description field | "Use when...", keywords |
40
- | **Core procedure** | SKILL.md body | Step-by-step workflows |
41
- | **Gotchas** | SKILL.md body (early) | Facts that defy assumptions |
42
- | **Deep reference** | references/ | API details, full schemas |
43
- | **Templates** | assets/ or inline | Output format examples |
44
- | **Executable logic** | scripts/ | Validation, data processing |
45
-
46
- Ask for each piece: "Would the agent get this wrong without this?"
47
- If no — cut it. If unsure — test it.
48
-
49
- ### Step 2: Write the description
50
-
51
- The description must convey WHEN to use, not just WHAT it does.
52
-
53
- **Rules:**
54
- - Imperative phrasing: "Use this skill when..." not "This skill does..."
55
- - Focus on user intent, not implementation
56
- - Err on the side of being pushy — list contexts explicitly
57
- - Include cases where user doesn't name the domain directly
58
- - Under 1024 characters (hard limit)
59
- - Include specific trigger keywords
60
-
61
- **Template:**
62
- ```yaml
63
- description: >
64
- [One sentence: what it does]. Use when [primary trigger context],
65
- [secondary trigger], or when [indirect trigger where user doesn't
66
- name the domain]. Also use when [edge case trigger].
67
- ```
68
-
69
- ### Step 3: Write the body
70
-
71
- **Principles (in priority order):**
72
-
73
- 1. **Procedures over declarations** — Teach HOW to approach a class of problems,
74
- not WHAT to produce for a specific instance
75
- 2. **Defaults, not menus** — Pick one approach, mention alternatives briefly.
76
- "Use X. For Y cases, use Z instead." Never present options as equals.
77
- 3. **Calibrate control to fragility** — Prescriptive for fragile/sequential tasks,
78
- flexible when multiple approaches are valid. Most skills have a mix.
79
- 4. **Reasoning over rigid directives** — "Do X because Y tends to cause Z" beats
80
- "ALWAYS do X, NEVER do Y"
81
- 5. **Add what the agent lacks, omit what it knows** — No explaining HTTP, PDFs,
82
- or what a migration is. Jump to what's non-obvious.
83
-
84
- **Structure:**
85
- ```markdown
86
- # Title
87
-
88
- [1-2 sentence purpose statement]
89
-
90
- ## Gotchas
91
- - [Highest-value content first — facts that defy assumptions]
92
- - [Each gotcha is a concrete correction, not general advice]
93
-
94
- ## Procedure
95
- ### Step 1: ...
96
- ### Step 2: ...
97
-
98
- ## Patterns
99
- [Only if the skill covers multiple approaches to similar problems]
100
- ```
101
-
102
- ### Step 4: Extract to references/
103
-
104
- Anything over 500 lines or 5000 tokens goes to `references/`. But tell the
105
- agent WHEN to load each file — conditional references, not a generic "see
106
- references/ for details."
107
-
108
- **Good:** "Read `references/api-errors.md` if the API returns a non-200 status"
109
- **Bad:** "See references/ for more information"
110
-
111
- ### Step 5: Validate
112
-
113
- Run through this checklist:
114
-
115
- - [ ] Description under 1024 chars
116
- - [ ] Body under 500 lines / 5000 tokens
117
- - [ ] Every instruction passes "would the agent get this wrong without it?"
118
- - [ ] Gotchas are concrete corrections, not general advice
119
- - [ ] Defaults chosen, not menus presented
120
- - [ ] Control calibrated: prescriptive where fragile, flexible where tolerant
121
- - [ ] References have conditional load triggers
122
- - [ ] No explaining what the agent already knows
123
-
124
- For structured evaluation beyond this checklist (paired evals, pass rate
125
- tracking, regression testing), use `plastic-evaluating-skills`.
126
-
127
- ## Gotchas
128
-
129
- - Hook `additionalContext` truncates at **10,000 characters**. If instructions
130
- must load via hooks (not skills), they must fit this budget.
131
- - `~/.claude/rules/*.md` files load fully with no truncation — use for
132
- always-loaded conventions that don't fit in a skill.
133
- - CLAUDE.md supports `@path/to/file` imports (max depth 4) — another way
134
- to load large instruction sets without truncation.
135
- - Agents only consult skills for tasks beyond what they can handle alone.
136
- Simple one-step requests may not trigger even with a perfect description.
137
- - Content from real domain expertise (runbooks, incident reports, code review)
138
- dramatically outperforms LLM-generated instructions without project context.
139
- - The most common cause of agents not following instructions: the instruction
140
- was too vague, didn't apply to the current task, or presented too many
141
- options without a clear default. Read execution traces to diagnose.
142
-
143
- ## For Convention Files (PLASTIC.md, CLAUDE.md)
144
-
145
- Convention files aren't skills — they load differently. Apply progressive
146
- disclosure by splitting:
147
-
148
- | Layer | Mechanism | Budget | Content |
149
- |-------|-----------|--------|---------|
150
- | **Always-on** | `~/.claude/rules/` or hook | <10K chars | Core identity, gotchas, critical procedures |
151
- | **On-demand** | Skills (SKILL.md) | <5K tokens each | Specific workflows activated by task |
152
- | **Deep reference** | `references/` in skills | Unlimited | Full specs, schemas, examples |
153
-
154
- **The always-on layer should answer: "What does this agent need to know about
155
- every single task?"** Everything else activates on demand.
156
-
157
- ## References
158
-
159
- - Read `references/agentskills-spec.md` for the complete agentskills.io specification including frontmatter fields, description optimization methodology, evaluation framework, and script design requirements
@@ -1,135 +0,0 @@
1
- # agentskills.io Full Reference
2
-
3
- Source: https://agentskills.io (all sections, verified June 2026)
4
-
5
- ## Specification Details
6
-
7
- ### Frontmatter Fields
8
-
9
- | Field | Required | Constraints |
10
- |-------|----------|-------------|
11
- | name | Yes | 1-64 chars. Lowercase alphanumeric + hyphens. No leading/trailing/consecutive hyphens. Must match directory name. |
12
- | description | Yes | 1-1024 chars. Non-empty. What + when. |
13
- | license | No | Short — name or filename reference |
14
- | compatibility | No | 1-500 chars. Environment requirements only when needed. |
15
- | metadata | No | String→string map. Use unique key names. |
16
- | allowed-tools | No | Space-separated. Experimental. |
17
-
18
- ### Progressive Disclosure Token Budgets
19
-
20
- - Discovery: ~100 tokens per skill (name + description only)
21
- - Activation: <5000 tokens / <500 lines recommended for SKILL.md body
22
- - Execution: Unbounded — files in scripts/, references/, assets/ load as needed
23
-
24
- ### File References
25
-
26
- - Use relative paths from skill root
27
- - Keep one level deep from SKILL.md
28
- - Agent resolves paths automatically
29
-
30
- ## Description Optimization
31
-
32
- ### Evaluation Methodology
33
-
34
- 1. Create ~20 eval queries (8-10 should-trigger, 8-10 should-not)
35
- 2. Split 60/40 train/validation (proportional mix in each)
36
- 3. Run each query 3 times, compute trigger rate
37
- 4. Pass threshold: 0.5
38
- 5. Near-miss negatives are most valuable (share keywords, need different thing)
39
- 6. Iterate on train set only, validate on held-out set
40
- 7. Select best by validation pass rate, not last iteration
41
- 8. 5 iterations usually sufficient
42
-
43
- ### Description Anti-patterns
44
-
45
- - "Helps with PDFs" — too vague, no trigger context
46
- - "Process CSV files" — no when/why, no user-intent focus
47
- - Implementation details instead of user intent
48
- - Missing edge case triggers (user doesn't name the domain)
49
-
50
- ## Instruction Best Practices
51
-
52
- ### Gotchas — Highest-Value Content
53
-
54
- Concrete corrections, not general advice:
55
-
56
- ```markdown
57
- ## Gotchas
58
- - The `users` table uses soft deletes. Queries must include
59
- `WHERE deleted_at IS NULL`.
60
- - User ID is `user_id` in DB, `uid` in auth, `accountId` in billing.
61
- All three refer to the same value.
62
- - The `/health` endpoint returns 200 even if DB is down. Use `/ready`.
63
- ```
64
-
65
- ### Calibrating Control
66
-
67
- Prescriptive when:
68
- - Operations are fragile
69
- - Consistency matters
70
- - Specific sequence must be followed
71
-
72
- Flexible when:
73
- - Multiple approaches are valid
74
- - Task tolerates variation
75
- - Explaining WHY is more effective than rigid rules
76
-
77
- ### Instruction Patterns
78
-
79
- 1. **Validation loops**: Do work → validate → fix → repeat
80
- 2. **Plan-validate-execute**: Create plan → validate vs source of truth → execute
81
- 3. **Checklists**: Track progress, enforce dependencies, validation gates
82
- 4. **Bundled scripts**: If agent reinvents same logic each run, bundle it
83
- 5. **Templates**: Concrete output structures > prose descriptions
84
-
85
- ## Script Design
86
-
87
- ### Hard Requirements
88
- - No interactive prompts (hard requirement — agents hang indefinitely)
89
- - All input via flags, env vars, or stdin
90
-
91
- ### Agent-Friendly Design
92
- - --help as primary interface documentation
93
- - Helpful error messages: what wrong + what expected + what to try
94
- - Structured output (JSON/CSV/TSV), data on stdout, diagnostics on stderr
95
- - Idempotent operations (agents may retry)
96
- - Dry-run for destructive operations
97
- - Meaningful exit codes documented in --help
98
- - Output size control: default to summaries, support --offset pagination
99
- - Agent harnesses truncate at 10-30K characters
100
-
101
- ## Evaluation Framework
102
-
103
- ### Test Case Structure
104
- ```json
105
- {
106
- "skill_name": "name",
107
- "evals": [{
108
- "id": 1,
109
- "prompt": "realistic user message",
110
- "expected_output": "what success looks like",
111
- "files": ["evals/files/input.csv"],
112
- "assertions": ["specific, verifiable checks"]
113
- }]
114
- }
115
- ```
116
-
117
- ### Running Evals
118
- - With-skill vs without-skill (or previous version) comparison
119
- - Clean context per run (subagents or separate sessions)
120
- - Capture timing: total_tokens, duration_ms
121
- - Start with 2-3 test cases, expand after first results
122
-
123
- ### Assertion Quality
124
- Good: Programmatically verifiable, specific, countable
125
- Weak: Vague ("the output is good")
126
- Brittle: Exact phrase matching
127
-
128
- Principle: Require concrete evidence for PASS. No benefit of the doubt.
129
-
130
- ### Iteration Loop
131
- 1. Run evals → grade assertions → aggregate benchmarks
132
- 2. Identify failures (assertions, human feedback, execution transcripts)
133
- 3. Feed all three + SKILL.md to LLM for proposed changes
134
- 4. Apply changes → re-run → compare
135
- 5. Stop when consistently empty feedback or no meaningful improvement