@chankov/agent-skills 0.1.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/.claude/commands/build.md +18 -0
- package/.claude/commands/code-simplify.md +22 -0
- package/.claude/commands/design-agent.md +14 -0
- package/.claude/commands/doctor.md +13 -0
- package/.claude/commands/plan.md +16 -0
- package/.claude/commands/prime.md +22 -0
- package/.claude/commands/review.md +16 -0
- package/.claude/commands/setup.md +19 -0
- package/.claude/commands/ship.md +17 -0
- package/.claude/commands/spec.md +15 -0
- package/.claude/commands/test.md +19 -0
- package/.opencode/commands/as-build.md +17 -0
- package/.opencode/commands/as-code-simplify.md +16 -0
- package/.opencode/commands/as-design-agent.md +15 -0
- package/.opencode/commands/as-doctor.md +11 -0
- package/.opencode/commands/as-plan.md +16 -0
- package/.opencode/commands/as-prime.md +22 -0
- package/.opencode/commands/as-review.md +15 -0
- package/.opencode/commands/as-setup.md +11 -0
- package/.opencode/commands/as-ship.md +16 -0
- package/.opencode/commands/as-spec.md +16 -0
- package/.opencode/commands/as-test.md +21 -0
- package/.pi/agents/agent-chain.yaml +49 -0
- package/.pi/agents/bowser.md +19 -0
- package/.pi/agents/pi-pi/agent-expert.md +98 -0
- package/.pi/agents/pi-pi/cli-expert.md +41 -0
- package/.pi/agents/pi-pi/config-expert.md +63 -0
- package/.pi/agents/pi-pi/ext-expert.md +43 -0
- package/.pi/agents/pi-pi/keybinding-expert.md +134 -0
- package/.pi/agents/pi-pi/pi-orchestrator.md +57 -0
- package/.pi/agents/pi-pi/prompt-expert.md +70 -0
- package/.pi/agents/pi-pi/skill-expert.md +42 -0
- package/.pi/agents/pi-pi/theme-expert.md +40 -0
- package/.pi/agents/pi-pi/tui-expert.md +85 -0
- package/.pi/agents/teams.yaml +31 -0
- package/.pi/damage-control-rules.yaml +278 -0
- package/.pi/extensions/chrome-devtools-mcp/README.md +39 -0
- package/.pi/extensions/chrome-devtools-mcp/index.ts +61 -0
- package/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
- package/.pi/extensions/compact-and-continue/README.md +42 -0
- package/.pi/extensions/compact-and-continue/index.ts +120 -0
- package/.pi/extensions/compact-and-continue/package.json +6 -0
- package/.pi/extensions/mcp-bridge/README.md +46 -0
- package/.pi/extensions/mcp-bridge/index.ts +206 -0
- package/.pi/extensions/mcp-bridge/package.json +6 -0
- package/.pi/extensions/package-lock.json +1143 -0
- package/.pi/extensions/package.json +9 -0
- package/.pi/harnesses/agent-chain/README.md +37 -0
- package/.pi/harnesses/agent-chain/index.ts +795 -0
- package/.pi/harnesses/agent-chain/package.json +6 -0
- package/.pi/harnesses/agent-team/README.md +38 -0
- package/.pi/harnesses/agent-team/index.ts +732 -0
- package/.pi/harnesses/agent-team/package.json +6 -0
- package/.pi/harnesses/coms/README.md +36 -0
- package/.pi/harnesses/coms/index.ts +1595 -0
- package/.pi/harnesses/coms/package.json +6 -0
- package/.pi/harnesses/coms-net/README.md +46 -0
- package/.pi/harnesses/coms-net/index.ts +1637 -0
- package/.pi/harnesses/coms-net/package.json +6 -0
- package/.pi/harnesses/damage-control/README.md +38 -0
- package/.pi/harnesses/damage-control/index.ts +207 -0
- package/.pi/harnesses/damage-control/package.json +6 -0
- package/.pi/harnesses/damage-control-continue/README.md +37 -0
- package/.pi/harnesses/damage-control-continue/index.ts +234 -0
- package/.pi/harnesses/damage-control-continue/package.json +6 -0
- package/.pi/harnesses/minimal/README.md +27 -0
- package/.pi/harnesses/minimal/index.ts +32 -0
- package/.pi/harnesses/minimal/package.json +6 -0
- package/.pi/harnesses/package-lock.json +35 -0
- package/.pi/harnesses/package.json +9 -0
- package/.pi/harnesses/pi-pi/README.md +39 -0
- package/.pi/harnesses/pi-pi/index.ts +631 -0
- package/.pi/harnesses/pi-pi/package.json +6 -0
- package/.pi/harnesses/purpose-gate/README.md +27 -0
- package/.pi/harnesses/purpose-gate/index.ts +82 -0
- package/.pi/harnesses/purpose-gate/package.json +6 -0
- package/.pi/harnesses/session-replay/README.md +28 -0
- package/.pi/harnesses/session-replay/index.ts +214 -0
- package/.pi/harnesses/session-replay/package.json +6 -0
- package/.pi/harnesses/subagent-widget/README.md +36 -0
- package/.pi/harnesses/subagent-widget/index.ts +479 -0
- package/.pi/harnesses/subagent-widget/package.json +6 -0
- package/.pi/harnesses/system-select/README.md +39 -0
- package/.pi/harnesses/system-select/index.ts +165 -0
- package/.pi/harnesses/system-select/package.json +6 -0
- package/.pi/harnesses/tilldone/README.md +35 -0
- package/.pi/harnesses/tilldone/index.ts +724 -0
- package/.pi/harnesses/tilldone/package.json +6 -0
- package/.pi/harnesses/tool-counter/README.md +31 -0
- package/.pi/harnesses/tool-counter/index.ts +100 -0
- package/.pi/harnesses/tool-counter/package.json +6 -0
- package/.pi/harnesses/tool-counter-widget/README.md +27 -0
- package/.pi/harnesses/tool-counter-widget/index.ts +66 -0
- package/.pi/harnesses/tool-counter-widget/package.json +6 -0
- package/.pi/prompts/build.md +24 -0
- package/.pi/prompts/code-simplify.md +22 -0
- package/.pi/prompts/doctor.md +13 -0
- package/.pi/prompts/plan.md +16 -0
- package/.pi/prompts/review.md +16 -0
- package/.pi/prompts/setup.md +19 -0
- package/.pi/prompts/ship.md +17 -0
- package/.pi/prompts/spec.md +15 -0
- package/.pi/prompts/test.md +19 -0
- package/.pi/skills/bowser/SKILL.md +114 -0
- package/.versions/0.1.0/.claude/commands/build.md +18 -0
- package/.versions/0.1.0/.claude/commands/code-simplify.md +22 -0
- package/.versions/0.1.0/.claude/commands/design-agent.md +14 -0
- package/.versions/0.1.0/.claude/commands/doctor.md +13 -0
- package/.versions/0.1.0/.claude/commands/plan.md +16 -0
- package/.versions/0.1.0/.claude/commands/prime.md +22 -0
- package/.versions/0.1.0/.claude/commands/review.md +16 -0
- package/.versions/0.1.0/.claude/commands/setup.md +19 -0
- package/.versions/0.1.0/.claude/commands/ship.md +17 -0
- package/.versions/0.1.0/.claude/commands/spec.md +15 -0
- package/.versions/0.1.0/.claude/commands/test.md +19 -0
- package/.versions/0.1.0/.opencode/commands/as-build.md +17 -0
- package/.versions/0.1.0/.opencode/commands/as-code-simplify.md +16 -0
- package/.versions/0.1.0/.opencode/commands/as-design-agent.md +15 -0
- package/.versions/0.1.0/.opencode/commands/as-doctor.md +11 -0
- package/.versions/0.1.0/.opencode/commands/as-plan.md +16 -0
- package/.versions/0.1.0/.opencode/commands/as-prime.md +22 -0
- package/.versions/0.1.0/.opencode/commands/as-review.md +15 -0
- package/.versions/0.1.0/.opencode/commands/as-setup.md +11 -0
- package/.versions/0.1.0/.opencode/commands/as-ship.md +16 -0
- package/.versions/0.1.0/.opencode/commands/as-spec.md +16 -0
- package/.versions/0.1.0/.opencode/commands/as-test.md +21 -0
- package/.versions/0.1.0/.pi/agents/agent-chain.yaml +49 -0
- package/.versions/0.1.0/.pi/agents/bowser.md +19 -0
- package/.versions/0.1.0/.pi/agents/pi-pi/agent-expert.md +98 -0
- package/.versions/0.1.0/.pi/agents/pi-pi/cli-expert.md +41 -0
- package/.versions/0.1.0/.pi/agents/pi-pi/config-expert.md +63 -0
- package/.versions/0.1.0/.pi/agents/pi-pi/ext-expert.md +43 -0
- package/.versions/0.1.0/.pi/agents/pi-pi/keybinding-expert.md +134 -0
- package/.versions/0.1.0/.pi/agents/pi-pi/pi-orchestrator.md +57 -0
- package/.versions/0.1.0/.pi/agents/pi-pi/prompt-expert.md +70 -0
- package/.versions/0.1.0/.pi/agents/pi-pi/skill-expert.md +42 -0
- package/.versions/0.1.0/.pi/agents/pi-pi/theme-expert.md +40 -0
- package/.versions/0.1.0/.pi/agents/pi-pi/tui-expert.md +85 -0
- package/.versions/0.1.0/.pi/agents/teams.yaml +31 -0
- package/.versions/0.1.0/.pi/damage-control-rules.yaml +278 -0
- package/.versions/0.1.0/.pi/extensions/chrome-devtools-mcp/README.md +39 -0
- package/.versions/0.1.0/.pi/extensions/chrome-devtools-mcp/index.ts +61 -0
- package/.versions/0.1.0/.pi/extensions/chrome-devtools-mcp/package.json +6 -0
- package/.versions/0.1.0/.pi/extensions/compact-and-continue/README.md +42 -0
- package/.versions/0.1.0/.pi/extensions/compact-and-continue/index.ts +120 -0
- package/.versions/0.1.0/.pi/extensions/compact-and-continue/package.json +6 -0
- package/.versions/0.1.0/.pi/extensions/mcp-bridge/README.md +46 -0
- package/.versions/0.1.0/.pi/extensions/mcp-bridge/index.ts +206 -0
- package/.versions/0.1.0/.pi/extensions/mcp-bridge/package.json +6 -0
- package/.versions/0.1.0/.pi/extensions/package-lock.json +1143 -0
- package/.versions/0.1.0/.pi/extensions/package.json +9 -0
- package/.versions/0.1.0/.pi/harnesses/agent-chain/README.md +37 -0
- package/.versions/0.1.0/.pi/harnesses/agent-chain/index.ts +795 -0
- package/.versions/0.1.0/.pi/harnesses/agent-chain/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/agent-team/README.md +38 -0
- package/.versions/0.1.0/.pi/harnesses/agent-team/index.ts +732 -0
- package/.versions/0.1.0/.pi/harnesses/agent-team/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/coms/README.md +36 -0
- package/.versions/0.1.0/.pi/harnesses/coms/index.ts +1595 -0
- package/.versions/0.1.0/.pi/harnesses/coms/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/coms-net/README.md +46 -0
- package/.versions/0.1.0/.pi/harnesses/coms-net/index.ts +1637 -0
- package/.versions/0.1.0/.pi/harnesses/coms-net/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/damage-control/README.md +38 -0
- package/.versions/0.1.0/.pi/harnesses/damage-control/index.ts +207 -0
- package/.versions/0.1.0/.pi/harnesses/damage-control/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/damage-control-continue/README.md +37 -0
- package/.versions/0.1.0/.pi/harnesses/damage-control-continue/index.ts +234 -0
- package/.versions/0.1.0/.pi/harnesses/damage-control-continue/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/minimal/README.md +27 -0
- package/.versions/0.1.0/.pi/harnesses/minimal/index.ts +32 -0
- package/.versions/0.1.0/.pi/harnesses/minimal/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/package-lock.json +35 -0
- package/.versions/0.1.0/.pi/harnesses/package.json +9 -0
- package/.versions/0.1.0/.pi/harnesses/pi-pi/README.md +39 -0
- package/.versions/0.1.0/.pi/harnesses/pi-pi/index.ts +631 -0
- package/.versions/0.1.0/.pi/harnesses/pi-pi/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/purpose-gate/README.md +27 -0
- package/.versions/0.1.0/.pi/harnesses/purpose-gate/index.ts +82 -0
- package/.versions/0.1.0/.pi/harnesses/purpose-gate/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/session-replay/README.md +28 -0
- package/.versions/0.1.0/.pi/harnesses/session-replay/index.ts +214 -0
- package/.versions/0.1.0/.pi/harnesses/session-replay/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/subagent-widget/README.md +36 -0
- package/.versions/0.1.0/.pi/harnesses/subagent-widget/index.ts +479 -0
- package/.versions/0.1.0/.pi/harnesses/subagent-widget/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/system-select/README.md +39 -0
- package/.versions/0.1.0/.pi/harnesses/system-select/index.ts +165 -0
- package/.versions/0.1.0/.pi/harnesses/system-select/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/tilldone/README.md +35 -0
- package/.versions/0.1.0/.pi/harnesses/tilldone/index.ts +724 -0
- package/.versions/0.1.0/.pi/harnesses/tilldone/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/tool-counter/README.md +31 -0
- package/.versions/0.1.0/.pi/harnesses/tool-counter/index.ts +100 -0
- package/.versions/0.1.0/.pi/harnesses/tool-counter/package.json +6 -0
- package/.versions/0.1.0/.pi/harnesses/tool-counter-widget/README.md +27 -0
- package/.versions/0.1.0/.pi/harnesses/tool-counter-widget/index.ts +66 -0
- package/.versions/0.1.0/.pi/harnesses/tool-counter-widget/package.json +6 -0
- package/.versions/0.1.0/.pi/prompts/build.md +24 -0
- package/.versions/0.1.0/.pi/prompts/code-simplify.md +22 -0
- package/.versions/0.1.0/.pi/prompts/doctor.md +13 -0
- package/.versions/0.1.0/.pi/prompts/plan.md +16 -0
- package/.versions/0.1.0/.pi/prompts/review.md +16 -0
- package/.versions/0.1.0/.pi/prompts/setup.md +19 -0
- package/.versions/0.1.0/.pi/prompts/ship.md +17 -0
- package/.versions/0.1.0/.pi/prompts/spec.md +15 -0
- package/.versions/0.1.0/.pi/prompts/test.md +19 -0
- package/.versions/0.1.0/.pi/skills/bowser/SKILL.md +114 -0
- package/.versions/0.1.0/.version +1 -0
- package/.versions/0.1.0/agents/builder.md +6 -0
- package/.versions/0.1.0/agents/code-reviewer.md +93 -0
- package/.versions/0.1.0/agents/documenter.md +6 -0
- package/.versions/0.1.0/agents/plan-reviewer.md +22 -0
- package/.versions/0.1.0/agents/planner.md +6 -0
- package/.versions/0.1.0/agents/scout.md +6 -0
- package/.versions/0.1.0/agents/security-auditor.md +97 -0
- package/.versions/0.1.0/agents/test-engineer.md +89 -0
- package/.versions/0.1.0/hooks/SIMPLIFY-IGNORE.md +90 -0
- package/.versions/0.1.0/hooks/hooks.json +14 -0
- package/.versions/0.1.0/hooks/session-start.sh +20 -0
- package/.versions/0.1.0/hooks/simplify-ignore-test.sh +247 -0
- package/.versions/0.1.0/hooks/simplify-ignore.sh +302 -0
- package/.versions/0.1.0/references/accessibility-checklist.md +159 -0
- package/.versions/0.1.0/references/performance-checklist.md +121 -0
- package/.versions/0.1.0/references/prompting-patterns.md +380 -0
- package/.versions/0.1.0/references/security-checklist.md +134 -0
- package/.versions/0.1.0/references/testing-patterns.md +236 -0
- package/.versions/0.1.0/skills/api-and-interface-design/SKILL.md +294 -0
- package/.versions/0.1.0/skills/browser-testing-with-devtools/SKILL.md +335 -0
- package/.versions/0.1.0/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/.versions/0.1.0/skills/code-review-and-quality/SKILL.md +347 -0
- package/.versions/0.1.0/skills/code-simplification/SKILL.md +331 -0
- package/.versions/0.1.0/skills/context-engineering/SKILL.md +291 -0
- package/.versions/0.1.0/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/.versions/0.1.0/skills/deprecation-and-migration/SKILL.md +206 -0
- package/.versions/0.1.0/skills/designing-agents/SKILL.md +394 -0
- package/.versions/0.1.0/skills/designing-agents/pi-harness-authoring.md +213 -0
- package/.versions/0.1.0/skills/documentation-and-adrs/SKILL.md +278 -0
- package/.versions/0.1.0/skills/frontend-ui-engineering/SKILL.md +322 -0
- package/.versions/0.1.0/skills/git-workflow-and-versioning/SKILL.md +316 -0
- package/.versions/0.1.0/skills/guided-workspace-setup/SKILL.md +293 -0
- package/.versions/0.1.0/skills/idea-refine/SKILL.md +178 -0
- package/.versions/0.1.0/skills/idea-refine/examples.md +238 -0
- package/.versions/0.1.0/skills/idea-refine/frameworks.md +99 -0
- package/.versions/0.1.0/skills/idea-refine/refinement-criteria.md +113 -0
- package/.versions/0.1.0/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/.versions/0.1.0/skills/incremental-implementation/SKILL.md +279 -0
- package/.versions/0.1.0/skills/performance-optimization/SKILL.md +350 -0
- package/.versions/0.1.0/skills/planning-and-task-breakdown/SKILL.md +237 -0
- package/.versions/0.1.0/skills/security-and-hardening/SKILL.md +349 -0
- package/.versions/0.1.0/skills/shipping-and-launch/SKILL.md +309 -0
- package/.versions/0.1.0/skills/source-driven-development/SKILL.md +194 -0
- package/.versions/0.1.0/skills/spec-driven-development/SKILL.md +237 -0
- package/.versions/0.1.0/skills/test-driven-development/SKILL.md +379 -0
- package/.versions/0.1.0/skills/using-agent-skills/SKILL.md +176 -0
- package/CHANGELOG.md +14 -0
- package/LICENSE +21 -0
- package/README.md +359 -0
- package/agents/builder.md +6 -0
- package/agents/code-reviewer.md +93 -0
- package/agents/documenter.md +6 -0
- package/agents/plan-reviewer.md +22 -0
- package/agents/planner.md +6 -0
- package/agents/scout.md +6 -0
- package/agents/security-auditor.md +97 -0
- package/agents/test-engineer.md +89 -0
- package/bin/cli.js +375 -0
- package/bin/lib/detect-agent.js +37 -0
- package/bin/lib/doctor.js +209 -0
- package/bin/snapshot-version.js +71 -0
- package/docs/agent-skills-setup.md +187 -0
- package/docs/copilot-setup.md +94 -0
- package/docs/cursor-setup.md +67 -0
- package/docs/gemini-cli-setup.md +113 -0
- package/docs/getting-started.md +162 -0
- package/docs/npm-install.md +169 -0
- package/docs/opencode-setup.md +241 -0
- package/docs/pi-extensions.md +163 -0
- package/docs/pi-setup.md +416 -0
- package/docs/skill-anatomy.md +129 -0
- package/docs/windsurf-setup.md +48 -0
- package/hooks/SIMPLIFY-IGNORE.md +90 -0
- package/hooks/hooks.json +14 -0
- package/hooks/session-start.sh +20 -0
- package/hooks/simplify-ignore-test.sh +247 -0
- package/hooks/simplify-ignore.sh +302 -0
- package/package.json +86 -0
- package/references/accessibility-checklist.md +159 -0
- package/references/performance-checklist.md +121 -0
- package/references/prompting-patterns.md +380 -0
- package/references/security-checklist.md +134 -0
- package/references/testing-patterns.md +236 -0
- package/skills/api-and-interface-design/SKILL.md +294 -0
- package/skills/browser-testing-with-devtools/SKILL.md +335 -0
- package/skills/ci-cd-and-automation/SKILL.md +390 -0
- package/skills/code-review-and-quality/SKILL.md +347 -0
- package/skills/code-simplification/SKILL.md +331 -0
- package/skills/context-engineering/SKILL.md +291 -0
- package/skills/debugging-and-error-recovery/SKILL.md +300 -0
- package/skills/deprecation-and-migration/SKILL.md +206 -0
- package/skills/designing-agents/SKILL.md +394 -0
- package/skills/designing-agents/pi-harness-authoring.md +213 -0
- package/skills/documentation-and-adrs/SKILL.md +278 -0
- package/skills/frontend-ui-engineering/SKILL.md +322 -0
- package/skills/git-workflow-and-versioning/SKILL.md +316 -0
- package/skills/guided-workspace-setup/SKILL.md +293 -0
- package/skills/idea-refine/SKILL.md +178 -0
- package/skills/idea-refine/examples.md +238 -0
- package/skills/idea-refine/frameworks.md +99 -0
- package/skills/idea-refine/refinement-criteria.md +113 -0
- package/skills/idea-refine/scripts/idea-refine.sh +15 -0
- package/skills/incremental-implementation/SKILL.md +279 -0
- package/skills/performance-optimization/SKILL.md +350 -0
- package/skills/planning-and-task-breakdown/SKILL.md +237 -0
- package/skills/security-and-hardening/SKILL.md +349 -0
- package/skills/shipping-and-launch/SKILL.md +309 -0
- package/skills/source-driven-development/SKILL.md +194 -0
- package/skills/spec-driven-development/SKILL.md +237 -0
- package/skills/test-driven-development/SKILL.md +379 -0
- package/skills/using-agent-skills/SKILL.md +176 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Skill Anatomy
|
|
2
|
+
|
|
3
|
+
This document describes the structure and format of agent-skills skill files. Use this as a guide when contributing new skills or understanding existing ones.
|
|
4
|
+
|
|
5
|
+
## File Location
|
|
6
|
+
|
|
7
|
+
Every skill lives in its own directory under `skills/`:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
skills/
|
|
11
|
+
skill-name/
|
|
12
|
+
SKILL.md # Required: The skill definition
|
|
13
|
+
supporting-file.md # Optional: Reference material loaded on demand
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## SKILL.md Format
|
|
17
|
+
|
|
18
|
+
### Frontmatter (Required)
|
|
19
|
+
|
|
20
|
+
```yaml
|
|
21
|
+
---
|
|
22
|
+
name: skill-name-with-hyphens
|
|
23
|
+
description: Brief statement of what the skill does. Use when [specific trigger conditions].
|
|
24
|
+
---
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Rules:**
|
|
28
|
+
- `name`: Lowercase, hyphen-separated. Must match the directory name.
|
|
29
|
+
- `description`: Starts with what the skill does (third person), followed by trigger conditions. Include both *what* and *when*. Maximum 1024 characters.
|
|
30
|
+
|
|
31
|
+
**Why this matters:** Agents discover skills by reading descriptions. The description is injected into the system prompt, so it must tell the agent both what the skill provides and when to activate it. Do not summarize the workflow — if the description contains process steps, the agent may follow the summary instead of reading the full skill.
|
|
32
|
+
|
|
33
|
+
### Standard Sections
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
# Skill Title
|
|
37
|
+
|
|
38
|
+
## Overview
|
|
39
|
+
One-two sentences explaining what this skill does and why it matters.
|
|
40
|
+
|
|
41
|
+
## When to Use
|
|
42
|
+
- Bullet list of triggering conditions (symptoms, task types)
|
|
43
|
+
- When NOT to use (exclusions)
|
|
44
|
+
|
|
45
|
+
## [Core Process / The Workflow / Steps]
|
|
46
|
+
The main workflow, broken into numbered steps or phases.
|
|
47
|
+
Include code examples where they help.
|
|
48
|
+
Use flowcharts (ASCII) where decision points exist.
|
|
49
|
+
|
|
50
|
+
## [Specific Techniques / Patterns]
|
|
51
|
+
Detailed guidance for specific scenarios.
|
|
52
|
+
Code examples, templates, configuration.
|
|
53
|
+
|
|
54
|
+
## Common Rationalizations
|
|
55
|
+
| Rationalization | Reality |
|
|
56
|
+
|---|---|
|
|
57
|
+
| Excuse agents use to skip steps | Why the excuse is wrong |
|
|
58
|
+
|
|
59
|
+
## Red Flags
|
|
60
|
+
- Behavioral patterns indicating the skill is being violated
|
|
61
|
+
- Things to watch for during review
|
|
62
|
+
|
|
63
|
+
## Verification
|
|
64
|
+
After completing the skill's process, confirm:
|
|
65
|
+
- [ ] Checklist of exit criteria
|
|
66
|
+
- [ ] Evidence requirements
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Section Purposes
|
|
70
|
+
|
|
71
|
+
### Overview
|
|
72
|
+
The "elevator pitch" for the skill. Should answer: What does this skill do, and why should an agent follow it?
|
|
73
|
+
|
|
74
|
+
### When to Use
|
|
75
|
+
Helps agents and humans decide if this skill applies to the current task. Include both positive triggers ("Use when X") and negative exclusions ("NOT for Y").
|
|
76
|
+
|
|
77
|
+
### Core Process
|
|
78
|
+
The heart of the skill. This is the step-by-step workflow the agent follows. Must be specific and actionable — not vague advice.
|
|
79
|
+
|
|
80
|
+
**Good:** "Run `npm test` and verify all tests pass"
|
|
81
|
+
**Bad:** "Make sure the tests work"
|
|
82
|
+
|
|
83
|
+
### Common Rationalizations
|
|
84
|
+
The most distinctive feature of well-crafted skills. These are excuses agents use to skip important steps, paired with rebuttals. They prevent the agent from rationalizing its way out of following the process.
|
|
85
|
+
|
|
86
|
+
Think of every time an agent has said "I'll add tests later" or "This is simple enough to skip the spec" — those go here with a factual counter-argument.
|
|
87
|
+
|
|
88
|
+
### Red Flags
|
|
89
|
+
Observable signs that the skill is being violated. Useful during code review and self-monitoring.
|
|
90
|
+
|
|
91
|
+
### Verification
|
|
92
|
+
The exit criteria. A checklist the agent uses to confirm the skill's process is complete. Every checkbox should be verifiable with evidence (test output, build result, screenshot, etc.).
|
|
93
|
+
|
|
94
|
+
## Supporting Files
|
|
95
|
+
|
|
96
|
+
Create supporting files only when:
|
|
97
|
+
- Reference material exceeds 100 lines (keep the main SKILL.md focused)
|
|
98
|
+
- Code tools or scripts are needed
|
|
99
|
+
- Checklists are long enough to justify separate files
|
|
100
|
+
|
|
101
|
+
Keep patterns and principles inline when under 50 lines.
|
|
102
|
+
|
|
103
|
+
## Writing Principles
|
|
104
|
+
|
|
105
|
+
1. **Process over knowledge.** Skills are workflows, not reference docs. Steps, not facts.
|
|
106
|
+
2. **Specific over general.** "Run `npm test`" beats "verify the tests".
|
|
107
|
+
3. **Evidence over assumption.** Every verification checkbox requires proof.
|
|
108
|
+
4. **Anti-rationalization.** Every skip-worthy step needs a counter-argument in the rationalizations table.
|
|
109
|
+
5. **Progressive disclosure.** Main SKILL.md is the entry point. Supporting files are loaded only when needed.
|
|
110
|
+
6. **Token-conscious.** Every section must justify its inclusion. If removing it wouldn't change agent behavior, remove it.
|
|
111
|
+
7. **Prompting-patterns applied.** Before finalizing a skill, verify its language against `references/prompting-patterns.md` — positive instructions over prohibitions, explain *why* behind non-obvious rules, no ALL-CAPS or reward/punishment language.
|
|
112
|
+
|
|
113
|
+
## Naming Conventions
|
|
114
|
+
|
|
115
|
+
- Skill directories: `lowercase-hyphen-separated`
|
|
116
|
+
- Skill files: `SKILL.md` (always uppercase)
|
|
117
|
+
- Supporting files: `lowercase-hyphen-separated.md`
|
|
118
|
+
- References: stored in `references/` at the project root, not inside skill directories
|
|
119
|
+
|
|
120
|
+
## Cross-Skill References
|
|
121
|
+
|
|
122
|
+
Reference other skills by name:
|
|
123
|
+
|
|
124
|
+
```markdown
|
|
125
|
+
Follow the `test-driven-development` skill for writing tests.
|
|
126
|
+
If the build breaks, use the `debugging-and-error-recovery` skill.
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Don't duplicate content between skills — reference and link instead.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Using agent-skills with Windsurf
|
|
2
|
+
|
|
3
|
+
## Setup
|
|
4
|
+
|
|
5
|
+
### Project Rules
|
|
6
|
+
|
|
7
|
+
Windsurf uses `.windsurfrules` for project-specific agent instructions:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Create a combined rules file from your most important skills
|
|
11
|
+
cat /path/to/agent-skills/skills/test-driven-development/SKILL.md > .windsurfrules
|
|
12
|
+
echo "\n---\n" >> .windsurfrules
|
|
13
|
+
cat /path/to/agent-skills/skills/incremental-implementation/SKILL.md >> .windsurfrules
|
|
14
|
+
echo "\n---\n" >> .windsurfrules
|
|
15
|
+
cat /path/to/agent-skills/skills/code-review-and-quality/SKILL.md >> .windsurfrules
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Global Rules
|
|
19
|
+
|
|
20
|
+
For skills you want across all projects, add them to Windsurf's global rules:
|
|
21
|
+
|
|
22
|
+
1. Open Windsurf → Settings → AI → Global Rules
|
|
23
|
+
2. Paste the content of your most-used skills
|
|
24
|
+
|
|
25
|
+
## Recommended Configuration
|
|
26
|
+
|
|
27
|
+
Keep `.windsurfrules` focused on 2-3 essential skills to stay within context limits:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
# .windsurfrules
|
|
31
|
+
# Essential agent-skills for this project
|
|
32
|
+
|
|
33
|
+
[Paste test-driven-development SKILL.md]
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
[Paste incremental-implementation SKILL.md]
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
[Paste code-review-and-quality SKILL.md]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Usage Tips
|
|
45
|
+
|
|
46
|
+
1. **Be selective** — Windsurf's context is limited. Choose skills that address your biggest quality gaps.
|
|
47
|
+
2. **Reference in conversation** — Paste additional skill content into the chat when working on specific phases (e.g., paste `security-and-hardening` when building auth).
|
|
48
|
+
3. **Use references as checklists** — Paste `references/security-checklist.md` and ask Windsurf to verify each item.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# simplify-ignore hook
|
|
2
|
+
|
|
3
|
+
Block-level protection for `/code-simplify`. Mark code that should never be simplified — the model won't see it.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
1. Annotate blocks you want to protect:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
/* simplify-ignore-start: perf-critical */
|
|
11
|
+
// manually unrolled XOR — 3x faster than a loop
|
|
12
|
+
result[0] = buf[0] ^ key[0];
|
|
13
|
+
result[1] = buf[1] ^ key[1];
|
|
14
|
+
result[2] = buf[2] ^ key[2];
|
|
15
|
+
result[3] = buf[3] ^ key[3];
|
|
16
|
+
/* simplify-ignore-end */
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
2. Add hooks to `.claude/settings.json`:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"hooks": {
|
|
24
|
+
"PreToolUse": [
|
|
25
|
+
{
|
|
26
|
+
"matcher": "Read",
|
|
27
|
+
"hooks": [{ "type": "command", "command": "bash ${CLAUDE_PROJECT_DIR}/hooks/simplify-ignore.sh" }]
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"PostToolUse": [
|
|
31
|
+
{
|
|
32
|
+
"matcher": "Edit|Write",
|
|
33
|
+
"hooks": [{ "type": "command", "command": "bash ${CLAUDE_PROJECT_DIR}/hooks/simplify-ignore.sh" }]
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"Stop": [
|
|
37
|
+
{
|
|
38
|
+
"hooks": [{ "type": "command", "command": "bash ${CLAUDE_PROJECT_DIR}/hooks/simplify-ignore.sh" }]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
3. Run `/code-simplify` — protected blocks become `/* BLOCK_de115a1d: perf-critical */` placeholders. The model reasons about surrounding code without seeing the protected implementation.
|
|
46
|
+
|
|
47
|
+
> **Note:** The hook stores temporary backups in `.claude/.simplify-ignore-cache/`. Make sure this path is in your `.gitignore`.
|
|
48
|
+
|
|
49
|
+
## How it works
|
|
50
|
+
|
|
51
|
+
One script, three hook events:
|
|
52
|
+
|
|
53
|
+
| Event | Action |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `PreToolUse Read` | Backs up file, replaces blocks with `BLOCK_<hash>` placeholders in-place |
|
|
56
|
+
| `PostToolUse Edit\|Write` | Expands placeholders back to real code, saves model's changes, re-filters |
|
|
57
|
+
| `Stop` | Restores all files from backup when session ends |
|
|
58
|
+
|
|
59
|
+
Each block is content-hashed (8 hex chars via `shasum`/`sha1sum`) so the round-trip is unambiguous even if the model duplicates or reorders placeholders. Cache is project-scoped to prevent cross-session interference.
|
|
60
|
+
|
|
61
|
+
## Annotation syntax
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
/* simplify-ignore-start */ // basic — hides the block
|
|
65
|
+
/* simplify-ignore-start: reason */ // with reason — appears in placeholder
|
|
66
|
+
/* simplify-ignore-end */
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Any comment style works (`//`, `/*`, `#`, `<!--`). Multiple blocks per file and single-line blocks supported. Placeholders preserve the original comment syntax (e.g. `# BLOCK_xxx` for Python, `<!-- BLOCK_xxx -->` for HTML).
|
|
70
|
+
|
|
71
|
+
## Crash recovery
|
|
72
|
+
|
|
73
|
+
If Claude Code crashes without triggering the Stop hook, files on disk may still have `BLOCK_<hash>` placeholders. To restore manually:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
echo '{}' | bash hooks/simplify-ignore.sh
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Backups are stored in `.claude/.simplify-ignore-cache/` within your project directory.
|
|
80
|
+
|
|
81
|
+
## Known limitations
|
|
82
|
+
|
|
83
|
+
- **Single-line blocks hide the entire line.** If `simplify-ignore-start` and `simplify-ignore-end` appear on the same line as other code, the whole line is hidden from the model, not just the annotated portion. Use dedicated lines for annotations.
|
|
84
|
+
- **Comment suffix detection covers `*/` and `-->` only.** Template engines with non-standard comment closers (ERB `%>`, Blade `--}}`) may produce unbalanced placeholders. Use `#` or `//` style comments instead.
|
|
85
|
+
- **Fallback expansion is progressive, not exact.** If the model alters a placeholder's formatting (e.g. changes the reason text), the hook tries progressively simpler matches: full placeholder → prefix+hash+suffix → hash-only. The hash-only fallback may leave cosmetic debris (e.g. stray `:` or reason text). A warning is printed to stderr when this happens.
|
|
86
|
+
- **File renaming leaves placeholders.** If the model renames or moves a file via a shell command, the new file will retain `BLOCK_<hash>` placeholders. The original code is saved as `<old-filename>.recovered` when the session stops. You must manually restore the recovered code into the new file.
|
|
87
|
+
|
|
88
|
+
## Requirements
|
|
89
|
+
|
|
90
|
+
- `jq`, `shasum` or `sha1sum` (auto-detected), Bash 3.2+
|
package/hooks/hooks.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# agent-skills session start hook
|
|
3
|
+
# Injects the using-agent-skills meta-skill into every new session
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
6
|
+
SKILLS_DIR="$(dirname "$SCRIPT_DIR")/skills"
|
|
7
|
+
META_SKILL="$SKILLS_DIR/using-agent-skills/SKILL.md"
|
|
8
|
+
|
|
9
|
+
if [ -f "$META_SKILL" ]; then
|
|
10
|
+
CONTENT=$(cat "$META_SKILL")
|
|
11
|
+
# Output as JSON for Claude Code hook consumption
|
|
12
|
+
cat <<EOF
|
|
13
|
+
{
|
|
14
|
+
"priority": "IMPORTANT",
|
|
15
|
+
"message": "agent-skills loaded. Use the skill discovery flowchart to find the right skill for your task.\n\n$CONTENT"
|
|
16
|
+
}
|
|
17
|
+
EOF
|
|
18
|
+
else
|
|
19
|
+
echo '{"priority": "INFO", "message": "agent-skills: using-agent-skills meta-skill not found. Skills may still be available individually."}'
|
|
20
|
+
fi
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# simplify-ignore-test.sh — Tests for the simplify-ignore hook
|
|
3
|
+
#
|
|
4
|
+
# Exercises filter_file by extracting function definitions from the hook.
|
|
5
|
+
# Run: bash hooks/simplify-ignore-test.sh
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
PASS=0 FAIL=0
|
|
10
|
+
TMPDIR=$(mktemp -d)
|
|
11
|
+
trap 'rm -rf "$TMPDIR"' EXIT
|
|
12
|
+
|
|
13
|
+
export CACHE="$TMPDIR/cache"
|
|
14
|
+
mkdir -p "$CACHE"
|
|
15
|
+
|
|
16
|
+
# Extract function definitions we need
|
|
17
|
+
hash_cmd() {
|
|
18
|
+
if command -v shasum >/dev/null 2>&1; then shasum
|
|
19
|
+
elif command -v sha1sum >/dev/null 2>&1; then sha1sum
|
|
20
|
+
else printf '%s\n' "error: missing shasum or sha1sum" >&2; exit 1; fi
|
|
21
|
+
}
|
|
22
|
+
file_id() { printf '%s' "$1" | hash_cmd | cut -c1-16; }
|
|
23
|
+
block_hash() { printf '%s' "$1" | hash_cmd | cut -c1-8; }
|
|
24
|
+
escape_glob() {
|
|
25
|
+
local s="$1"
|
|
26
|
+
s="${s//\\/\\\\}"
|
|
27
|
+
s="${s//\*/\\*}"
|
|
28
|
+
s="${s//\?/\\?}"
|
|
29
|
+
s="${s//\[/\\[}"
|
|
30
|
+
printf '%s' "$s"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
# Extract filter_file from the hook script (line 59 "filter_file()" to line 142 closing brace)
|
|
34
|
+
eval "$(sed -n '/^filter_file()/,/^}/p' hooks/simplify-ignore.sh)"
|
|
35
|
+
|
|
36
|
+
assert_eq() {
|
|
37
|
+
local label="$1" expected="$2" actual="$3"
|
|
38
|
+
if [ "$expected" = "$actual" ]; then
|
|
39
|
+
PASS=$((PASS + 1))
|
|
40
|
+
printf ' PASS: %s\n' "$label"
|
|
41
|
+
else
|
|
42
|
+
FAIL=$((FAIL + 1))
|
|
43
|
+
printf ' FAIL: %s\n' "$label" >&2
|
|
44
|
+
printf ' expected: %s\n' "$(printf '%s' "$expected" | cat -v)" >&2
|
|
45
|
+
printf ' actual: %s\n' "$(printf '%s' "$actual" | cat -v)" >&2
|
|
46
|
+
fi
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# ── Test 1: Single-line block produces exactly one placeholder ────────────
|
|
50
|
+
printf 'Test 1: Single-line block (start+end on same line)\n'
|
|
51
|
+
rm -f "$CACHE"/*
|
|
52
|
+
|
|
53
|
+
SRC="$TMPDIR/single-line.js"
|
|
54
|
+
DEST="$TMPDIR/single-line-filtered.js"
|
|
55
|
+
cat > "$SRC" <<'EOF'
|
|
56
|
+
const a = 1;
|
|
57
|
+
/* simplify-ignore-start */ const secret = 42; /* simplify-ignore-end */
|
|
58
|
+
const b = 2;
|
|
59
|
+
EOF
|
|
60
|
+
|
|
61
|
+
FID="test_single"
|
|
62
|
+
filter_file "$SRC" "$DEST" "$FID"
|
|
63
|
+
|
|
64
|
+
placeholder_count=$(grep -c 'BLOCK_' "$DEST")
|
|
65
|
+
assert_eq "exactly one placeholder line" "1" "$placeholder_count"
|
|
66
|
+
assert_eq "line before block preserved" "1" "$(grep -c 'const a = 1' "$DEST")"
|
|
67
|
+
assert_eq "line after block preserved" "1" "$(grep -c 'const b = 2' "$DEST")"
|
|
68
|
+
|
|
69
|
+
block_files=$(ls "$CACHE/${FID}".block.* 2>/dev/null | wc -l | tr -d ' ')
|
|
70
|
+
assert_eq "one block file in cache" "1" "$block_files"
|
|
71
|
+
|
|
72
|
+
block_content=$(cat "$CACHE/${FID}".block.*)
|
|
73
|
+
assert_eq "block content matches" \
|
|
74
|
+
"/* simplify-ignore-start */ const secret = 42; /* simplify-ignore-end */" \
|
|
75
|
+
"$block_content"
|
|
76
|
+
|
|
77
|
+
# ── Test 2: Multi-line block ─────────────────────────────────────────────
|
|
78
|
+
printf '\nTest 2: Multi-line block\n'
|
|
79
|
+
rm -f "$CACHE"/*
|
|
80
|
+
|
|
81
|
+
SRC="$TMPDIR/multi-line.js"
|
|
82
|
+
DEST="$TMPDIR/multi-line-filtered.js"
|
|
83
|
+
cat > "$SRC" <<'EOF'
|
|
84
|
+
const a = 1;
|
|
85
|
+
// simplify-ignore-start
|
|
86
|
+
const secret1 = 42;
|
|
87
|
+
const secret2 = 99;
|
|
88
|
+
// simplify-ignore-end
|
|
89
|
+
const b = 2;
|
|
90
|
+
EOF
|
|
91
|
+
|
|
92
|
+
FID="test_multi"
|
|
93
|
+
filter_file "$SRC" "$DEST" "$FID"
|
|
94
|
+
|
|
95
|
+
placeholder_count=$(grep -c 'BLOCK_' "$DEST")
|
|
96
|
+
assert_eq "exactly one placeholder for multi-line block" "1" "$placeholder_count"
|
|
97
|
+
|
|
98
|
+
output_lines=$(wc -l < "$DEST" | tr -d ' ')
|
|
99
|
+
assert_eq "output has 3 lines (before + placeholder + after)" "3" "$output_lines"
|
|
100
|
+
|
|
101
|
+
# ── Test 3: Multiple blocks in one file ──────────────────────────────────
|
|
102
|
+
printf '\nTest 3: Multiple blocks in one file\n'
|
|
103
|
+
rm -f "$CACHE"/*
|
|
104
|
+
|
|
105
|
+
SRC="$TMPDIR/multi-block.js"
|
|
106
|
+
DEST="$TMPDIR/multi-block-filtered.js"
|
|
107
|
+
cat > "$SRC" <<'EOF'
|
|
108
|
+
line1
|
|
109
|
+
// simplify-ignore-start
|
|
110
|
+
blockA
|
|
111
|
+
// simplify-ignore-end
|
|
112
|
+
line2
|
|
113
|
+
// simplify-ignore-start
|
|
114
|
+
blockB
|
|
115
|
+
// simplify-ignore-end
|
|
116
|
+
line3
|
|
117
|
+
EOF
|
|
118
|
+
|
|
119
|
+
FID="test_multiblock"
|
|
120
|
+
filter_file "$SRC" "$DEST" "$FID"
|
|
121
|
+
|
|
122
|
+
placeholder_count=$(grep -c 'BLOCK_' "$DEST")
|
|
123
|
+
assert_eq "two placeholders for two blocks" "2" "$placeholder_count"
|
|
124
|
+
|
|
125
|
+
block_files=$(ls "$CACHE/${FID}".block.* 2>/dev/null | wc -l | tr -d ' ')
|
|
126
|
+
assert_eq "two block files in cache" "2" "$block_files"
|
|
127
|
+
|
|
128
|
+
# ── Test 4: Reason string preserved ──────────────────────────────────────
|
|
129
|
+
printf '\nTest 4: Reason string in placeholder\n'
|
|
130
|
+
rm -f "$CACHE"/*
|
|
131
|
+
|
|
132
|
+
SRC="$TMPDIR/reason.js"
|
|
133
|
+
DEST="$TMPDIR/reason-filtered.js"
|
|
134
|
+
cat > "$SRC" <<'EOF'
|
|
135
|
+
// simplify-ignore-start: perf-critical
|
|
136
|
+
hot_loop();
|
|
137
|
+
// simplify-ignore-end
|
|
138
|
+
EOF
|
|
139
|
+
|
|
140
|
+
FID="test_reason"
|
|
141
|
+
filter_file "$SRC" "$DEST" "$FID"
|
|
142
|
+
|
|
143
|
+
assert_eq "placeholder includes reason" "1" "$(grep -c 'perf-critical' "$DEST")"
|
|
144
|
+
|
|
145
|
+
reason_files=$(ls "$CACHE/${FID}".reason.* 2>/dev/null | wc -l | tr -d ' ')
|
|
146
|
+
assert_eq "reason file saved" "1" "$reason_files"
|
|
147
|
+
assert_eq "reason content" "perf-critical" "$(cat "$CACHE/${FID}".reason.*)"
|
|
148
|
+
|
|
149
|
+
# ── Test 5: Trailing newline preservation ────────────────────────────────
|
|
150
|
+
printf '\nTest 5: Trailing newline preservation\n'
|
|
151
|
+
rm -f "$CACHE"/*
|
|
152
|
+
|
|
153
|
+
SRC="$TMPDIR/no-trailing-nl.js"
|
|
154
|
+
DEST="$TMPDIR/no-trailing-nl-filtered.js"
|
|
155
|
+
printf 'line1\n// simplify-ignore-start\nsecret\n// simplify-ignore-end' > "$SRC"
|
|
156
|
+
|
|
157
|
+
FID="test_trail"
|
|
158
|
+
filter_file "$SRC" "$DEST" "$FID"
|
|
159
|
+
|
|
160
|
+
# Source has no trailing newline; dest should also have no trailing newline
|
|
161
|
+
src_has_nl=$(tail -c 1 "$SRC" | wc -l | tr -d ' ')
|
|
162
|
+
dest_has_nl=$(tail -c 1 "$DEST" | wc -l | tr -d ' ')
|
|
163
|
+
assert_eq "dest preserves no-trailing-newline from source" "$src_has_nl" "$dest_has_nl"
|
|
164
|
+
|
|
165
|
+
# ── Test 6: No blocks → return 1 ────────────────────────────────────────
|
|
166
|
+
printf '\nTest 6: No blocks returns 1\n'
|
|
167
|
+
rm -f "$CACHE"/*
|
|
168
|
+
|
|
169
|
+
SRC="$TMPDIR/no-blocks.js"
|
|
170
|
+
DEST="$TMPDIR/no-blocks-filtered.js"
|
|
171
|
+
cat > "$SRC" <<'EOF'
|
|
172
|
+
const a = 1;
|
|
173
|
+
const b = 2;
|
|
174
|
+
EOF
|
|
175
|
+
|
|
176
|
+
FID="test_noblocks"
|
|
177
|
+
rc=0
|
|
178
|
+
filter_file "$SRC" "$DEST" "$FID" || rc=$?
|
|
179
|
+
assert_eq "returns 1 when no blocks found" "1" "$rc"
|
|
180
|
+
|
|
181
|
+
# ── Test 7: Unclosed block emits warning and flushes ─────────────────────
|
|
182
|
+
printf '\nTest 7: Unclosed block\n'
|
|
183
|
+
rm -f "$CACHE"/*
|
|
184
|
+
|
|
185
|
+
SRC="$TMPDIR/unclosed.js"
|
|
186
|
+
DEST="$TMPDIR/unclosed-filtered.js"
|
|
187
|
+
cat > "$SRC" <<'EOF'
|
|
188
|
+
line1
|
|
189
|
+
// simplify-ignore-start
|
|
190
|
+
orphan code
|
|
191
|
+
EOF
|
|
192
|
+
|
|
193
|
+
FID="test_unclosed"
|
|
194
|
+
stderr_out=$(filter_file "$SRC" "$DEST" "$FID" 2>&1) || true
|
|
195
|
+
assert_eq "warning emitted for unclosed block" "1" "$(printf '%s' "$stderr_out" | grep -c 'unclosed')"
|
|
196
|
+
assert_eq "orphan code flushed to output" "1" "$(grep -c 'orphan code' "$DEST")"
|
|
197
|
+
|
|
198
|
+
# ── Test 8: Single-line block with reason ────────────────────────────────
|
|
199
|
+
printf '\nTest 8: Single-line block with reason\n'
|
|
200
|
+
rm -f "$CACHE"/*
|
|
201
|
+
|
|
202
|
+
SRC="$TMPDIR/single-reason.js"
|
|
203
|
+
DEST="$TMPDIR/single-reason-filtered.js"
|
|
204
|
+
cat > "$SRC" <<'EOF'
|
|
205
|
+
before
|
|
206
|
+
/* simplify-ignore-start: hot-path */ x = compute(); /* simplify-ignore-end */
|
|
207
|
+
after
|
|
208
|
+
EOF
|
|
209
|
+
|
|
210
|
+
FID="test_single_reason"
|
|
211
|
+
filter_file "$SRC" "$DEST" "$FID"
|
|
212
|
+
|
|
213
|
+
placeholder_count=$(grep -c 'BLOCK_' "$DEST")
|
|
214
|
+
assert_eq "exactly one placeholder for single-line+reason" "1" "$placeholder_count"
|
|
215
|
+
assert_eq "reason in placeholder" "1" "$(grep -c 'hot-path' "$DEST")"
|
|
216
|
+
|
|
217
|
+
# ── Test 9: HTML comment syntax ──────────────────────────────────────────
|
|
218
|
+
printf '\nTest 9: HTML comment syntax\n'
|
|
219
|
+
rm -f "$CACHE"/*
|
|
220
|
+
|
|
221
|
+
SRC="$TMPDIR/html.html"
|
|
222
|
+
DEST="$TMPDIR/html-filtered.html"
|
|
223
|
+
cat > "$SRC" <<'EOF'
|
|
224
|
+
<div>
|
|
225
|
+
<!-- simplify-ignore-start -->
|
|
226
|
+
<secret-component />
|
|
227
|
+
<!-- simplify-ignore-end -->
|
|
228
|
+
</div>
|
|
229
|
+
EOF
|
|
230
|
+
|
|
231
|
+
FID="test_html"
|
|
232
|
+
filter_file "$SRC" "$DEST" "$FID"
|
|
233
|
+
|
|
234
|
+
placeholder_count=$(grep -c 'BLOCK_' "$DEST")
|
|
235
|
+
assert_eq "HTML block replaced" "1" "$placeholder_count"
|
|
236
|
+
assert_eq "HTML suffix preserved" "1" "$(grep -c '\-\->' "$DEST")"
|
|
237
|
+
|
|
238
|
+
# ── Test 10: JSON parsing error warning ──────────────────────────────────
|
|
239
|
+
printf '\nTest 10: Malformed JSON input produces warning\n'
|
|
240
|
+
|
|
241
|
+
warning_out=$(echo 'NOT_JSON{{{' | bash hooks/simplify-ignore.sh 2>&1) || true
|
|
242
|
+
assert_eq "warning on bad JSON" "1" "$(printf '%s' "$warning_out" | grep -c 'Warning.*failed to parse')"
|
|
243
|
+
|
|
244
|
+
# ── Summary ──────────────────────────────────────────────────────────────
|
|
245
|
+
printf '\n══════════════════════════════════════════\n'
|
|
246
|
+
printf 'Results: %d passed, %d failed\n' "$PASS" "$FAIL"
|
|
247
|
+
[ "$FAIL" -eq 0 ] && exit 0 || exit 1
|