cclaw-cli 0.5.17 → 0.7.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Utility skills that complement the 9 flow stages.
2
+ * Utility skills that complement the 8 flow stages.
3
3
  * These are contextual lenses, not flow stages.
4
4
  * Each skill: ~120-180 lines, under the 500-line progressive disclosure guideline.
5
5
  */
@@ -504,12 +504,45 @@ Do not start implementation execution without an approved plan artifact and expl
504
504
  - Machine-only checks are delegated to subagents when supported.
505
505
  - User approvals are requested only at required gate boundaries.
506
506
 
507
+ ## Fresh Context Protocol (between waves)
508
+
509
+ After a wave completes — especially after long agent turns — context drift is
510
+ the #1 cause of degraded execution quality. Before starting the **next wave**,
511
+ prefer a **fresh agent context** over continuing in a saturated session:
512
+
513
+ 1. **Snapshot wave outcome** — append a short summary to the plan artifact
514
+ (\`### Wave <N> outcome\` with: tasks done, evidence files, blockers, next-wave inputs).
515
+ 2. **Capture handoff facts** — the minimum information the next agent needs:
516
+ - Stage and run id (from \`.cclaw/state/flow-state.json\`)
517
+ - List of completed task IDs from the plan
518
+ - Open blockers / failing gates by name
519
+ - File paths the next wave will touch (no full diffs)
520
+ 3. **Decide: continue or rotate**
521
+ - **Rotate** (start a new agent session) when: prior wave consumed > ~50% of the context budget, the prior wave required deep investigation that the next wave does not need, or you are about to cross a stage boundary.
522
+ - **Continue** when: next wave is a tiny follow-up (≤ 1 task) and the prior context is directly relevant.
523
+ 4. **Resume** in the new session via \`/cc-next\` — the session-start hook will restore flow state, checkpoint, and digest automatically.
524
+
525
+ This is the same intuition as Compound Engineering's "fresh context per iteration": every wave starts with a clean, intentionally-loaded context, not a degraded carry-over.
526
+
527
+ ### Handoff template (paste into next session)
528
+
529
+ \`\`\`markdown
530
+ ## Wave <N> handoff
531
+ - Stage: <stage>
532
+ - Run: <runId>
533
+ - Completed task IDs: <list>
534
+ - Blockers: <list or none>
535
+ - Files next wave will touch: <list>
536
+ - Verification command(s) used: <list>
537
+ \`\`\`
538
+
507
539
  ## Anti-Patterns
508
540
 
509
541
  - Executing all tasks in one pass without intermediate verification.
510
542
  - Marking tasks done without command evidence.
511
543
  - Reordering critical dependencies for speed.
512
544
  - Continuing after a gate failure hoping later tasks fix it.
545
+ - Carrying a saturated context across wave boundaries because "it has all the history" — saturated context is a liability, not an asset.
513
546
  `;
514
547
  }
515
548
  export function contextEngineeringSkill() {
@@ -649,6 +682,681 @@ Do not approve user-facing UI changes that break basic keyboard navigation or re
649
682
  - Color-only status indicators with no text/aria support.
650
683
  `;
651
684
  }
685
+ export function landscapeCheckSkill() {
686
+ return `---
687
+ name: landscape-check
688
+ description: "Landscape survey before a design/scope decision. Use when deciding whether to build, reuse, or adopt — inside and outside the repo."
689
+ ---
690
+
691
+ # Landscape Check
692
+
693
+ ## Quick Start
694
+
695
+ > 1. Before committing to a build decision, survey the landscape: in-repo, in-ecosystem, and in-class.
696
+ > 2. Produce a one-page table of candidates (build / reuse in-repo / adopt external) with evidence.
697
+ > 3. Explicitly kill alternatives with a one-line reason. Do not leave implicit assumptions.
698
+
699
+ ## HARD-GATE
700
+
701
+ Do not approve a scope or design that introduces a new system, library,
702
+ or abstraction without comparing at least **one in-repo candidate** and
703
+ **one external/ecosystem candidate** (or explicitly stating why no such
704
+ candidates exist).
705
+
706
+ ## When to Use
707
+
708
+ - Scope stage, before picking a mode (expand/selective/hold/reduce)
709
+ - Design stage, before committing to a new architecture boundary
710
+ - Brainstorm stage, when the user frames the problem as "let's build X"
711
+ - Review stage, when a proposed change duplicates an existing capability
712
+
713
+ ## Protocol
714
+
715
+ 1. **Define the capability in one sentence.** "We need a way to <verb> <object> under <constraint>."
716
+ 2. **In-repo search.** Grep for similar verbs/modules/components. Read the closest 1-3 candidates. Record their fit and why they are or are not a good adapter target.
717
+ 3. **Ecosystem search.** Check ecosystem defaults (stdlib, framework primitives, common OSS packages in use). Do not invent new dependencies when an existing one covers 80%+ of the need.
718
+ 4. **In-class search.** Look at how other well-known projects in the same class solve this. Cite at least one concrete example (even if you end up rejecting it).
719
+ 5. **Produce the decision table.** Columns: Candidate, Kind (build / reuse / adopt), Fit (1-5), Effort (S/M/L/XL), Risk, Reason accepted or rejected.
720
+ 6. **Commit.** Pick exactly one winner. All losers must have a one-line kill reason.
721
+
722
+ ## Output Template
723
+
724
+ \`\`\`markdown
725
+ ### Landscape Check — <capability>
726
+
727
+ | Candidate | Kind | Fit | Effort | Risk | Verdict |
728
+ |---|---|---|---|---|---|
729
+ | src/foo/Bar | reuse | 4/5 | S | Low | SELECTED — already covers 80% of the need |
730
+ | external/lib-x | adopt | 3/5 | M | Med | REJECTED — heavy dep, 20% unused surface |
731
+ | build new | build | 2/5 | L | High | REJECTED — premature abstraction |
732
+
733
+ **Decision:** Reuse \`src/foo/Bar\` with a thin adapter. Kill reasons recorded above.
734
+ \`\`\`
735
+
736
+ ## Anti-Patterns
737
+
738
+ - "We looked and nothing fits" without citing what was looked at.
739
+ - Treating "nobody on the team knows library X" as a kill reason without evaluating the learning cost.
740
+ - Choosing "build" because reuse would require a small refactor of the existing component.
741
+ - Skipping the in-class search because "our case is special" — it usually is not.
742
+
743
+ ## Red Flags
744
+
745
+ - Decision table has only the winner listed.
746
+ - Ecosystem search is empty when a well-known primitive obviously applies.
747
+ - "Fit" scores without evidence (no file:line, no cited OSS repo, no framework docs reference).
748
+ - The in-repo candidate was never read before being dismissed.
749
+ `;
750
+ }
751
+ export function knowledgeCurationSkill() {
752
+ return `---
753
+ name: knowledge-curation
754
+ description: "Read-only curation pass over .cclaw/knowledge.md and .cclaw/knowledge.jsonl. Surfaces stale, duplicate, or low-confidence entries and proposes a soft-archive plan; never deletes without explicit user approval."
755
+ ---
756
+
757
+ # Knowledge Curation
758
+
759
+ ## Quick Start
760
+
761
+ > 1. This is a **read-only audit** of \`.cclaw/knowledge.md\` and, when present, \`.cclaw/knowledge.jsonl\`. Never delete or rewrite entries here.
762
+ > 2. Surface candidates for soft-archive when the active file > 50 entries OR contains stale/duplicate/superseded entries.
763
+ > 3. Propose a single archive plan and require explicit user approval before any move.
764
+
765
+ ## HARD-GATE
766
+
767
+ - Do not modify \`.cclaw/knowledge.md\` or \`.cclaw/knowledge.jsonl\` from this skill except via an explicit user-approved archive plan that **moves** markdown entries to \`.cclaw/knowledge.archive.md\` and appends soft-archive lines (same title, \`archived: true\`) to the JSONL. Never physically removes entries.
768
+ - Do not silently rewrite or summarize entries — preserve original wording.
769
+ - Prefer the JSONL store for queries when present (faster, structured); use the markdown mirror as the human-readable source of truth for final user approval.
770
+
771
+ ## When to run
772
+
773
+ - Triggered automatically by **\`/cc-learn curate\`**.
774
+ - Recommended after \`cclaw archive\` of a feature run, when knowledge has grown.
775
+ - Recommended when active entry count exceeds **50**.
776
+
777
+ ## Audit dimensions
778
+
779
+ For each entry in \`.cclaw/knowledge.md\` produce a row with:
780
+
781
+ | Field | Source |
782
+ |---|---|
783
+ | Title | \`### <ts> [type] <title>\` heading |
784
+ | Type | \`rule\` / \`pattern\` / \`lesson\` / \`compound\` |
785
+ | Stage | \`Stage:\` field (or \`unknown\`) |
786
+ | Age | days since timestamp |
787
+ | Confidence | \`Confidence:\` field if present, else \`unstated\` |
788
+ | Domain | \`Domain:\` field if present |
789
+ | Supersedes | \`Supersedes:\` field if present |
790
+ | Status hint | one of: keep / supersede-candidate / archive-candidate / duplicate |
791
+
792
+ ### Status rules
793
+
794
+ - **supersede-candidate**: another entry has \`Supersedes: <this-title>\`.
795
+ - **duplicate**: title or insight ≈ another entry's (caller's judgment, not regex).
796
+ - **archive-candidate**:
797
+ - Type \`lesson\` AND age > 180 days AND no \`Supersedes\` chain points to it; OR
798
+ - Stage = \`brainstorm\` AND age > 90 days; OR
799
+ - Confidence = \`low\` AND age > 60 days; OR
800
+ - Total active entries > 50 and entry has lowest reuse signal.
801
+ - **keep**: everything else.
802
+
803
+ ## Output format
804
+
805
+ Produce two artifacts as **chat output only** (do not write files):
806
+
807
+ ### 1. Audit table
808
+
809
+ \`\`\`markdown
810
+ | # | Title | Type | Stage | Age | Confidence | Status hint |
811
+ |---|---|---|---|---|---|---|
812
+ | 1 | … | … | … | … | … | … |
813
+ \`\`\`
814
+
815
+ ### 2. Soft-archive proposal
816
+
817
+ \`\`\`markdown
818
+ ## Proposed archive (requires user approval)
819
+
820
+ Threshold reasoning: <why entries below were selected>
821
+
822
+ Entries to archive:
823
+ 1. <title> — reason
824
+ 2. <title> — reason
825
+
826
+ Action plan if approved:
827
+ 1. Append a header to \`.cclaw/knowledge.archive.md\` with today's UTC date.
828
+ 2. Move (cut/paste) selected entries verbatim from \`.cclaw/knowledge.md\` into the archive file.
829
+ 3. Append a single supersession line to \`.cclaw/knowledge.md\`:
830
+ \\\`### <ts> [pattern] knowledge-curation-<date> — archived <N> entries, see knowledge.archive.md\\\`
831
+
832
+ After approval: ask the user to run the move themselves, or — if they explicitly grant write access — perform the move atomically and report the new active count.
833
+ \`\`\`
834
+
835
+ ## Anti-patterns
836
+
837
+ - Deleting entries instead of archiving — knowledge must be append-only.
838
+ - Rewriting an entry to "clean it up" — preserve original wording verbatim.
839
+ - Auto-archiving without user approval, even when above threshold.
840
+ - Removing \`compound\` entries — these are the highest-leverage records.
841
+ - Treating high age as a proxy for low value — a 2-year-old security rule may be the most important entry in the file.
842
+ `;
843
+ }
844
+ export function securityAuditSkill() {
845
+ return `---
846
+ name: security-audit
847
+ description: "Proactive security audit — hunts for vulnerabilities across the codebase using pattern-based detection. Distinct from security review (checklist for a specific diff)."
848
+ ---
849
+
850
+ # Security Audit
851
+
852
+ ## Quick Start
853
+
854
+ > 1. Scan the codebase for high-signal vulnerability patterns (not just the diff).
855
+ > 2. Produce a finding register grouped by category with severity and file:line.
856
+ > 3. For each Critical: provide a concrete exploit path (not just a category label).
857
+
858
+ ## HARD-GATE
859
+
860
+ Do not close a security audit pass while any Critical pattern match is
861
+ unresolved. Each Critical finding must be either fixed, suppressed with
862
+ a documented reason, or tracked as a named accepted risk with an owner.
863
+
864
+ ## When to Use
865
+
866
+ - Initial project onboarding (baseline audit)
867
+ - Before a major release that expands attack surface
868
+ - When new dependencies are introduced
869
+ - After a security incident (to check for same-class issues)
870
+ - On a scheduled cadence (quarterly for stable projects, monthly for high-risk)
871
+
872
+ This is complementary to the \`security\` skill, which is a point-in-time
873
+ review checklist scoped to a single diff.
874
+
875
+ ## Audit Pattern Catalog
876
+
877
+ Run each category as a focused pass. For every pattern, capture
878
+ file:line evidence — never assume the project is clean just because
879
+ there was "no obvious problem".
880
+
881
+ ### 1. Secret Exposure
882
+
883
+ Patterns to grep for (language-agnostic):
884
+
885
+ - \`AKIA[0-9A-Z]{16}\` — AWS access key id
886
+ - \`-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----\`
887
+ - \`xox[bp]-[0-9a-zA-Z-]+\` — Slack tokens
888
+ - \`ghp_[A-Za-z0-9]{36}\` — GitHub PAT
889
+ - \`console\\.log.*(token|secret|password|api_key)\`
890
+ - Hard-coded JWTs (3 base64 segments separated by \`.\`)
891
+
892
+ Also inspect: .env.example for real values, logs for PII, git history for
893
+ leaked secrets via \`git log -p | grep -i secret\`.
894
+
895
+ ### 2. Injection
896
+
897
+ - Raw SQL string concatenation with request data
898
+ - \`eval(\`, \`new Function(\`, \`exec(\`, \`execSync(\` with untrusted input
899
+ - \`dangerouslySetInnerHTML\`, \`innerHTML =\` with user-provided content
900
+ - Shell command construction from user input
901
+ - Template literal SQL (\`\\\`SELECT ... \${userInput}\\\`\`)
902
+
903
+ ### 3. Auth and Session
904
+
905
+ - Missing auth middleware on routes that mutate state
906
+ - JWT verification that trusts the \`alg\` header (algorithm confusion)
907
+ - \`setCookie\` without \`HttpOnly\`, \`Secure\`, or \`SameSite\`
908
+ - Session fixation (no regenerate-on-login)
909
+ - Rate limit absent on login, signup, password reset
910
+
911
+ ### 4. Trust Boundary and LLM Output
912
+
913
+ - LLM output passed directly to \`exec\` / SQL / filesystem calls
914
+ - Tool-call arguments from the model used without schema validation
915
+ - Untrusted markdown rendered without sanitization
916
+ - Confused deputy: service acts on behalf of user without passing auth context
917
+
918
+ ### 5. Crypto Misuse
919
+
920
+ - MD5 / SHA1 for password hashing
921
+ - \`Math.random()\` used for security tokens
922
+ - Reused IV in AES-GCM (catastrophic)
923
+ - ECB mode cipher usage
924
+ - Missing constant-time comparison for secrets
925
+
926
+ ### 6. Dependency and Supply Chain
927
+
928
+ - \`npm audit\` / \`pip audit\` Critical or High advisories unresolved
929
+ - Dependencies pulled from non-locked tags instead of pinned versions
930
+ - Post-install scripts from new/unknown packages
931
+ - Un-reviewed direct-to-main dependency bumps
932
+
933
+ ### 7. File System and Path Traversal
934
+
935
+ - \`path.join\` with user input without \`path.normalize\` + prefix check
936
+ - Unzip/untar without entry path validation (zip-slip)
937
+ - Writing to user-supplied paths without allowlist
938
+ - Following symlinks inside trusted directories
939
+
940
+ ### 8. Logging and Observability
941
+
942
+ - Stack traces returned in API responses (production)
943
+ - Logs containing tokens, passwords, full request bodies
944
+ - Error messages that reveal DB schema or internal paths
945
+
946
+ ## Output Format
947
+
948
+ Produce a single audit report with this structure:
949
+
950
+ \`\`\`markdown
951
+ # Security Audit — <scope>, <date>
952
+
953
+ ## Summary
954
+ - Files scanned: <N>
955
+ - Categories checked: <list>
956
+ - Critical: <N>, Important: <N>, Suggestion: <N>
957
+
958
+ ## Findings
959
+
960
+ ### <Category> — <Pattern name>
961
+ - **Severity:** Critical | Important | Suggestion
962
+ - **File:line:** path/to/file.ts:42
963
+ - **Evidence:** short excerpt (≤ 3 lines)
964
+ - **Exploit path:** specific, concrete (not a category label)
965
+ - **Fix:** specific remediation with command/patch-level detail
966
+ - **Owner:** <name or role>
967
+ - **Target date:** <YYYY-MM-DD for Critical/Important>
968
+
969
+ ## Accepted Risks
970
+ - <finding id>: <reason documented>, owner <name>, revisit <date>
971
+
972
+ ## Suppressed (False Positives)
973
+ - <finding id>: <why this pattern is not exploitable here>
974
+ \`\`\`
975
+
976
+ ## Anti-Patterns
977
+
978
+ - "No Critical findings" without stating what patterns were actually run.
979
+ - Accepting a Critical risk without named owner + revisit date.
980
+ - Treating a lint rule as equivalent to a runtime security check.
981
+ - Running audits only on the diff — the diff does not contain legacy risks.
982
+ - Deleting audit reports after fixing findings (keep them as regression evidence).
983
+
984
+ ## Red Flags
985
+
986
+ - Audit claims coverage but cites zero file:line evidence.
987
+ - Every Critical pattern has zero matches (this is implausible for any non-trivial codebase — verify the grep commands were actually executed).
988
+ - Findings are Important-only (no Critical or Suggestion buckets) — usually means severity was compressed to avoid escalation.
989
+ `;
990
+ }
991
+ export function adversarialReviewSkill() {
992
+ return `---
993
+ name: adversarial-review
994
+ description: "Adversarial review lens. Use during review to deliberately attack the implementation — as a hostile user, a future maintainer, or a competitor."
995
+ ---
996
+
997
+ # Adversarial Review
998
+
999
+ ## Quick Start
1000
+
1001
+ > 1. Stop assuming good-faith usage. Play three roles in sequence: hostile user, stressed operator, future maintainer.
1002
+ > 2. For each role, produce at least 2 concrete attack/friction scenarios with file:line evidence.
1003
+ > 3. Escalate any finding that a Critical severity review would miss.
1004
+
1005
+ ## HARD-GATE
1006
+
1007
+ Do not complete review stage without an adversarial-review pass when
1008
+ **any** of the following apply: user-facing input surface changed,
1009
+ trust boundary moved, concurrency was introduced, or a new failure
1010
+ mode path was added.
1011
+
1012
+ ## When to Use
1013
+
1014
+ - Review stage, after Layer 2 quality checks complete
1015
+ - Before shipping anything user-facing or revenue-sensitive
1016
+ - When fuzz/property-testing exists but was not exercised against this change
1017
+ - When the implementer has a strong "this is fine" prior
1018
+
1019
+ ## Roles and Questions
1020
+
1021
+ ### Role 1 — Hostile User
1022
+
1023
+ You are trying to break, trick, or exploit the system. Ask:
1024
+
1025
+ - What happens on empty / null / maximum / negative / unicode / newline inputs?
1026
+ - What if I call the endpoint 1000 times per second? What about 1 every 10 minutes for a week?
1027
+ - What if I send a payload that is almost valid (off-by-one schema, wrong content-type, duplicate keys)?
1028
+ - What if two honest actions collide (double-click, race, retry after timeout)?
1029
+ - Can I observe a secret through error messages, timing, or response size?
1030
+
1031
+ ### Role 2 — Stressed Operator
1032
+
1033
+ You are on call at 3 AM. Ask:
1034
+
1035
+ - What does this look like in logs when it fails? Is the failure actionable?
1036
+ - If I restart the service mid-request, does state recover cleanly?
1037
+ - Is the rollback procedure real, tested, and under 15 minutes?
1038
+ - Can I tell from metrics alone whether this is healthy?
1039
+
1040
+ ### Role 3 — Future Maintainer
1041
+
1042
+ You are reading this code in 6 months with no memory of the context. Ask:
1043
+
1044
+ - Can I safely change this without breaking callers I cannot see?
1045
+ - Are there hidden invariants not captured in tests?
1046
+ - Will renaming this field silently break serialized consumers?
1047
+ - Is the "obviously correct" path actually correct, or is it just plausible?
1048
+
1049
+ ## Output Format
1050
+
1051
+ For each finding:
1052
+
1053
+ \`\`\`
1054
+ - **Role:** Hostile User | Stressed Operator | Future Maintainer
1055
+ - **Scenario:** concrete scenario (not a category)
1056
+ - **File:line:** path/to/file.ts:42
1057
+ - **Impact:** what breaks, for whom, under what frequency
1058
+ - **Recommendation:** specific fix or mitigation
1059
+ \`\`\`
1060
+
1061
+ Escalate to the main review-army under the matching severity (Critical / Important / Suggestion).
1062
+
1063
+ ## Anti-Patterns
1064
+
1065
+ - Treating adversarial review as a category list without producing concrete scenarios.
1066
+ - Assuming "our users would never do that" — they will, or the next integration will.
1067
+ - Running adversarial review after the ship decision is already made.
1068
+ - Only playing the hostile-user role and skipping operator + maintainer.
1069
+ `;
1070
+ }
1071
+ export function retrospectiveSkill() {
1072
+ return `---
1073
+ name: retrospective
1074
+ description: "Post-ship retrospective lens. Use after a ship to extract durable lessons (rules, patterns, accelerators) before context fades. Distinct from the inline ship Compound Step — this is a deeper, optional sweep across the whole run."
1075
+ ---
1076
+
1077
+ # Retrospective
1078
+
1079
+ ## Quick Start
1080
+
1081
+ > 1. Run **after** the ship stage closes (PR merged or release tagged), while the run is still loaded in memory.
1082
+ > 2. Walk the four lenses below; harvest concrete entries for \`.cclaw/knowledge.md\`.
1083
+ > 3. Stop when you have at least one durable entry **or** an explicit "no new lesson this run".
1084
+
1085
+ ## HARD-GATE
1086
+
1087
+ Do **not** run retrospective before ship gates pass. The goal is to learn from
1088
+ a *closed* loop, not to evaluate work-in-progress.
1089
+ Do **not** invent generic platitudes ("write more tests"). Every entry must cite
1090
+ a concrete moment in *this* run (file, decision, blocker, surprise).
1091
+
1092
+ ## When to use
1093
+
1094
+ - Right after \`/cc-next\` reports the ship stage complete.
1095
+ - Before starting the next \`/cc <idea>\` — fresh context, lessons captured.
1096
+ - After an incident or surprise during ship (rollback, hotfix, regression).
1097
+
1098
+ ## When NOT to use
1099
+
1100
+ - Mid-flow (use the per-stage Operational Self-Improvement block instead).
1101
+ - For trivial changes (typo fix, config bump) — the Compound Step in the
1102
+ ship template is enough.
1103
+
1104
+ ## Four Lenses
1105
+
1106
+ For each lens, write either a knowledge entry **or** the explicit string
1107
+ "no new lesson". Skipping a lens silently is forbidden.
1108
+
1109
+ ### 1. What surprised us?
1110
+
1111
+ - A bug that hid in a place no one suspected → \`[lesson]\`.
1112
+ - A test that passed but missed a real failure mode → \`[lesson]\`.
1113
+ - A library/API behavior that contradicted our mental model → \`[rule]\`.
1114
+
1115
+ ### 2. What slowed us down?
1116
+
1117
+ - Repeated context loss between waves → \`[compound]\` accelerator.
1118
+ - Re-derivation of a fact already in upstream artifacts → \`[pattern]\` "re-read X first".
1119
+ - Tooling friction (slow test loop, flaky CI) → \`[compound]\` follow-up.
1120
+
1121
+ ### 3. What worked unreasonably well?
1122
+
1123
+ - A refactor that unlocked the next 3 tasks → \`[pattern]\`.
1124
+ - A skill/agent invocation that nailed it on first try → \`[pattern]\` (record the prompt shape).
1125
+ - Adopting an existing solution instead of building → \`[rule]\` reinforcement.
1126
+
1127
+ ### 4. What would we do differently next time?
1128
+
1129
+ - Architectural decision that aged poorly within the same run → \`[lesson]\`.
1130
+ - Scope mode chosen incorrectly → \`[rule]\` heuristic update.
1131
+ - Order-of-operations mistake (e.g. spec drift before tdd) → \`[pattern]\` ordering.
1132
+
1133
+ ## Output protocol
1134
+
1135
+ For every harvested insight, append one entry to \`.cclaw/knowledge.md\` using
1136
+ the standard format (see \`learnings\` skill). Prefer:
1137
+
1138
+ - \`[compound]\` for process/speed accelerators.
1139
+ - \`[lesson]\` for "we learned this the hard way".
1140
+ - \`[pattern]\` for repeatable shapes that worked.
1141
+ - \`[rule]\` only for hard constraints that must always hold.
1142
+
1143
+ Then write a one-paragraph **Run Summary** at the top of the next
1144
+ \`/cc <idea>\` brainstorm context citing the lessons in scope.
1145
+
1146
+ ## Anti-patterns
1147
+
1148
+ - Retrospective as performance review — frame is *system improvement*, not blame.
1149
+ - Harvesting only positive ("what worked") and skipping uncomfortable lessons.
1150
+ - Writing entries so generic they could apply to any project.
1151
+ - Letting the retrospective drift into a re-design of the shipped feature.
1152
+ `;
1153
+ }
1154
+ export function languageTypescriptSkill() {
1155
+ return `---
1156
+ name: language-typescript
1157
+ description: "TypeScript rule pack. Opt-in language lens. Use when reviewing or writing TypeScript/JavaScript diffs during tdd or review — enforces type-safety, runtime-boundary validation, and idiomatic patterns."
1158
+ ---
1159
+
1160
+ # TypeScript Rule Pack
1161
+
1162
+ ## Quick Start
1163
+
1164
+ > 1. Activate during tdd or review whenever the diff touches \`.ts\`, \`.tsx\`, \`.mts\`, \`.cts\`, or \`.js\` files.
1165
+ > 2. Walk the rule tiers in order. Tier-1 violations block merge. Tier-2 need a named follow-up.
1166
+ > 3. Cite each finding as \`file:line — <rule id> — <one-line remediation>\`.
1167
+
1168
+ ## HARD-GATE
1169
+
1170
+ Do not approve a TypeScript change that ships \`any\`, \`@ts-ignore\`, or
1171
+ \`@ts-expect-error\` *without* (a) a comment explaining why, (b) a linked issue,
1172
+ and (c) an assertion that the blast radius is bounded to the current file.
1173
+ No exceptions in production code paths.
1174
+
1175
+ ## Tier 1 — blocking rules
1176
+
1177
+ 1. **No silent \`any\`.** Unknown inputs must be typed as \`unknown\` first, then narrowed.
1178
+ 2. **Runtime validate trust boundaries.** HTTP bodies, env vars, file contents, and
1179
+ IPC payloads must be parsed through a schema validator (zod, valibot, io-ts) before
1180
+ being treated as typed data.
1181
+ 3. **No \`as\` without a narrowing reason.** \`value as Foo\` is only acceptable when
1182
+ preceded by a runtime check that proves the shape (e.g. \`if ("id" in value)\`).
1183
+ 4. **Exhaustive switches on discriminated unions.** Every \`switch\` on a tagged
1184
+ union must end with a \`default\` branch that assigns to \`never\` to surface
1185
+ missing cases at compile time.
1186
+ 5. **Promise hygiene.** No unawaited promises in \`async\` functions; no
1187
+ \`void promise\` unless documented. Use \`@typescript-eslint/no-floating-promises\`.
1188
+ 6. **Null-safety at the boundary.** Optional chaining (\`?.\`) and nullish
1189
+ coalescing (\`??\`) must only be used when the null path is handled, not as a
1190
+ silent default.
1191
+
1192
+ ## Tier 2 — follow-up rules
1193
+
1194
+ 7. Prefer \`readonly\` for arrays/object fields that are not mutated.
1195
+ 8. Prefer \`type\` aliases for unions, \`interface\` for extendable object shapes.
1196
+ 9. Name generic parameters descriptively once they carry semantic meaning (\`TEvent\`, \`TPayload\`).
1197
+ 10. Avoid re-exporting entire namespaces; named re-exports keep bundle analysis tractable.
1198
+ 11. Co-locate test fixtures with their types to keep drift visible.
1199
+
1200
+ ## Anti-patterns
1201
+
1202
+ - "It compiles, ship it" — compilation is necessary, not sufficient. Runtime boundary validation is the gate.
1203
+ - Casting library return types to tighten them without reading the library's actual contract.
1204
+ - Wrapping every function in \`try/catch\` and swallowing the error — errors must either be rethrown typed or mapped to a Result/Either shape.
1205
+ - Using enums where a string-literal union would do (enums carry runtime cost and erase at tree-shaking time only when \`const\`).
1206
+
1207
+ ## Review output shape
1208
+
1209
+ \`\`\`
1210
+ - **Rule:** T1-2 (runtime validate trust boundaries)
1211
+ - **File:line:** src/api/users.ts:42
1212
+ - **Finding:** POST body cast directly to \`UserCreateInput\`; no schema parse.
1213
+ - **Remediation:** Parse through \`userCreateSchema\` (zod) before passing to the service layer.
1214
+ \`\`\`
1215
+ `;
1216
+ }
1217
+ export function languagePythonSkill() {
1218
+ return `---
1219
+ name: language-python
1220
+ description: "Python rule pack. Opt-in language lens. Use when reviewing or writing Python diffs during tdd or review — enforces typing, exception hygiene, and idiomatic patterns."
1221
+ ---
1222
+
1223
+ # Python Rule Pack
1224
+
1225
+ ## Quick Start
1226
+
1227
+ > 1. Activate during tdd or review whenever the diff touches \`.py\` / \`.pyi\` files.
1228
+ > 2. Walk the rule tiers in order. Tier-1 violations block merge. Tier-2 need a named follow-up.
1229
+ > 3. Cite each finding as \`file:line — <rule id> — <one-line remediation>\`.
1230
+
1231
+ ## HARD-GATE
1232
+
1233
+ Do not approve a Python change that catches bare \`except:\` or \`except Exception:\`
1234
+ in production code *without* (a) re-raising, (b) logging with \`logger.exception\`, or
1235
+ (c) a comment explaining the intentional swallow. Silent broad catches are the
1236
+ single biggest source of "works on my machine" bugs in Python services.
1237
+
1238
+ ## Tier 1 — blocking rules
1239
+
1240
+ 1. **Type hints on public APIs.** Every exported function, method, and dataclass
1241
+ must have full type hints. Use \`from __future__ import annotations\` or PEP 604 union syntax.
1242
+ 2. **No mutable default arguments.** \`def f(x=[])\` is a bug. Use \`None\` + inline default.
1243
+ 3. **Exception specificity.** Catch the narrowest exception class you actually handle.
1244
+ 4. **Context managers for resources.** Files, sockets, DB sessions, locks — always \`with\`.
1245
+ 5. **No bare \`assert\` in production code.** \`assert\` is stripped under \`python -O\`.
1246
+ For invariants, raise \`ValueError\`/\`RuntimeError\` explicitly.
1247
+ 6. **Deterministic imports.** No conditional imports at module top level except for
1248
+ platform branches; no import-time side effects.
1249
+
1250
+ ## Tier 2 — follow-up rules
1251
+
1252
+ 7. Prefer \`@dataclass(slots=True, frozen=True)\` for value objects.
1253
+ 8. Prefer \`pathlib.Path\` over \`os.path\` for new code.
1254
+ 9. Use f-strings for interpolation; reserve \`%\` and \`.format\` for logger messages (lazy eval).
1255
+ 10. Use \`logging.getLogger(__name__)\` per module; never the root logger.
1256
+ 11. Pin dependency ranges in \`pyproject.toml\`; lock with \`uv lock\` / \`pip-compile\`.
1257
+
1258
+ ## Async-specific
1259
+
1260
+ - Do not mix \`requests\`/sync I/O inside \`async def\`. Use \`httpx.AsyncClient\` / \`aiofiles\`.
1261
+ - \`asyncio.gather\` with \`return_exceptions=False\` cancels siblings on first failure — be explicit.
1262
+ - Every task created with \`asyncio.create_task\` must have its reference kept and awaited.
1263
+
1264
+ ## Anti-patterns
1265
+
1266
+ - Using \`**kwargs\` to avoid writing a real signature.
1267
+ - Monkey-patching modules from tests without a \`contextlib.contextmanager\` cleanup.
1268
+ - Treating \`__init__.py\` as a place to run logic (imports only).
1269
+ - Re-inventing \`itertools\`/\`functools\` instead of using stdlib.
1270
+
1271
+ ## Review output shape
1272
+
1273
+ \`\`\`
1274
+ - **Rule:** P1-3 (exception specificity)
1275
+ - **File:line:** users/service.py:88
1276
+ - **Finding:** \`except Exception\` around DB call silently drops integrity errors.
1277
+ - **Remediation:** Catch \`IntegrityError\` explicitly; re-raise everything else.
1278
+ \`\`\`
1279
+ `;
1280
+ }
1281
+ export function languageGoSkill() {
1282
+ return `---
1283
+ name: language-go
1284
+ description: "Go rule pack. Opt-in language lens. Use when reviewing or writing Go diffs during tdd or review — enforces error handling discipline, concurrency safety, and idiomatic patterns."
1285
+ ---
1286
+
1287
+ # Go Rule Pack
1288
+
1289
+ ## Quick Start
1290
+
1291
+ > 1. Activate during tdd or review whenever the diff touches \`.go\` files.
1292
+ > 2. Walk the rule tiers in order. Tier-1 violations block merge. Tier-2 need a named follow-up.
1293
+ > 3. Cite each finding as \`file:line — <rule id> — <one-line remediation>\`.
1294
+
1295
+ ## HARD-GATE
1296
+
1297
+ Do not approve a Go change that discards an \`error\` return value with \`_ = ...\`
1298
+ in production code *without* a comment explaining why the error is provably
1299
+ irrelevant. Discarded errors are Go's #1 source of silent data loss.
1300
+
1301
+ ## Tier 1 — blocking rules
1302
+
1303
+ 1. **Every \`error\` is checked or explicitly wrapped with \`fmt.Errorf("%w", err)\`.**
1304
+ 2. **No goroutine leaks.** Every \`go func()\` must have a stop condition visible in
1305
+ the diff: a \`context.Context\` cancellation, a \`done\` channel, or a bounded
1306
+ input channel that will close.
1307
+ 3. **Context propagation.** Any function that does I/O, RPC, or long work must take
1308
+ \`ctx context.Context\` as the first parameter.
1309
+ 4. **No mutex by value.** Fields of type \`sync.Mutex\` / \`sync.RWMutex\` must be
1310
+ pointers *or* the containing struct must be used only via pointer receivers.
1311
+ 5. **Defer placement.** \`defer file.Close()\` must immediately follow a successful
1312
+ open, before any code path that can return early.
1313
+ 6. **\`for range\` capture hygiene** (pre-Go 1.22): copy loop variables before
1314
+ capturing in goroutines or deferred functions. From Go 1.22+ the language fixes
1315
+ this, but confirm the repo's \`go\` directive in \`go.mod\`.
1316
+
1317
+ ## Tier 2 — follow-up rules
1318
+
1319
+ 7. Prefer small interfaces defined at the consumer site, not upstream.
1320
+ 8. Prefer \`errors.Is\` / \`errors.As\` over string matching.
1321
+ 9. Avoid \`init()\` except for registering with a framework.
1322
+ 10. Use \`t.Helper()\` inside test helpers so failure lines point at the caller.
1323
+ 11. Use \`//go:build\` tags for OS-specific code, not runtime \`runtime.GOOS\` checks.
1324
+
1325
+ ## Concurrency-specific
1326
+
1327
+ - Buffered channels are a performance hint, not a correctness fix. Unbuffered first.
1328
+ - \`sync.WaitGroup\` \`Add\` must happen **before** \`go\`, not inside the goroutine.
1329
+ - \`atomic\` operations must be paired on the same variable — do not mix \`atomic.Load\`
1330
+ with plain reads of the same field.
1331
+ - Shared maps require a mutex or \`sync.Map\`; Go's race detector in CI is non-negotiable.
1332
+
1333
+ ## Anti-patterns
1334
+
1335
+ - Returning \`interface{}\` / \`any\` to "keep options open" — narrow it now.
1336
+ - Building "smart" error types that lose the wrapped chain.
1337
+ - Using \`panic\` for control flow in library code (allowed only for unrecoverable invariants).
1338
+ - Ignoring \`go vet\` warnings because "the code works".
1339
+
1340
+ ## Review output shape
1341
+
1342
+ \`\`\`
1343
+ - **Rule:** G1-2 (no goroutine leaks)
1344
+ - **File:line:** internal/worker/pool.go:57
1345
+ - **Finding:** \`go w.loop()\` has no stop condition; context is not threaded through.
1346
+ - **Remediation:** Accept \`ctx\` in \`Start\` and select on \`ctx.Done()\` inside \`loop\`.
1347
+ \`\`\`
1348
+ `;
1349
+ }
1350
+ export const LANGUAGE_RULE_PACK_FOLDERS = {
1351
+ typescript: "language-typescript",
1352
+ python: "language-python",
1353
+ go: "language-go"
1354
+ };
1355
+ export const LANGUAGE_RULE_PACK_GENERATORS = {
1356
+ "language-typescript": languageTypescriptSkill,
1357
+ "language-python": languagePythonSkill,
1358
+ "language-go": languageGoSkill
1359
+ };
652
1360
  export const UTILITY_SKILL_FOLDERS = [
653
1361
  "security",
654
1362
  "debugging",
@@ -658,7 +1366,12 @@ export const UTILITY_SKILL_FOLDERS = [
658
1366
  "executing-plans",
659
1367
  "context-engineering",
660
1368
  "source-driven-development",
661
- "frontend-accessibility"
1369
+ "frontend-accessibility",
1370
+ "landscape-check",
1371
+ "adversarial-review",
1372
+ "security-audit",
1373
+ "knowledge-curation",
1374
+ "retrospective"
662
1375
  ];
663
1376
  export const UTILITY_SKILL_MAP = {
664
1377
  security: securityReviewSkill,
@@ -669,5 +1382,10 @@ export const UTILITY_SKILL_MAP = {
669
1382
  "executing-plans": executingPlansSkill,
670
1383
  "context-engineering": contextEngineeringSkill,
671
1384
  "source-driven-development": sourceDrivenDevelopmentSkill,
672
- "frontend-accessibility": frontendAccessibilitySkill
1385
+ "frontend-accessibility": frontendAccessibilitySkill,
1386
+ "landscape-check": landscapeCheckSkill,
1387
+ "adversarial-review": adversarialReviewSkill,
1388
+ "security-audit": securityAuditSkill,
1389
+ "knowledge-curation": knowledgeCurationSkill,
1390
+ retrospective: retrospectiveSkill
673
1391
  };