@jaybeeuu/agent-cortex 1.20.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 (154) hide show
  1. package/.beads/README.md +81 -0
  2. package/.beads/config.yaml +1 -0
  3. package/.beads/issues.jsonl +236 -0
  4. package/.beads/metadata.json +7 -0
  5. package/.claude-plugin/marketplace.json +16 -0
  6. package/.github/workflows/ci.test.ts +217 -0
  7. package/.github/workflows/ci.yml +35 -0
  8. package/.github/workflows/publish.yml +36 -0
  9. package/.junie/guidelines.md +87 -0
  10. package/.junie/mcp/mcp.json +10 -0
  11. package/AGENTS.md +102 -0
  12. package/CHANGELOG.md +705 -0
  13. package/README.md +209 -0
  14. package/agents/README.md +235 -0
  15. package/agents/plan.agent.md +56 -0
  16. package/agents/ralph-plan.agent.md +119 -0
  17. package/agents/ralph.agent.md +305 -0
  18. package/agents/strategy.agent.md +109 -0
  19. package/agents-native/ralph.md +193 -0
  20. package/bin/agent-cortex.mjs +27 -0
  21. package/claude/.claude-plugin/plugin.json +11 -0
  22. package/claude/.mcp.json +18 -0
  23. package/claude/agents/plan.md +56 -0
  24. package/claude/agents/ralph-plan.md +119 -0
  25. package/claude/agents/ralph.md +193 -0
  26. package/claude/agents/strategy.md +109 -0
  27. package/claude/hooks.json +23 -0
  28. package/claude/scripts/statusline-command.sh +124 -0
  29. package/docs/ideas/auto-model-selection.md +75 -0
  30. package/docs/ideas/improve-pi-system-prompt.md +34 -0
  31. package/docs/ideas/model-selector.md +40 -0
  32. package/docs/ideas/pi-task-memory.md +34 -0
  33. package/docs/ideas/qa-extension.md +43 -0
  34. package/docs/inspirations.md +33 -0
  35. package/docs/research/gas-city-research.md +256 -0
  36. package/docs/research/skill-design-research.md +286 -0
  37. package/docs/research/skill-improvements-analysis.md +117 -0
  38. package/docs/research/skill-patterns-research.md +24 -0
  39. package/docs/skills/skill-anatomy.md +149 -0
  40. package/docs/user-preferences.md +17 -0
  41. package/extensions/agent-modes/index.ts +507 -0
  42. package/extensions/auto-name.ts +107 -0
  43. package/extensions/context-loader.md +35 -0
  44. package/extensions/context-loader.ts +65 -0
  45. package/extensions/lib/tiny-model.ts +212 -0
  46. package/extensions/notify/index.ts +293 -0
  47. package/extensions/session-start.ts +44 -0
  48. package/extensions/skill-stats/README.md +74 -0
  49. package/extensions/skill-stats/context-loader.test.ts +107 -0
  50. package/extensions/skill-stats/discover.ts +119 -0
  51. package/extensions/skill-stats/format.ts +13 -0
  52. package/extensions/skill-stats/index.test.ts +452 -0
  53. package/extensions/skill-stats/index.ts +222 -0
  54. package/extensions/skill-stats/package.json +19 -0
  55. package/extensions/skill-stats/pnpm-lock.yaml +329 -0
  56. package/extensions/skill-stats/record.ts +48 -0
  57. package/extensions/skill-stats/store.ts +104 -0
  58. package/extensions/skill-stats/tsconfig.json +12 -0
  59. package/extensions/subagent/README.md +175 -0
  60. package/extensions/subagent/agents/planner.md +37 -0
  61. package/extensions/subagent/agents/reviewer.md +35 -0
  62. package/extensions/subagent/agents/scout.md +50 -0
  63. package/extensions/subagent/agents/worker.md +24 -0
  64. package/extensions/subagent/agents.ts +126 -0
  65. package/extensions/subagent/index.ts +1138 -0
  66. package/extensions/subagent/prompts/implement-and-review.md +10 -0
  67. package/extensions/subagent/prompts/implement.md +10 -0
  68. package/extensions/subagent/prompts/scout-and-plan.md +9 -0
  69. package/hooks.json +10 -0
  70. package/lib/cli.mjs +37 -0
  71. package/package.json +39 -0
  72. package/pi/keybindings.json +3 -0
  73. package/pi/settings.json +29 -0
  74. package/plugin.json +35 -0
  75. package/pnpm-workspace.yaml +7 -0
  76. package/scripts/build-claude-agents.mjs +179 -0
  77. package/scripts/install-instructions.sh +82 -0
  78. package/skills/engineering/design-an-interface/SKILL.md +94 -0
  79. package/skills/engineering/grill-with-docs/SKILL.md +88 -0
  80. package/skills/engineering/improve-codebase-architecture/REFERENCE.md +78 -0
  81. package/skills/engineering/improve-codebase-architecture/SKILL.md +81 -0
  82. package/skills/engineering/tdd/SKILL.md +150 -0
  83. package/skills/engineering/tdd/deep-modules.md +33 -0
  84. package/skills/engineering/tdd/interface-design.md +31 -0
  85. package/skills/engineering/tdd/mocking.md +59 -0
  86. package/skills/engineering/tdd/refactoring.md +10 -0
  87. package/skills/engineering/tdd/tests.md +61 -0
  88. package/skills/engineering/technical-direction/SKILL.md +86 -0
  89. package/skills/planning/classify-bead/SKILL.md +67 -0
  90. package/skills/planning/create-task/SKILL.md +96 -0
  91. package/skills/planning/create-task/pipeline.json +33 -0
  92. package/skills/planning/create-task/scripts/create-chores.ts +112 -0
  93. package/skills/planning/create-task/scripts/package.json +14 -0
  94. package/skills/planning/create-task/scripts/pnpm-lock.yaml +342 -0
  95. package/skills/planning/create-task/scripts/tsconfig.json +12 -0
  96. package/skills/planning/create-task/templates/code.md +40 -0
  97. package/skills/planning/create-task/templates/document.md +40 -0
  98. package/skills/planning/create-task/templates/fix.md +27 -0
  99. package/skills/planning/create-task/templates/review.md +36 -0
  100. package/skills/planning/create-task/templates/verify.md +43 -0
  101. package/skills/planning/prd-to-tasks/SKILL.md +227 -0
  102. package/skills/planning/record-idea/SKILL.md +62 -0
  103. package/skills/planning/record-idea/scripts/new-idea.sh +89 -0
  104. package/skills/planning/request-refactor-plan/SKILL.md +73 -0
  105. package/skills/planning/write-a-prd/SKILL.md +74 -0
  106. package/skills/planning/write-a-ticket/SKILL.md +97 -0
  107. package/skills/productivity/bd-tool/SKILL.md +90 -0
  108. package/skills/productivity/grill-me/SKILL.md +10 -0
  109. package/skills/productivity/handoff/SKILL.md +15 -0
  110. package/skills/productivity/init-beads/SKILL.md +93 -0
  111. package/skills/productivity/teach/GLOSSARY-FORMAT.md +35 -0
  112. package/skills/productivity/teach/LEARNING-RECORD-FORMAT.md +46 -0
  113. package/skills/productivity/teach/MISSION-FORMAT.md +31 -0
  114. package/skills/productivity/teach/RESOURCES-FORMAT.md +32 -0
  115. package/skills/productivity/teach/SKILL.md +109 -0
  116. package/skills/productivity/validate-agent-dir/scripts/package.json +15 -0
  117. package/skills/productivity/validate-agent-dir/scripts/pnpm-lock.yaml +329 -0
  118. package/skills/productivity/validate-agent-dir/scripts/pnpm-workspace.yaml +2 -0
  119. package/skills/productivity/validate-agent-dir/scripts/tsconfig.json +19 -0
  120. package/skills/productivity/validate-agent-dir/scripts/validate-agent-dir.test.ts +317 -0
  121. package/skills/productivity/validate-agent-dir/scripts/validate-agent-dir.ts +127 -0
  122. package/skills/productivity/write-a-skill/SKILL.md +74 -0
  123. package/skills/review/maintain-agent-docs/REFERENCE.md +246 -0
  124. package/skills/review/maintain-agent-docs/SKILL.md +83 -0
  125. package/skills/review/refactor-skill/EXAMPLES.md +20 -0
  126. package/skills/review/refactor-skill/SKILL.md +148 -0
  127. package/skills/review/review-security/SKILL.md +107 -0
  128. package/skills/review/review-security/scripts/install-gitleaks.sh +43 -0
  129. package/skills/style/style-code/REFERENCE.md +38 -0
  130. package/skills/style/style-code/SKILL.md +113 -0
  131. package/skills/style/style-comms/SKILL.md +93 -0
  132. package/skills/style/style-documentation/SKILL.md +112 -0
  133. package/skills/style/style-tests/SKILL.md +97 -0
  134. package/skills/workflow/git-workflow/SKILL.md +85 -0
  135. package/skills/workflow/hitl-collab/SKILL.md +29 -0
  136. package/skills/workflow/plan/SKILL.md +272 -0
  137. package/skills/workflow/ralph/REFERENCE.md +202 -0
  138. package/skills/workflow/ralph/SKILL.md +105 -0
  139. package/skills/workflow/run-pipeline-stage/SKILL.md +151 -0
  140. package/skills/workflow/run-pipeline-stage/playbooks/code.md +17 -0
  141. package/skills/workflow/run-pipeline-stage/playbooks/document.md +18 -0
  142. package/skills/workflow/run-pipeline-stage/playbooks/fix.md +17 -0
  143. package/skills/workflow/run-pipeline-stage/playbooks/review.md +19 -0
  144. package/skills/workflow/run-pipeline-stage/playbooks/verify.md +14 -0
  145. package/skills/workflow/run-pipeline-stage/prompts/stage-runner.md +20 -0
  146. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.test.ts +783 -0
  147. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.ts +586 -0
  148. package/skills/workflow/run-pipeline-stage/scripts/package.json +15 -0
  149. package/skills/workflow/run-pipeline-stage/scripts/pnpm-lock.yaml +342 -0
  150. package/skills/workflow/run-pipeline-stage/scripts/pnpm-workspace.yaml +2 -0
  151. package/skills/workflow/run-pipeline-stage/scripts/tsconfig.json +12 -0
  152. package/skills/workflow/using-agent-skills/SKILL.md +109 -0
  153. package/skills/workflow/using-agent-skills/scripts/validate-skill-structure.test.ts +73 -0
  154. package/test/cli.test.mjs +149 -0
@@ -0,0 +1,148 @@
1
+ ---
2
+ name: refactor-skill
3
+ description: Refactor an existing SKILL.md to the canonical anatomy template through template comparison, user interview, and one-pass rewrite. Use when refactoring, restructuring, or reviewing skills, or comparing a skill to the current template.
4
+ ---
5
+
6
+ # Refactor Skill
7
+
8
+ ## When to use
9
+
10
+ - A skill's SKILL.md predates the anatomy template and needs upgrading.
11
+ - You want to align a skill with `docs/skills/skill-anatomy.md` before the refactor wave touches it.
12
+ - You want to compare a skill's structure to the current template standard.
13
+ - Trigger phrases: "refactor this skill", "restructure this skill", "review this skill", "upgrade X to the template", "align with anatomy".
14
+
15
+ ## When NOT to use
16
+
17
+ - Creating a brand-new skill from scratch — use `write-a-skill` instead.
18
+ - Minor copy-editing or typo fixes that don't need anatomy alignment.
19
+ - Skills that are already verified against the anatomy template.
20
+
21
+ ## Workflow
22
+
23
+ ### 1. Gather materials
24
+
25
+ Read the target skill's `skills/<name>/SKILL.md` and the canonical anatomy reference:
26
+
27
+ ```bash
28
+ cat skills/<name>/SKILL.md
29
+ cat docs/skills/skill-anatomy.md
30
+ ```
31
+
32
+ If the target has no `SKILL.md` yet, abort — this skill upgrades existing files; use `write-a-skill` for new creation.
33
+
34
+ ### 2. Compare against the template
35
+
36
+ Run through each dimension of the anatomy template and record how the target currently relates to it. For each dimension, note the current state — whether it's present, missing, partial, or needs adjustment:
37
+
38
+ - **Front matter**: `name` and `description` present? Description follows the two-sentence format (capability statement + `Use when ...` with 2-4 trigger phrases)?
39
+ - **When to use**: present? Trigger phrases included?
40
+ - **When NOT to use**: present? When to include vs omit? Only include if the skill has similar neighbours where invocation precision matters.
41
+ - **Workflow**: ordered deterministic steps with observable outcomes?
42
+ - **Red Flags**: present? Only include for discipline-enforcement skills (security, TDD, review).
43
+ - **Common Rationalizations**: present? Only include for process-critical skills where shortcut pressure is common.
44
+ - **Phase-gate checklists**: present? Only include for multi-phase workflows (3+ distinct phases).
45
+ - **Cross-skill references**: present? Only include when another skill owns a sub-domain better than restating.
46
+ - **Examples**: present? Only include for non-trivial output contracts.
47
+ - **Verification checklist**: present? Concrete, machine-checkable items?
48
+ - **Voice/tone**: imperative second-person? Positive framing? Rationale sentences for non-obvious rules?
49
+ - **Line length**: near ~150 lines? Under 150 hard cap?
50
+
51
+ The framing is **comparison, not gap detection** — a dimension may already be fully aligned. Build a structured assessment grouped by required vs optional. See `EXAMPLES.md` for the output shape.
52
+
53
+ #### Phase gate: comparison complete
54
+
55
+ - [ ] Required dimensions checked (front matter, When to use, Workflow, Verification checklist)
56
+ - [ ] Optional dimensions noted as relevant or not for this skill
57
+ - [ ] You can articulate what will change and what will stay the same
58
+
59
+ ### 3. Present findings and propose changes
60
+
61
+ Share the full comparison assessment with the user. Do not start editing yet — this step is about understanding and agreement.
62
+
63
+ Present the comparison and discuss optional sections using the inclusion criteria below. For opted-in sections, capture content requirements; for opted-out, record the decision. Do not ask about required sections (When to use, Workflow, Verification checklist).
64
+
65
+ | Section | Ask if |
66
+ |---|---|
67
+ | `When NOT to use` | The skill has similar neighbours where invocation precision matters |
68
+ | `Red Flags` | The skill enforces process discipline (security, TDD, review) |
69
+ | `Common Rationalizations` | The skill is process-critical where shortcut pressure is common |
70
+ | `Phase-gate checklists` | The workflow has 3+ distinct phases |
71
+ | `Cross-skill references` | Another skill owns a sub-domain the workflow delegates to |
72
+ | `Examples` | The output contract is non-trivial (formats, schemas, templates) |
73
+ | `Philosophy / rationale` | The skill defends an opinionated method with trade-offs |
74
+
75
+ Then **propose the plan**: summarise what will change, what will stay the same, and the proposed new description. Ask for explicit approval before any file is written — iterate on the proposal if needed.
76
+
77
+ #### Phase gate: plan approved
78
+
79
+ - [ ] Comparison and optional-section discussion presented
80
+ - [ ] Proposed changes + new description shown to user
81
+ - [ ] User explicitly approved the plan
82
+
83
+ ### 4. Produce the rewrite
84
+
85
+ Write the complete new `skills/<name>/SKILL.md` in one pass covering:
86
+
87
+ - Correct front matter
88
+ - All required sections in canonical order
89
+ - Each opted-in optional section with its what/when/example guidance inline
90
+ - Voice and tone per `style-code` (imperative second-person, positive framing, rationale sentences)
91
+ - Description matching the two-sentence format with 2-4 trigger phrases
92
+
93
+ Write the file directly:
94
+
95
+ ```bash
96
+ cat > skills/<name>/SKILL.md << 'EOF'
97
+ <new content>
98
+ EOF
99
+ ```
100
+
101
+ ### 5. Validate against template constraints
102
+
103
+ After writing, verify:
104
+
105
+ - [ ] Front matter has `name` and `description`
106
+ - [ ] Description is ≤ 1024 chars, two sentences, second starts with "Use when"
107
+ - [ ] Required sections present: `## When to use`, `## Workflow`, `## Verification checklist`
108
+ - [ ] All opted-in optional sections present in canonical order
109
+ - [ ] `SKILL.md` ≤ 150 lines (`wc -l skills/<name>/SKILL.md`)
110
+ - [ ] Body uses imperative second-person, positive framing
111
+ - [ ] No ALL-CAPS emphasis
112
+ - [ ] Rationale sentences present for non-obvious rules
113
+
114
+ Report any validation failures and fix them. If all pass, summarise what was changed.
115
+
116
+ ## Examples
117
+
118
+ See `EXAMPLES.md` for a worked comparison table showing the template-comparison output shape for a typical skill refactor.
119
+
120
+ ## Red Flags
121
+
122
+ - **"I already know this skill"** — Reading the file fresh reveals assumptions that familiarity hides. A skill you use daily may still have front-matter omissions or tone drift. Always read it.
123
+ - **Deciding optional sections without asking** — Optional sections depend on the skill's neighbours and purpose, which the user understands better than an agent. Making the call unilaterally produces a weaker result.
124
+ - **Keeping old phrasing because "it was already fine"** — Voice and tone rules (imperative second-person, positive framing, rationale sentences) are hard to apply incrementally. Old phrasing that reads fine in isolation may break template consistency.
125
+ - **Cargo-culting section headings** — Copying section headings from the template without adapting content to the skill's actual purpose creates generic, low-value sections. Each section must earn its place with specific, skill-relevant content.
126
+ - **Refactoring for its own sake** — If the comparison shows the skill is already well-aligned, don't change it. Adding churn for its own sake degrades clarity and wastes time. Report that no changes are needed and stop.
127
+
128
+ ## Common Rationalizations
129
+
130
+ | Rationalization | Rebuttal |
131
+ |---|---|
132
+ | "This skill is already close enough — I'll just tweak a few lines" | Partial alignment creates drift. The template enforces section ordering, tone, and description rules that are hard to apply incrementally. Do the full pass. |
133
+ | "The comparison takes too long — I can spot the issues from reading" | The comparison checklist ensures nothing is missed. Skipping it trades thoroughness for speed and usually misses something. |
134
+ | "I know what optional sections they'll want" | You might be right, but the user still needs to confirm. Presenting a recommendation with your reasoning is fine — deciding without asking isn't. |
135
+
136
+ ## Verification checklist
137
+
138
+ - [ ] Target skill's `SKILL.md` exists and was read
139
+ - [ ] Template comparison completed before any rewrite
140
+ - [ ] Phase gates passed: comparison complete, plan approved
141
+ - [ ] User interviewed on every optional section and approved the plan
142
+ - [ ] Rewrite includes all required sections in canonical order
143
+ - [ ] Rewrite includes opted-in optional sections with guidance
144
+ - [ ] Description follows two-sentence format with trigger phrases
145
+ - [ ] `SKILL.md` ≤ 150 lines
146
+ - [ ] Voice/tone matches `style-code` / `style-documentation` standards
147
+ - [ ] No red flags triggered during execution
148
+ - [ ] Validation completed and all checks pass
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: review-security
3
+ description: Scans git changes for leaked secrets, credentials, and tokens using gitleaks. Use when you need to "check for secrets", "scan for credentials", or "review security" before committing.
4
+ ---
5
+
6
+ # Review Security
7
+
8
+ ## When to use
9
+
10
+ - Before any commit — scan staged changes for secrets.
11
+ - During code review — scan the most recent commit.
12
+ - Asked to "check for secrets", "scan for credentials", or "review security".
13
+
14
+ ## When NOT to use
15
+
16
+ - Auditing dependency vulnerabilities or supply-chain security — gitleaks scans your code, not your dependencies.
17
+ - Reviewing authentication or authorisation logic — use a manual code review instead.
18
+ - Scanning an entire repository history for the first time — run `gitleaks detect --full` separately; this skill is for incremental scans.
19
+
20
+ ## Philosophy / rationale
21
+
22
+ - **Automated scanning catches what manual review misses.** A secret committed to git is there forever — even if you remove it later, it lives in history.
23
+ - **Staged scans are the cheapest catch point.** Scanning before commit costs seconds. Cleaning up after a push costs hours and involves the whole team.
24
+ - **Gitleaks runs locally without sending code to a third party.** Your code never leaves your machine.
25
+
26
+ ## Workflow
27
+
28
+ ### 1. Verify gitleaks is installed
29
+
30
+ ```bash
31
+ gitleaks version
32
+ ```
33
+
34
+ If the command fails, gitleaks is not installed. Inform the user and offer to install it:
35
+
36
+ ```bash
37
+ bash "$(find ~ -path '*/agent-cortex/skills/review-security/scripts/install-gitleaks.sh' 2>/dev/null | head -1)"
38
+ ```
39
+
40
+ ### 2. Determine the scan scope
41
+
42
+ | Situation | Command |
43
+ |---|---|
44
+ | Staged changes (before committing) | `gitleaks protect --staged -v` |
45
+ | Most recent commit (after committing, e.g. during review) | `gitleaks detect --log-opts "HEAD~1..HEAD" -v` |
46
+ | Specific ref range | `gitleaks detect --log-opts "<from>..<to>" -v` |
47
+
48
+ ### 3. Run the scan and interpret the verdict
49
+
50
+ - Exit `0` — **PASS**. No secrets found. Proceed.
51
+ - Exit `1` — **FAIL**. Findings are printed with file, line, and rule name.
52
+
53
+ ### 4. Handle failures
54
+
55
+ If the verdict is FAIL, report each finding as a required change. Do not proceed until secrets are removed.
56
+
57
+ When running within a ralph review pipeline, the outcome is communicated through the `---REPORT---` block that ralph parses — set `REVIEW_OUTCOME: CHANGES_REQUESTED` in that block and list each finding under `CHANGES_REQUESTED` (see the review template at `skills/create-task/templates/review.md`).
58
+
59
+ ## Red Flags
60
+
61
+ - **Skipping the scan because "it is just documentation".** Secrets leak in docs, config examples, and READMEs just as easily as in code.
62
+ - **Dismissing a finding without verifying.** Always check the context before marking a finding as a false positive.
63
+ - **Scanning after pushing instead of before.** Once pushed, the secret is on the remote. Even a force push may not fully remove it from history.
64
+
65
+ ## Common Rationalizations
66
+
67
+ | Rationalization | Rebuttal |
68
+ |---|---|
69
+ | "I will check for secrets manually" | Manual review has blind spots. Gitleaks catches patterns you will scroll past. |
70
+ | "This is just a config file" | Config files are where secrets most commonly live. |
71
+ | "I will scan before pushing, not before committing" | The earlier you catch it, the cheaper it is. Pre-commit scan costs two seconds. |
72
+ | "This is a false positive" | It might be. Verify the context before dismissing it. |
73
+
74
+ ## Cross-skill references
75
+
76
+ | When you need… | Use this skill |
77
+ |---|---|
78
+ | Code conventions that help avoid embedding secrets | `style-code` |
79
+ | Documentation conventions that keep examples secret-free | `style-documentation` |
80
+
81
+ ## Examples
82
+
83
+ ### Reading a FAIL finding
84
+
85
+ ```
86
+ Finding: detected AWS Access Key ID
87
+ Rule: aws-access-key-id
88
+ File: deploy/config.ts
89
+ Line: 42
90
+ Secret: AKIA************
91
+ ```
92
+
93
+ Each finding includes the rule that caught it, the file and line, and the matched secret. Investigate to confirm or dismiss.
94
+
95
+ ### Staged scan catches before it is too late
96
+
97
+ | Instead of… | Write… |
98
+ |---|---|
99
+ | Committing `config.ts` with a hardcoded API key, pushing, then realising | Running `gitleaks protect --staged` before commit, catching the key in the staged diff |
100
+
101
+ ## Verification checklist
102
+
103
+ - [ ] Gitleaks is installed and available
104
+ - [ ] Appropriate scan scope selected (staged, commit, or ref range)
105
+ - [ ] Scan run and verdict recorded
106
+ - [ ] Every FAIL finding investigated and resolved
107
+ - [ ] No commit pushed with unresolved secrets
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env bash
2
+ # Installs gitleaks using the appropriate method for the current platform.
3
+ set -euo pipefail
4
+
5
+ if command -v gitleaks &>/dev/null; then
6
+ echo "gitleaks is already installed: $(gitleaks version)"
7
+ exit 0
8
+ fi
9
+
10
+ OS="$(uname -s)"
11
+
12
+ if [ "$OS" = "Darwin" ]; then
13
+ if command -v brew &>/dev/null; then
14
+ echo "Installing gitleaks via Homebrew..."
15
+ brew install gitleaks
16
+ else
17
+ echo "Homebrew not found. Install it from https://brew.sh, then run: brew install gitleaks"
18
+ exit 1
19
+ fi
20
+ elif [ "$OS" = "Linux" ]; then
21
+ echo "Downloading latest gitleaks release from GitHub..."
22
+ LATEST=$(curl -s https://api.github.com/repos/gitleaks/gitleaks/releases/latest \
23
+ | grep '"tag_name"' | cut -d'"' -f4)
24
+ ARCH="$(uname -m)"
25
+ case "$ARCH" in
26
+ x86_64) ARCH="x64" ;;
27
+ aarch64|arm64) ARCH="arm64" ;;
28
+ *) echo "Unsupported architecture: $ARCH"; exit 1 ;;
29
+ esac
30
+ INSTALL_DIR="${HOME}/.local/bin"
31
+ mkdir -p "$INSTALL_DIR"
32
+ URL="https://github.com/gitleaks/gitleaks/releases/download/${LATEST}/gitleaks_${LATEST#v}_linux_${ARCH}.tar.gz"
33
+ curl -sL "$URL" | tar -xz -C "$INSTALL_DIR" gitleaks
34
+ chmod +x "$INSTALL_DIR/gitleaks"
35
+ if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
36
+ echo "Note: add $INSTALL_DIR to your PATH if gitleaks is not found after install."
37
+ fi
38
+ else
39
+ echo "Unsupported OS: $OS. See https://github.com/gitleaks/gitleaks#installing for manual install instructions."
40
+ exit 1
41
+ fi
42
+
43
+ echo "Installed: $(gitleaks version)"
@@ -0,0 +1,38 @@
1
+ # Additional Examples
2
+
3
+ Extended before/after pairs for less common style-code patterns.
4
+
5
+ ## Validation and error handling
6
+
7
+ | Instead of… | Write… |
8
+ |---|---|
9
+ | ```ts function process(input: any) { // assume it's correct } ``` | ```ts function process(input: unknown): ProcessResult { const data = parseInput(input); // validated at system edge } ``` |
10
+ | ```ts throw "invalid"; ``` | ```ts throw new ValidationError({ field: "email", reason: "missing @" }); ``` |
11
+
12
+ ## Module structure
13
+
14
+ | Instead of… | Write… |
15
+ |---|---|
16
+ | `actions/`, `reducers/`, `selectors/`, `thunks/` — grouped by technical type | `accounts/`, `payments/`, `notifications/` — each with its own types, actions, reducers, selectors, thunks |
17
+ | `utils/` with fifty unrelated helpers | Feature-specific modules (`accounts/resolve-overdue.ts`, `accounts/export-csv.ts`) |
18
+ | `shared/types.ts` with every type | Types co-located in the owning package, exported from `index.ts` |
19
+
20
+ ## State management
21
+
22
+ | Instead of… | Write… |
23
+ |---|---|
24
+ | ```ts let count = 0; function inc() { count++; } ``` (shared mutable state) | ```ts const [count, setCount] = useState(0); // explicit, local, testable ``` |
25
+ | Async state stored as separate booleans | ```ts type AsyncState<T> = { status: "idle" \| "loading" \| "success"; data?: T; error?: Error }; ``` |
26
+
27
+ ## Component structure
28
+
29
+ | Instead of… | Write… |
30
+ |---|---|
31
+ | ```ts function Page() { const [data, setData] = useState(null); useEffect(...); return <div>...</div>; } ``` (data loading + rendering) | Split into `usePageData()` hook and `Page` component with explicit props |
32
+
33
+ ## Public API conventions
34
+
35
+ | Instead of… | Write… |
36
+ |---|---|
37
+ | Default export from module | Named exports from `index.ts` for the intended public API |
38
+ | ```ts export function x(a, b, c) { ... } ``` with undocumented params | ```ts export function createReport(options: ReportOptions): Report { ... } ``` with documented `ReportOptions` interface |
@@ -0,0 +1,113 @@
1
+ ---
2
+ name: style-code
3
+ description: Defines this project's coding style, conventions, and architectural preferences (naming, module boundaries, structure). Use BEFORE writing or editing any code and during any refactor or code review — consult it whenever you add or change functions, modules, types, or files rather than choosing style ad hoc. Also for a "style review", "naming conventions", or "module boundaries".
4
+ ---
5
+
6
+ # Code Style
7
+
8
+ ## When to use
9
+
10
+ - Writing new code, editing existing code, or reviewing a pull request.
11
+ - Deciding between type approaches, naming strategies, or module boundaries.
12
+ - Asked for a "style review", "does this look right", or "what's the convention here".
13
+
14
+ ## When NOT to use
15
+
16
+ - Writing tests or deciding test strategy — use `style-tests` or `tdd` instead.
17
+ - Communication tone, document structure, or external writing — use `style-comms`.
18
+ - Deciding what and whether to document — use `style-documentation`.
19
+
20
+ ## Philosophy / rationale
21
+
22
+ - **Small, focused changes beat broad refactors.** Every change should answer one question. Scope creep is the most common source of defects in an otherwise clean change.
23
+ - **Clarity over cleverness.** Code is read many more times than it is written. Clever code optimises for the writing moment; clear code optimises for every subsequent reading.
24
+ - **Validate at system edges, trust the type system within.** Inbound data from API ingress, deserialisation, or inter-service communication is untrusted until validated. Within application boundaries, trust the type system to enforce correct calls — don't re-validate at every internal module boundary.
25
+ - **Prefer result objects for domain errors; reserve exceptions for emergencies.** Expected failures — validation errors, not-found, conflict — belong in a typed result the caller can handle. Thrown `Error` should signal something genuinely broken: a programming mistake, an invariant violation, or unrecoverable state.
26
+ - **Deep modules beat shallow ones.** A tight public API with complexity hidden behind it is easier to use, test, and change than a flat sprawl of interdependent helpers.
27
+ - **Abstraction must earn its keep, but local helpers are free.** An abstraction extracted into a shared module before its shape is proven nearly always guesses wrong. But extracting a local helper to clarify domain logic is always worthwhile — even at first use. The goal is readable code, not zero duplication.
28
+
29
+ ## Workflow
30
+
31
+ 1. **Orient.** Run the `tdd` skill for the red-green-refactor loop. Style rules guide the shape of the code you produce inside that loop.
32
+
33
+ 2. **Define types and boundaries first.** Model domain concepts with named types, interfaces, discriminated unions, or typed result objects. Keep types close to the service or package that owns them. Validate unknown data at system edges (API ingress, deserialisation, inter-service boundaries) using runtime validators — treat incoming data as `unknown` until checked. Within the application, trust the type system to enforce correct calls.
34
+
35
+ 3. **Name for clarity.** Use descriptive names drawn from the project's ubiquitous language. Do not invent synonyms for established domain terms. If the language isn't yet defined for this area, run `grill-with-docs` to extract it before naming. Use consistent suffixes: `Props`, `Options`, `Context`, `State` where they aid recognition. Name factories and builders with explicit verbs (`create`, `make`, `build`, `resolve`, `parse`, `compile`, `fetch`, `read`, `write`).
36
+
37
+ 4. **Structure with ownership in mind.** Keep ingress, processing, API, CLI, and infrastructure concerns in separate modules. Split modules when it sharpens bounded-context ownership; do not split just to reshuffle code.
38
+
39
+ **Co-locate by domain, not by technical type.** All the files for a given feature or bounded context — types, actions, reducers, selectors, thunks, components, tests — live alongside each other. Do not group files by what they *are* ("all selectors here, all thunks there"). Group them by what they *belong to* ("everything for the accounts domain here"). This keeps domain boundaries visible in the filesystem and makes it safe to rename, extract, or delete a feature without hunting across a dozen type-based directories.
40
+
41
+ 5. **Apply UI and state patterns.** Prefer small functional components with explicit props interfaces. Use CSS Modules when the stack supports them. Keep state transitions visible and predictable — encapsulate state behind hooks, selectors, or dedicated state modules. Keep derived state clearly separated from primitive state.
42
+
43
+ 6. **Review against the checklist below.** Read the diff once as its reviewer before committing.
44
+
45
+ ## Red Flags
46
+
47
+ - **Reaching for `any` or non-null assertions.** Every `any` is a blind spot in the type system. If unavoidable, keep it narrow and function-scoped.
48
+ - **Broadening scope.** A change that fixes a bug and also renames three modules and extracts an abstraction is three changes. Split it.
49
+ - **Skipping edge validation.** Inbound data at API ingress, deserialisation, or inter-service boundaries is untrusted until validated. Within the application, trust the type system. A missed edge validation silently poisons downstream callers.
50
+ - **Unstructured errors.** A thrown string or `{ message }` object leaves the caller guessing what failed and why. Prefer typed result objects for expected domain failures — use thrown `Error` only when something has genuinely gone wrong (programming error, invariant violation, unrecoverable state).
51
+ - **Large modules with mixed concerns.** A file doing data loading, state orchestration, and rendering is three modules waiting to be extracted.
52
+ - **Premature cross-module abstraction.** Extracting a shared utility into a common module before the pattern has proven itself across multiple callers nearly always guesses the wrong shape. Local helpers that clarify intent are fine at first use — keep them within the module boundary until the pattern repeats.
53
+
54
+ ## Common Rationalizations
55
+
56
+ | Rationalization | Rebuttal |
57
+ |---|---|
58
+ | "I'll just use `any` here — it's a small edge case" | Every `any` is a type system blind spot. If unavoidable, keep it narrow, local, and documented. |
59
+ | "I'll clean this up in a follow-up" | Follow-ups rarely happen. Keep the change proportionate but correct. |
60
+ | "This is too small for edge validation" | The smallest unvalidated input at a system edge causes the most confusing downstream failures. Validate incoming data once at the boundary and let the type system carry it from there. |
61
+ | "I'll add types later" | Types are cheapest at write time. Adding them later is a refactor you will skip. |
62
+ | "The existing code already does it this way" | Existing patterns may predate this guide. Follow the guide unless changing it would inflate scope beyond the task. |
63
+ | "I'll throw an Error for this validation failure" | Expected domain failures should be typed results the caller can handle. Reserve thrown `Error` for things that are truly broken. |
64
+ | "I'll extract this into a shared util — it might be useful later" | Extract locally first if it clarifies the code. Promote to shared only when at least a third real caller emerges. Guessing the shape before then wastes time and creates coupling. |
65
+
66
+ ## Cross-skill references
67
+
68
+ | When you need… | Use this skill |
69
+ |---|---|
70
+ | Test-first development loop | `tdd` |
71
+ | Test writing conventions | `style-tests` |
72
+ | Building or hardening the project's ubiquitous language | `grill-with-docs` |
73
+ | Communication tone and document structure | `style-comms` |
74
+ | What and whether to document | `style-documentation` |
75
+ | Surfacing architectural friction and deepening shallow modules | `improve-codebase-architecture` |
76
+ | Secrets and credential scanning | `review-security` |
77
+
78
+ ## Examples
79
+
80
+ See `REFERENCE.md` for the full set. The most common patterns:
81
+
82
+ ### Types at boundaries
83
+
84
+ | Instead of… | Write… |
85
+ |---|---|
86
+ | `function handleRequest(raw: any) { ... }` with no validation | `function handleRequest(raw: unknown): HandlerResult { ... }` validated at the ingress boundary |
87
+ | `const user = JSON.parse(raw)` with unchecked cast | `const user = parseUser(JSON.parse(raw))` validated with `parseUser` at the deserialisation edge |
88
+
89
+ ### Naming
90
+
91
+ | Instead of… | Write… |
92
+ |---|---|
93
+ | `function process(items) { ... }` | `function resolveOverdueAccounts(accounts: Account[]) { ... }` |
94
+ | `interface Config { ... }` | `interface ExportOptions { ... }` |
95
+
96
+ ### Scoping
97
+
98
+ | Instead of… | Write… |
99
+ |---|---|
100
+ | One commit fixing a bug, renaming a module, and adding an abstraction | One commit per concern, each reviewable on its own |
101
+
102
+ ## Verification checklist
103
+
104
+ - [ ] Change is focused on one concern — no scope creep
105
+ - [ ] External inputs validated at system edges (API, deserialisation, inter-service)
106
+ - [ ] Exported APIs and return types are explicit (no inferred `any`)
107
+ - [ ] Names are descriptive and drawn from the project's ubiquitous language
108
+ - [ ] No `any`, broad casts, or non-null assertions without narrow scoping
109
+ - [ ] Types are co-located with the module that owns them
110
+ - [ ] Modules are split by ownership, not just for reshuffling code
111
+ - [ ] State transitions are explicit and encapsulated behind a clear API
112
+ - [ ] Tests and docs updated where behaviour changed
113
+ - [ ] Staged changes scanned with `review-security` before committing
@@ -0,0 +1,93 @@
1
+ ---
2
+ name: style-comms
3
+ description: Sets tone, structure, and concision rules for written communication. Use BEFORE composing project or external-facing text — commit messages, PR descriptions, tickets, RFCs, PRDs, proposals, reports, or status updates — and when asked to "make this clearer" or for a "style review".
4
+ ---
5
+
6
+ # Communication Style
7
+
8
+ ## When to use
9
+
10
+ - Writing a ticket, RFC, PRD, proposal, report, or any document someone else will read.
11
+ - Reviewing a draft for tone, structure, or concision.
12
+ - Asked for a "style review", "make this clearer", or "is this well written?".
13
+
14
+ ## When NOT to use
15
+
16
+ - Deciding *whether and what* to document — use `style-documentation` instead.
17
+ - Writing code or test code — use `style-code` or `style-tests` instead.
18
+
19
+ ## Philosophy / rationale
20
+
21
+ - **Reader time is more valuable than writer time.** Every sentence you write costs the reader time to process. Make each one count.
22
+ - **Lead with the payoff because the reader's first question is always "why am I reading this?".** Put the key takeaway — whether it's a decision, a conclusion, a recommendation, or a summary — up front so they orient before diving into detail.
23
+ - **Triangular structure (broad → narrow) lets readers self-select depth.** A reader who only needs context stops early; one who needs specifics reads on. Both get what they need without friction.
24
+ - **Explicit language ages better than hedged language.** Hedging ("might", "potentially", "it could be") lets each reader fill in their own interpretation — which will differ from yours.
25
+
26
+ ## Workflow
27
+
28
+ 1. **Identify the audience and the ask.** Who is reading this, and what do they need to decide or know by the end? Write the ask down first.
29
+
30
+ 2. **Lead with the payoff.** Open with the key takeaway — the decision needed, the conclusion reached, the recommendation, or a summary of findings.
31
+ - Informal documents: one or two sentence TL;DR.
32
+ - Formal documents: a summary of no more than two paragraphs covering purpose, key points, and conclusions.
33
+
34
+ 3. **Structure with the triangular approach.** Start broad, then narrow progressively — from context to problem to proposed approach to specific detail. Put the most granular information last.
35
+
36
+ 4. **Write with concision.** Every sentence must earn its place.
37
+ - Prefer plain language over formal or corporate phrasing.
38
+ - State things directly. Avoid hedging ("might", "potentially", "it could be said"), filler ("It is worth noting that…", "As mentioned above…"), and throat-clearing.
39
+ - Do not restate what was just said in different words.
40
+ - Do not open with a preamble that restates the document title or obvious context.
41
+
42
+ 5. **Use lists, links, and examples intentionally.**
43
+ - **Lists:** Use for genuinely enumerable, parallel items. Do not break a single flowing thought into bullets.
44
+ - **Links:** Link to the specific location (code line, document section), not a top-level root. Do not link things the reader can trivially find. Add a **References** section at the end only when multiple links need collating — inline a single link instead.
45
+ - **Examples:** Use to illustrate complex ideas — code blocks under 15 lines, calculations with workings, concrete scenarios. Remove if the surrounding prose is already clear. Show only what makes the point.
46
+
47
+ 6. **Review against the checklist below.** Read the draft once as its intended audience before sending or committing.
48
+
49
+ ## Examples
50
+
51
+ ### Lead with the payoff
52
+
53
+ | Instead of… | Write… |
54
+ |---|---|
55
+ | "I've been looking at the current auth system and thinking about ways we could improve it. There are a few options to consider…" | "We need to decide between OAuth2 and SAML for the new API gateway. Here's the tradeoff." |
56
+
57
+ ### Conciseness
58
+
59
+ | Instead of… | Write… |
60
+ |---|---|
61
+ | "It is worth noting that the database migration is something we should take into consideration at this point in time." | "The database migration is our next bottleneck." |
62
+
63
+ ### Intentional lists
64
+
65
+ | Instead of… | Write… |
66
+ |---|---|
67
+ | "The system needs to be scalable. It also needs to be secure. And it also needs to be maintainable." | "Requirements: scalable, secure, maintainable." |
68
+
69
+ ### Direct over hedged
70
+
71
+ | Instead of… | Write… |
72
+ |---|---|
73
+ | "This might potentially cause some issues that we could look at." | "This approach causes two problems: increased latency and a single point of failure." |
74
+
75
+ ## Cross-skill references
76
+
77
+ | When you need… | Use this skill |
78
+ |---|---|
79
+ | A document template with section structure | `write-a-ticket`, `write-a-prd`, `write-a-skill` |
80
+ | Guidance on what and whether to document | `style-documentation` |
81
+ | Coding style and conventions | `style-code` |
82
+ | Test writing style | `style-tests` |
83
+
84
+ ## Verification checklist
85
+
86
+ - [ ] Document opens with the key takeaway (decision, conclusion, recommendation, or summary)
87
+ - [ ] Triangular structure: broad context → narrow detail
88
+ - [ ] No hedging, filler, preamble, or restated document title
89
+ - [ ] Every sentence earns its place — nothing can be cut without loss
90
+ - [ ] Lists are parallel and genuinely enumerable
91
+ - [ ] Links point to specific locations, not top-level roots
92
+ - [ ] Examples are under 15 lines and show only what's needed
93
+ - [ ] References section used only for multiple links; single links are inlined