@phuc1403/musketeer 0.8.0 → 0.9.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 (76) hide show
  1. package/README.md +49 -49
  2. package/manifest.json +333 -301
  3. package/package.json +1 -1
  4. package/template/.claude/agents/code-reviewer.md +182 -166
  5. package/template/.claude/hooks/git-skill-reminder.cjs +53 -0
  6. package/template/.claude/hooks/lib/colors.cjs +180 -122
  7. package/template/.claude/hooks/lib/transcript-parser.cjs +300 -277
  8. package/template/.claude/skills/code-review/SKILL.md +201 -54
  9. package/template/.claude/skills/code-review/references/checklist-workflow.md +96 -0
  10. package/template/.claude/skills/code-review/references/checklists/api.md +52 -52
  11. package/template/.claude/skills/code-review/references/checklists/base.md +100 -100
  12. package/template/.claude/skills/code-review/references/checklists/web-app.md +54 -54
  13. package/template/.claude/skills/code-review/references/code-review-reception.md +113 -0
  14. package/template/.claude/skills/code-review/references/codebase-scan-workflow.md +30 -0
  15. package/template/.claude/skills/code-review/references/edge-case-scouting.md +119 -0
  16. package/template/.claude/skills/code-review/references/input-mode-resolution.md +135 -0
  17. package/template/.claude/skills/code-review/references/parallel-review-workflow.md +76 -0
  18. package/template/.claude/skills/code-review/references/requesting-code-review.md +116 -0
  19. package/template/.claude/skills/code-review/references/spec-compliance-review.md +43 -0
  20. package/template/.claude/skills/code-review/references/task-management-reviews.md +140 -0
  21. package/template/.claude/skills/code-review/references/verification-before-completion.md +139 -0
  22. package/template/.claude/skills/git/SKILL.md +131 -115
  23. package/template/.claude/skills/git/references/branch-management.md +88 -88
  24. package/template/.claude/skills/git/references/commit-standards.md +46 -46
  25. package/template/.claude/skills/git/references/context-efficiency.md +54 -0
  26. package/template/.claude/skills/git/references/gh-cli-guide.md +109 -109
  27. package/template/.claude/skills/git/references/safety-protocols.md +69 -69
  28. package/template/.claude/skills/git/references/workflow-commit.md +58 -58
  29. package/template/.claude/skills/git/references/workflow-merge-pr.md +136 -0
  30. package/template/.claude/skills/git/references/workflow-merge.md +48 -48
  31. package/template/.claude/skills/git/references/workflow-pr.md +58 -58
  32. package/template/.claude/skills/git/references/workflow-push.md +52 -52
  33. package/template/.claude/skills/skill-creator/LICENSE.txt +201 -201
  34. package/template/.claude/skills/skill-creator/SKILL.md +154 -149
  35. package/template/.claude/skills/skill-creator/agents/analyzer.md +274 -274
  36. package/template/.claude/skills/skill-creator/agents/comparator.md +202 -202
  37. package/template/.claude/skills/skill-creator/agents/grader.md +223 -223
  38. package/template/.claude/skills/skill-creator/assets/eval_review.html +146 -146
  39. package/template/.claude/skills/skill-creator/eval-viewer/generate_review.py +471 -471
  40. package/template/.claude/skills/skill-creator/eval-viewer/viewer.html +1325 -1325
  41. package/template/.claude/skills/skill-creator/references/benchmark-optimization-guide.md +86 -86
  42. package/template/.claude/skills/skill-creator/references/distribution-guide.md +79 -79
  43. package/template/.claude/skills/skill-creator/references/eval-infrastructure-guide.md +129 -129
  44. package/template/.claude/skills/skill-creator/references/eval-schemas.md +121 -121
  45. package/template/.claude/skills/skill-creator/references/mcp-skills-integration.md +71 -71
  46. package/template/.claude/skills/skill-creator/references/metadata-quality-criteria.md +94 -94
  47. package/template/.claude/skills/skill-creator/references/plugin-marketplace-hosting.md +104 -104
  48. package/template/.claude/skills/skill-creator/references/plugin-marketplace-overview.md +89 -89
  49. package/template/.claude/skills/skill-creator/references/plugin-marketplace-schema.md +93 -93
  50. package/template/.claude/skills/skill-creator/references/plugin-marketplace-sources.md +103 -103
  51. package/template/.claude/skills/skill-creator/references/plugin-marketplace-troubleshooting.md +76 -76
  52. package/template/.claude/skills/skill-creator/references/script-quality-criteria.md +106 -106
  53. package/template/.claude/skills/skill-creator/references/skill-anatomy-and-requirements.md +77 -77
  54. package/template/.claude/skills/skill-creator/references/skill-creation-workflow.md +152 -151
  55. package/template/.claude/skills/skill-creator/references/skill-design-patterns.md +75 -75
  56. package/template/.claude/skills/skill-creator/references/skillmark-benchmark-criteria.md +102 -102
  57. package/template/.claude/skills/skill-creator/references/structure-organization-criteria.md +114 -114
  58. package/template/.claude/skills/skill-creator/references/testing-and-iteration.md +78 -78
  59. package/template/.claude/skills/skill-creator/references/token-efficiency-criteria.md +74 -74
  60. package/template/.claude/skills/skill-creator/references/troubleshooting-guide.md +81 -81
  61. package/template/.claude/skills/skill-creator/references/validation-checklist.md +83 -83
  62. package/template/.claude/skills/skill-creator/references/writing-effective-instructions.md +88 -88
  63. package/template/.claude/skills/skill-creator/references/yaml-frontmatter-reference.md +92 -92
  64. package/template/.claude/skills/skill-creator/scripts/aggregate_benchmark.py +401 -401
  65. package/template/.claude/skills/skill-creator/scripts/encoding_utils.py +36 -36
  66. package/template/.claude/skills/skill-creator/scripts/generate_report.py +326 -326
  67. package/template/.claude/skills/skill-creator/scripts/improve_description.py +248 -248
  68. package/template/.claude/skills/skill-creator/scripts/init_skill.py +360 -360
  69. package/template/.claude/skills/skill-creator/scripts/package_skill.py +143 -143
  70. package/template/.claude/skills/skill-creator/scripts/quick_validate.py +110 -110
  71. package/template/.claude/skills/skill-creator/scripts/run_eval.py +310 -310
  72. package/template/.claude/skills/skill-creator/scripts/run_loop.py +332 -332
  73. package/template/.claude/skills/skill-creator/scripts/utils.py +47 -47
  74. package/template/.claude/statusline.cjs +0 -0
  75. package/template/.claude/skills/code-review/references/adversarial-review.md +0 -223
  76. /package/template/.claude/hooks/{usage-context-awareness.cjs → usage-quota-cache-refresh.cjs} +0 -0
@@ -1,103 +1,103 @@
1
- # Plugin Marketplace Sources
2
-
3
- Plugin source types for `marketplace.json` plugin entries.
4
-
5
- ## Relative Paths (Same Repo)
6
-
7
- ```json
8
- { "name": "my-plugin", "source": "./plugins/my-plugin" }
9
- ```
10
-
11
- **Note:** Only works when marketplace added via Git (GitHub/GitLab/git URL). URL-based marketplaces only download `marketplace.json`, not plugin files. Use GitHub/git sources for URL-based distribution.
12
-
13
- ## GitHub Repositories
14
-
15
- ```json
16
- {
17
- "name": "github-plugin",
18
- "source": { "source": "github", "repo": "owner/plugin-repo" }
19
- }
20
- ```
21
-
22
- Pin to specific version:
23
- ```json
24
- {
25
- "name": "github-plugin",
26
- "source": {
27
- "source": "github",
28
- "repo": "owner/plugin-repo",
29
- "ref": "v2.0.0",
30
- "sha": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"
31
- }
32
- }
33
- ```
34
-
35
- | Field | Type | Description |
36
- |-------|------|-------------|
37
- | `repo` | string | Required. `owner/repo` format |
38
- | `ref` | string | Optional. Branch or tag (defaults to repo default) |
39
- | `sha` | string | Optional. Full 40-char commit SHA for exact pinning |
40
-
41
- ## Git Repositories (GitLab, Bitbucket, etc.)
42
-
43
- ```json
44
- {
45
- "name": "git-plugin",
46
- "source": { "source": "url", "url": "https://gitlab.com/team/plugin.git" }
47
- }
48
- ```
49
-
50
- Pin to specific version:
51
- ```json
52
- {
53
- "name": "git-plugin",
54
- "source": {
55
- "source": "url",
56
- "url": "https://gitlab.com/team/plugin.git",
57
- "ref": "main",
58
- "sha": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"
59
- }
60
- }
61
- ```
62
-
63
- | Field | Type | Description |
64
- |-------|------|-------------|
65
- | `url` | string | Required. Full git URL (must end `.git`) |
66
- | `ref` | string | Optional. Branch or tag |
67
- | `sha` | string | Optional. Full 40-char commit SHA |
68
-
69
- ## Advanced Example (All Features)
70
-
71
- ```json
72
- {
73
- "name": "enterprise-tools",
74
- "source": { "source": "github", "repo": "company/enterprise-plugin" },
75
- "description": "Enterprise workflow automation tools",
76
- "version": "2.1.0",
77
- "author": { "name": "Enterprise Team", "email": "enterprise@example.com" },
78
- "homepage": "https://docs.example.com/plugins/enterprise-tools",
79
- "license": "MIT",
80
- "keywords": ["enterprise", "workflow", "automation"],
81
- "category": "productivity",
82
- "commands": ["./commands/core/", "./commands/enterprise/"],
83
- "agents": ["./agents/security-reviewer.md", "./agents/compliance-checker.md"],
84
- "hooks": {
85
- "PostToolUse": [{
86
- "matcher": "Write|Edit",
87
- "hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/scripts/validate.sh" }]
88
- }]
89
- },
90
- "mcpServers": {
91
- "enterprise-db": {
92
- "command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
93
- "args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"]
94
- }
95
- },
96
- "strict": false
97
- }
98
- ```
99
-
100
- **Key notes:**
101
- - `${CLAUDE_PLUGIN_ROOT}` — references files within plugin's installation cache directory
102
- - `strict: false` — marketplace entry defines plugin entirely, no `plugin.json` needed
103
- - `commands`/`agents` — multiple directories or individual files, paths relative to plugin root
1
+ # Plugin Marketplace Sources
2
+
3
+ Plugin source types for `marketplace.json` plugin entries.
4
+
5
+ ## Relative Paths (Same Repo)
6
+
7
+ ```json
8
+ { "name": "my-plugin", "source": "./plugins/my-plugin" }
9
+ ```
10
+
11
+ **Note:** Only works when marketplace added via Git (GitHub/GitLab/git URL). URL-based marketplaces only download `marketplace.json`, not plugin files. Use GitHub/git sources for URL-based distribution.
12
+
13
+ ## GitHub Repositories
14
+
15
+ ```json
16
+ {
17
+ "name": "github-plugin",
18
+ "source": { "source": "github", "repo": "owner/plugin-repo" }
19
+ }
20
+ ```
21
+
22
+ Pin to specific version:
23
+ ```json
24
+ {
25
+ "name": "github-plugin",
26
+ "source": {
27
+ "source": "github",
28
+ "repo": "owner/plugin-repo",
29
+ "ref": "v2.0.0",
30
+ "sha": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"
31
+ }
32
+ }
33
+ ```
34
+
35
+ | Field | Type | Description |
36
+ |-------|------|-------------|
37
+ | `repo` | string | Required. `owner/repo` format |
38
+ | `ref` | string | Optional. Branch or tag (defaults to repo default) |
39
+ | `sha` | string | Optional. Full 40-char commit SHA for exact pinning |
40
+
41
+ ## Git Repositories (GitLab, Bitbucket, etc.)
42
+
43
+ ```json
44
+ {
45
+ "name": "git-plugin",
46
+ "source": { "source": "url", "url": "https://gitlab.com/team/plugin.git" }
47
+ }
48
+ ```
49
+
50
+ Pin to specific version:
51
+ ```json
52
+ {
53
+ "name": "git-plugin",
54
+ "source": {
55
+ "source": "url",
56
+ "url": "https://gitlab.com/team/plugin.git",
57
+ "ref": "main",
58
+ "sha": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0"
59
+ }
60
+ }
61
+ ```
62
+
63
+ | Field | Type | Description |
64
+ |-------|------|-------------|
65
+ | `url` | string | Required. Full git URL (must end `.git`) |
66
+ | `ref` | string | Optional. Branch or tag |
67
+ | `sha` | string | Optional. Full 40-char commit SHA |
68
+
69
+ ## Advanced Example (All Features)
70
+
71
+ ```json
72
+ {
73
+ "name": "enterprise-tools",
74
+ "source": { "source": "github", "repo": "company/enterprise-plugin" },
75
+ "description": "Enterprise workflow automation tools",
76
+ "version": "2.1.0",
77
+ "author": { "name": "Enterprise Team", "email": "enterprise@example.com" },
78
+ "homepage": "https://docs.example.com/plugins/enterprise-tools",
79
+ "license": "MIT",
80
+ "keywords": ["enterprise", "workflow", "automation"],
81
+ "category": "productivity",
82
+ "commands": ["./commands/core/", "./commands/enterprise/"],
83
+ "agents": ["./agents/security-reviewer.md", "./agents/compliance-checker.md"],
84
+ "hooks": {
85
+ "PostToolUse": [{
86
+ "matcher": "Write|Edit",
87
+ "hooks": [{ "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/scripts/validate.sh" }]
88
+ }]
89
+ },
90
+ "mcpServers": {
91
+ "enterprise-db": {
92
+ "command": "${CLAUDE_PLUGIN_ROOT}/servers/db-server",
93
+ "args": ["--config", "${CLAUDE_PLUGIN_ROOT}/config.json"]
94
+ }
95
+ },
96
+ "strict": false
97
+ }
98
+ ```
99
+
100
+ **Key notes:**
101
+ - `${CLAUDE_PLUGIN_ROOT}` — references files within plugin's installation cache directory
102
+ - `strict: false` — marketplace entry defines plugin entirely, no `plugin.json` needed
103
+ - `commands`/`agents` — multiple directories or individual files, paths relative to plugin root
@@ -1,76 +1,76 @@
1
- # Plugin Marketplace Troubleshooting
2
-
3
- ## Marketplace Not Loading
4
-
5
- **Symptoms:** Can't add marketplace or see plugins.
6
-
7
- **Checklist:**
8
- - Marketplace URL accessible?
9
- - `.claude-plugin/marketplace.json` exists at specified path?
10
- - JSON syntax valid? Run `claude plugin validate .` or `/plugin validate .`
11
- - Private repo — do you have access permissions?
12
-
13
- ## Validation Errors
14
-
15
- Run `claude plugin validate .` from marketplace directory. Common errors:
16
-
17
- | Error | Cause | Fix |
18
- |-------|-------|-----|
19
- | `File not found: .claude-plugin/marketplace.json` | Missing manifest | Create with required fields |
20
- | `Invalid JSON syntax: Unexpected token...` | JSON syntax error | Fix commas, quotes, brackets |
21
- | `Duplicate plugin name "x"` | Two plugins share name | Give unique `name` values |
22
- | `plugins[0].source: Path traversal not allowed` | Source contains `..` | Use paths relative to root, no `..` |
23
-
24
- **Warnings (non-blocking):**
25
- - `Marketplace has no plugins defined` — add plugins to array
26
- - `No marketplace description provided` — add `metadata.description`
27
- - `Plugin "x" uses npm source` — npm not fully implemented, use github/local
28
-
29
- ## Plugin Installation Failures
30
-
31
- **Symptoms:** Marketplace appears but install fails.
32
-
33
- **Checklist:**
34
- - Plugin source URLs accessible?
35
- - Plugin directories contain required files?
36
- - GitHub sources — repos public or you have access?
37
- - Test manually by cloning/downloading source
38
-
39
- ## Private Repository Auth Fails
40
-
41
- ### Manual Install/Update
42
- - Authenticated with git provider? `gh auth status` for GitHub
43
- - Credential helper configured? `git config --global credential.helper`
44
- - Can you clone repo manually?
45
-
46
- ### Background Auto-Updates
47
- - Token set in environment? `echo $GITHUB_TOKEN`
48
- - Token has required permissions?
49
- - GitHub: `repo` scope for private repos
50
- - GitLab: `read_repository` scope minimum
51
- - Token not expired?
52
-
53
- ## Relative Paths Fail in URL-Based Marketplaces
54
-
55
- **Symptoms:** Added marketplace via URL, plugins with `"./plugins/my-plugin"` source fail.
56
-
57
- **Cause:** URL-based marketplaces only download `marketplace.json`, not plugin files. Relative paths reference files on remote server that weren't downloaded.
58
-
59
- **Fixes:**
60
- 1. **Use external sources:**
61
- ```json
62
- { "name": "my-plugin", "source": { "source": "github", "repo": "owner/repo" } }
63
- ```
64
- 2. **Use Git-based marketplace:** Host in Git repo, add via git URL. Clones entire repo, relative paths work.
65
-
66
- ## Files Not Found After Installation
67
-
68
- **Symptoms:** Plugin installs but file references fail, especially outside plugin directory.
69
-
70
- **Cause:** Plugins copied to cache directory, not used in-place. Paths like `../shared-utils` won't work.
71
-
72
- **Fixes:**
73
- - Use symlinks (followed during copying)
74
- - Restructure so shared directory is inside plugin source path
75
- - Use `${CLAUDE_PLUGIN_ROOT}` in hooks/MCP configs for cache-aware paths
76
- - See [Plugin caching docs](https://code.claude.com/docs/en/plugins-reference.md#plugin-caching-and-file-resolution)
1
+ # Plugin Marketplace Troubleshooting
2
+
3
+ ## Marketplace Not Loading
4
+
5
+ **Symptoms:** Can't add marketplace or see plugins.
6
+
7
+ **Checklist:**
8
+ - Marketplace URL accessible?
9
+ - `.claude-plugin/marketplace.json` exists at specified path?
10
+ - JSON syntax valid? Run `claude plugin validate .` or `/plugin validate .`
11
+ - Private repo — do you have access permissions?
12
+
13
+ ## Validation Errors
14
+
15
+ Run `claude plugin validate .` from marketplace directory. Common errors:
16
+
17
+ | Error | Cause | Fix |
18
+ |-------|-------|-----|
19
+ | `File not found: .claude-plugin/marketplace.json` | Missing manifest | Create with required fields |
20
+ | `Invalid JSON syntax: Unexpected token...` | JSON syntax error | Fix commas, quotes, brackets |
21
+ | `Duplicate plugin name "x"` | Two plugins share name | Give unique `name` values |
22
+ | `plugins[0].source: Path traversal not allowed` | Source contains `..` | Use paths relative to root, no `..` |
23
+
24
+ **Warnings (non-blocking):**
25
+ - `Marketplace has no plugins defined` — add plugins to array
26
+ - `No marketplace description provided` — add `metadata.description`
27
+ - `Plugin "x" uses npm source` — npm not fully implemented, use github/local
28
+
29
+ ## Plugin Installation Failures
30
+
31
+ **Symptoms:** Marketplace appears but install fails.
32
+
33
+ **Checklist:**
34
+ - Plugin source URLs accessible?
35
+ - Plugin directories contain required files?
36
+ - GitHub sources — repos public or you have access?
37
+ - Test manually by cloning/downloading source
38
+
39
+ ## Private Repository Auth Fails
40
+
41
+ ### Manual Install/Update
42
+ - Authenticated with git provider? `gh auth status` for GitHub
43
+ - Credential helper configured? `git config --global credential.helper`
44
+ - Can you clone repo manually?
45
+
46
+ ### Background Auto-Updates
47
+ - Token set in environment? `echo $GITHUB_TOKEN`
48
+ - Token has required permissions?
49
+ - GitHub: `repo` scope for private repos
50
+ - GitLab: `read_repository` scope minimum
51
+ - Token not expired?
52
+
53
+ ## Relative Paths Fail in URL-Based Marketplaces
54
+
55
+ **Symptoms:** Added marketplace via URL, plugins with `"./plugins/my-plugin"` source fail.
56
+
57
+ **Cause:** URL-based marketplaces only download `marketplace.json`, not plugin files. Relative paths reference files on remote server that weren't downloaded.
58
+
59
+ **Fixes:**
60
+ 1. **Use external sources:**
61
+ ```json
62
+ { "name": "my-plugin", "source": { "source": "github", "repo": "owner/repo" } }
63
+ ```
64
+ 2. **Use Git-based marketplace:** Host in Git repo, add via git URL. Clones entire repo, relative paths work.
65
+
66
+ ## Files Not Found After Installation
67
+
68
+ **Symptoms:** Plugin installs but file references fail, especially outside plugin directory.
69
+
70
+ **Cause:** Plugins copied to cache directory, not used in-place. Paths like `../shared-utils` won't work.
71
+
72
+ **Fixes:**
73
+ - Use symlinks (followed during copying)
74
+ - Restructure so shared directory is inside plugin source path
75
+ - Use `${CLAUDE_PLUGIN_ROOT}` in hooks/MCP configs for cache-aware paths
76
+ - See [Plugin caching docs](https://code.claude.com/docs/en/plugins-reference.md#plugin-caching-and-file-resolution)
@@ -1,106 +1,106 @@
1
- # Script Quality Criteria
2
-
3
- Scripts provide deterministic reliability and token efficiency.
4
-
5
- ## When to Include Scripts
6
-
7
- - Same code rewritten repeatedly
8
- - Deterministic operations needed
9
- - Complex transformations
10
- - External tool integrations
11
-
12
- ## Cross-Platform Requirements
13
-
14
- **Prefer:** Node.js or Python
15
- **Avoid:** Bash scripts (not well-supported on Windows)
16
-
17
- If bash required, provide Node.js/Python alternative.
18
-
19
- ## Testing Requirements
20
-
21
- **Mandatory:** All scripts must have tests
22
-
23
- ```bash
24
- # Run tests before packaging
25
- python -m pytest scripts/tests/
26
- # or
27
- npm test
28
- ```
29
-
30
- Tests must pass. No skipping failed tests.
31
-
32
- ## Environment Variables
33
-
34
- Respect hierarchy (first found wins):
35
-
36
- 1. `process.env` (runtime)
37
- 2. `$HOME/.claude/skills/<skill-name>/.env` (skill-specific)
38
- 3. `$HOME/.claude/skills/.env` (shared skills)
39
- 4. `$HOME/.claude/.env` (global)
40
- 5. `./.claude/skills/${SKILL}/.env` (cwd)
41
- 6. `./.claude/skills/.env` (cwd)
42
- 7. `./.claude/.env` (cwd)
43
-
44
- **Implementation pattern (Python):**
45
-
46
- ```python
47
- from dotenv import load_dotenv
48
- import os
49
-
50
- # Load in reverse order (last loaded wins if not set)
51
- load_dotenv('$HOME/.claude/.env')
52
- load_dotenv('$HOME/.claude/skills/.env')
53
- load_dotenv('$HOME/.claude/skills/my-skill/.env')
54
- load_dotenv('./.claude/skills/my-skill/.env')
55
- load_dotenv('./.claude/skills/.env')
56
- load_dotenv('./.claude/.env')
57
- # process.env already takes precedence
58
- ```
59
-
60
- ## Documentation Requirements
61
-
62
- ### .env.example
63
- Show required variables without values:
64
-
65
- ```
66
- API_KEY=
67
- DATABASE_URL=
68
- DEBUG=false
69
- ```
70
-
71
- ### requirements.txt (Python)
72
- Pin major versions:
73
-
74
- ```
75
- requests>=2.28.0
76
- python-dotenv>=1.0.0
77
- ```
78
-
79
- ### package.json (Node.js)
80
- Include scripts:
81
-
82
- ```json
83
- {
84
- "scripts": {
85
- "test": "jest"
86
- }
87
- }
88
- ```
89
-
90
- ## Manual Testing
91
-
92
- Before packaging, test with real use cases:
93
-
94
- ```bash
95
- # Example: PDF rotation script
96
- python scripts/rotate_pdf.py input.pdf 90 output.pdf
97
- ```
98
-
99
- Verify output matches expectations.
100
-
101
- ## Error Handling
102
-
103
- - Clear error messages
104
- - Graceful failures
105
- - No silent errors
106
- - Exit codes: 0 success, non-zero failure
1
+ # Script Quality Criteria
2
+
3
+ Scripts provide deterministic reliability and token efficiency.
4
+
5
+ ## When to Include Scripts
6
+
7
+ - Same code rewritten repeatedly
8
+ - Deterministic operations needed
9
+ - Complex transformations
10
+ - External tool integrations
11
+
12
+ ## Cross-Platform Requirements
13
+
14
+ **Prefer:** Node.js or Python
15
+ **Avoid:** Bash scripts (not well-supported on Windows)
16
+
17
+ If bash required, provide Node.js/Python alternative.
18
+
19
+ ## Testing Requirements
20
+
21
+ **Mandatory:** All scripts must have tests
22
+
23
+ ```bash
24
+ # Run tests before packaging
25
+ python -m pytest scripts/tests/
26
+ # or
27
+ npm test
28
+ ```
29
+
30
+ Tests must pass. No skipping failed tests.
31
+
32
+ ## Environment Variables
33
+
34
+ Respect hierarchy (first found wins):
35
+
36
+ 1. `process.env` (runtime)
37
+ 2. `$HOME/.claude/skills/<skill-name>/.env` (skill-specific)
38
+ 3. `$HOME/.claude/skills/.env` (shared skills)
39
+ 4. `$HOME/.claude/.env` (global)
40
+ 5. `./.claude/skills/${SKILL}/.env` (cwd)
41
+ 6. `./.claude/skills/.env` (cwd)
42
+ 7. `./.claude/.env` (cwd)
43
+
44
+ **Implementation pattern (Python):**
45
+
46
+ ```python
47
+ from dotenv import load_dotenv
48
+ import os
49
+
50
+ # Load in reverse order (last loaded wins if not set)
51
+ load_dotenv('$HOME/.claude/.env')
52
+ load_dotenv('$HOME/.claude/skills/.env')
53
+ load_dotenv('$HOME/.claude/skills/my-skill/.env')
54
+ load_dotenv('./.claude/skills/my-skill/.env')
55
+ load_dotenv('./.claude/skills/.env')
56
+ load_dotenv('./.claude/.env')
57
+ # process.env already takes precedence
58
+ ```
59
+
60
+ ## Documentation Requirements
61
+
62
+ ### .env.example
63
+ Show required variables without values:
64
+
65
+ ```
66
+ API_KEY=
67
+ DATABASE_URL=
68
+ DEBUG=false
69
+ ```
70
+
71
+ ### requirements.txt (Python)
72
+ Pin major versions:
73
+
74
+ ```
75
+ requests>=2.28.0
76
+ python-dotenv>=1.0.0
77
+ ```
78
+
79
+ ### package.json (Node.js)
80
+ Include scripts:
81
+
82
+ ```json
83
+ {
84
+ "scripts": {
85
+ "test": "jest"
86
+ }
87
+ }
88
+ ```
89
+
90
+ ## Manual Testing
91
+
92
+ Before packaging, test with real use cases:
93
+
94
+ ```bash
95
+ # Example: PDF rotation script
96
+ python scripts/rotate_pdf.py input.pdf 90 output.pdf
97
+ ```
98
+
99
+ Verify output matches expectations.
100
+
101
+ ## Error Handling
102
+
103
+ - Clear error messages
104
+ - Graceful failures
105
+ - No silent errors
106
+ - Exit codes: 0 success, non-zero failure