bros-harness 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +183 -0
  4. package/SECURITY.md +16 -0
  5. package/assets/agents.manifest.json +55 -0
  6. package/assets/commands.manifest.json +35 -0
  7. package/assets/docs.manifest.json +20 -0
  8. package/assets/import-report.md +25 -0
  9. package/assets/manifest.json +799 -0
  10. package/assets/opencode/agents/README.md +3 -0
  11. package/assets/opencode/agents/bro-build.md +256 -0
  12. package/assets/opencode/agents/bro-design.md +77 -0
  13. package/assets/opencode/agents/bro-docs.md +72 -0
  14. package/assets/opencode/agents/bro-explore.md +143 -0
  15. package/assets/opencode/agents/bro-ops.md +195 -0
  16. package/assets/opencode/agents/bro-shield.md +77 -0
  17. package/assets/opencode/agents/bro-test.md +204 -0
  18. package/assets/opencode/agents/bro-ui.md +135 -0
  19. package/assets/opencode/agents/mighty-bro.md +252 -0
  20. package/assets/opencode/commands/README.md +3 -0
  21. package/assets/opencode/commands/bros-assemble.md +32 -0
  22. package/assets/opencode/commands/bros-build.md +58 -0
  23. package/assets/opencode/commands/bros-plan.md +83 -0
  24. package/assets/opencode/commands/bros-review.md +38 -0
  25. package/assets/opencode/commands/bros-status.md +26 -0
  26. package/assets/opencode/docs/README.md +3 -0
  27. package/assets/opencode/docs/bros-builtin-skills.md +63 -0
  28. package/assets/opencode/docs/bros-harness.md +194 -0
  29. package/assets/opencode/skills/README.md +3 -0
  30. package/assets/opencode/skills/agent-architecture-audit/SKILL.md +256 -0
  31. package/assets/opencode/skills/agent-harness-construction/.openskills.json +7 -0
  32. package/assets/opencode/skills/agent-harness-construction/SKILL.md +73 -0
  33. package/assets/opencode/skills/agent-introspection-debugging/.openskills.json +7 -0
  34. package/assets/opencode/skills/agent-introspection-debugging/SKILL.md +153 -0
  35. package/assets/opencode/skills/api-design/.openskills.json +7 -0
  36. package/assets/opencode/skills/api-design/agents/openai.yaml +7 -0
  37. package/assets/opencode/skills/architecture-decision-records/.openskills.json +7 -0
  38. package/assets/opencode/skills/architecture-decision-records/SKILL.md +179 -0
  39. package/assets/opencode/skills/article-writing/.openskills.json +7 -0
  40. package/assets/opencode/skills/article-writing/SKILL.md +79 -0
  41. package/assets/opencode/skills/article-writing/agents/openai.yaml +7 -0
  42. package/assets/opencode/skills/automation-audit-ops/.openskills.json +7 -0
  43. package/assets/opencode/skills/automation-audit-ops/SKILL.md +142 -0
  44. package/assets/opencode/skills/backend-patterns/.openskills.json +7 -0
  45. package/assets/opencode/skills/backend-patterns/SKILL.md +561 -0
  46. package/assets/opencode/skills/backend-patterns/agents/openai.yaml +7 -0
  47. package/assets/opencode/skills/benchmark/.openskills.json +7 -0
  48. package/assets/opencode/skills/benchmark/SKILL.md +93 -0
  49. package/assets/opencode/skills/bros-orchestrate/SKILL.md +455 -0
  50. package/assets/opencode/skills/browser-qa/.openskills.json +7 -0
  51. package/assets/opencode/skills/browser-qa/SKILL.md +87 -0
  52. package/assets/opencode/skills/canary-watch/.openskills.json +7 -0
  53. package/assets/opencode/skills/canary-watch/SKILL.md +107 -0
  54. package/assets/opencode/skills/code-review-expert/SKILL.md +155 -0
  55. package/assets/opencode/skills/code-review-expert/agents/agent.yaml +7 -0
  56. package/assets/opencode/skills/code-review-expert/references/code-quality-checklist.md +130 -0
  57. package/assets/opencode/skills/code-review-expert/references/removal-plan.md +52 -0
  58. package/assets/opencode/skills/code-review-expert/references/security-checklist.md +118 -0
  59. package/assets/opencode/skills/code-review-expert/references/solid-checklist.md +65 -0
  60. package/assets/opencode/skills/code-tour/.openskills.json +7 -0
  61. package/assets/opencode/skills/code-tour/SKILL.md +236 -0
  62. package/assets/opencode/skills/coding-standards/.openskills.json +7 -0
  63. package/assets/opencode/skills/coding-standards/SKILL.md +549 -0
  64. package/assets/opencode/skills/coding-standards/agents/openai.yaml +7 -0
  65. package/assets/opencode/skills/context-budget/.openskills.json +7 -0
  66. package/assets/opencode/skills/context-budget/SKILL.md +135 -0
  67. package/assets/opencode/skills/database-migrations/.openskills.json +7 -0
  68. package/assets/opencode/skills/database-migrations/SKILL.md +429 -0
  69. package/assets/opencode/skills/deployment-patterns/.openskills.json +7 -0
  70. package/assets/opencode/skills/deployment-patterns/SKILL.md +427 -0
  71. package/assets/opencode/skills/design-system/.openskills.json +7 -0
  72. package/assets/opencode/skills/design-system/SKILL.md +82 -0
  73. package/assets/opencode/skills/docker-patterns/.openskills.json +7 -0
  74. package/assets/opencode/skills/docker-patterns/SKILL.md +364 -0
  75. package/assets/opencode/skills/documentation-lookup/.openskills.json +7 -0
  76. package/assets/opencode/skills/documentation-lookup/SKILL.md +90 -0
  77. package/assets/opencode/skills/documentation-lookup/agents/openai.yaml +7 -0
  78. package/assets/opencode/skills/e2e-testing/.openskills.json +7 -0
  79. package/assets/opencode/skills/e2e-testing/SKILL.md +326 -0
  80. package/assets/opencode/skills/e2e-testing/agents/openai.yaml +7 -0
  81. package/assets/opencode/skills/error-handling/SKILL.md +376 -0
  82. package/assets/opencode/skills/frontend-design/.openskills.json +7 -0
  83. package/assets/opencode/skills/frontend-design/SKILL.md +145 -0
  84. package/assets/opencode/skills/frontend-design-direction/SKILL.md +92 -0
  85. package/assets/opencode/skills/frontend-patterns/.openskills.json +7 -0
  86. package/assets/opencode/skills/frontend-patterns/SKILL.md +642 -0
  87. package/assets/opencode/skills/frontend-patterns/agents/openai.yaml +7 -0
  88. package/assets/opencode/skills/gateguard/.openskills.json +7 -0
  89. package/assets/opencode/skills/gateguard/SKILL.md +125 -0
  90. package/assets/opencode/skills/git-master/SKILL.md +60 -0
  91. package/assets/opencode/skills/golang-patterns/.openskills.json +7 -0
  92. package/assets/opencode/skills/golang-patterns/SKILL.md +674 -0
  93. package/assets/opencode/skills/golang-testing/.openskills.json +7 -0
  94. package/assets/opencode/skills/golang-testing/SKILL.md +720 -0
  95. package/assets/opencode/skills/grafana-dashboard-design/SKILL.md +65 -0
  96. package/assets/opencode/skills/hexagonal-architecture/.openskills.json +7 -0
  97. package/assets/opencode/skills/hexagonal-architecture/SKILL.md +276 -0
  98. package/assets/opencode/skills/java-coding-standards/.openskills.json +7 -0
  99. package/assets/opencode/skills/java-coding-standards/SKILL.md +383 -0
  100. package/assets/opencode/skills/jpa-patterns/.openskills.json +7 -0
  101. package/assets/opencode/skills/jpa-patterns/SKILL.md +151 -0
  102. package/assets/opencode/skills/knowledge-ops/.openskills.json +7 -0
  103. package/assets/opencode/skills/knowledge-ops/SKILL.md +154 -0
  104. package/assets/opencode/skills/make-interfaces-feel-better/SKILL.md +151 -0
  105. package/assets/opencode/skills/mysql-patterns/SKILL.md +412 -0
  106. package/assets/opencode/skills/nestjs-patterns/.openskills.json +7 -0
  107. package/assets/opencode/skills/nestjs-patterns/SKILL.md +230 -0
  108. package/assets/opencode/skills/nextjs-turbopack/.openskills.json +7 -0
  109. package/assets/opencode/skills/nextjs-turbopack/SKILL.md +57 -0
  110. package/assets/opencode/skills/nextjs-turbopack/agents/openai.yaml +7 -0
  111. package/assets/opencode/skills/parallel-execution-optimizer/SKILL.md +72 -0
  112. package/assets/opencode/skills/postgres-patterns/.openskills.json +7 -0
  113. package/assets/opencode/skills/postgres-patterns/SKILL.md +147 -0
  114. package/assets/opencode/skills/prisma-patterns/SKILL.md +371 -0
  115. package/assets/opencode/skills/product-capability/.openskills.json +7 -0
  116. package/assets/opencode/skills/product-capability/SKILL.md +141 -0
  117. package/assets/opencode/skills/product-lens/.openskills.json +7 -0
  118. package/assets/opencode/skills/product-lens/SKILL.md +92 -0
  119. package/assets/opencode/skills/production-audit/SKILL.md +206 -0
  120. package/assets/opencode/skills/python-patterns/.openskills.json +7 -0
  121. package/assets/opencode/skills/python-patterns/SKILL.md +750 -0
  122. package/assets/opencode/skills/python-testing/.openskills.json +7 -0
  123. package/assets/opencode/skills/python-testing/SKILL.md +816 -0
  124. package/assets/opencode/skills/redis-patterns/SKILL.md +403 -0
  125. package/assets/opencode/skills/requirements-clarity/README.md +260 -0
  126. package/assets/opencode/skills/requirements-clarity/SKILL.md +324 -0
  127. package/assets/opencode/skills/rust-patterns/.openskills.json +7 -0
  128. package/assets/opencode/skills/rust-patterns/SKILL.md +499 -0
  129. package/assets/opencode/skills/rust-testing/.openskills.json +7 -0
  130. package/assets/opencode/skills/rust-testing/SKILL.md +500 -0
  131. package/assets/opencode/skills/safety-guard/.openskills.json +7 -0
  132. package/assets/opencode/skills/safety-guard/SKILL.md +75 -0
  133. package/assets/opencode/skills/search-first/.openskills.json +7 -0
  134. package/assets/opencode/skills/search-first/SKILL.md +181 -0
  135. package/assets/opencode/skills/security-review/.openskills.json +7 -0
  136. package/assets/opencode/skills/security-review/agents/openai.yaml +7 -0
  137. package/assets/opencode/skills/security-review/cloud-infrastructure-security.md +361 -0
  138. package/assets/opencode/skills/security-scan/.openskills.json +7 -0
  139. package/assets/opencode/skills/security-scan/SKILL.md +165 -0
  140. package/assets/opencode/skills/springboot-patterns/.openskills.json +7 -0
  141. package/assets/opencode/skills/springboot-patterns/SKILL.md +314 -0
  142. package/assets/opencode/skills/springboot-tdd/.openskills.json +7 -0
  143. package/assets/opencode/skills/springboot-tdd/SKILL.md +158 -0
  144. package/assets/opencode/skills/springboot-verification/.openskills.json +7 -0
  145. package/assets/opencode/skills/springboot-verification/SKILL.md +231 -0
  146. package/assets/opencode/skills/strategic-compact/.openskills.json +7 -0
  147. package/assets/opencode/skills/strategic-compact/SKILL.md +131 -0
  148. package/assets/opencode/skills/strategic-compact/agents/openai.yaml +7 -0
  149. package/assets/opencode/skills/strategic-compact/suggest-compact.sh +54 -0
  150. package/assets/opencode/skills/tdd-workflow/.openskills.json +7 -0
  151. package/assets/opencode/skills/tdd-workflow/SKILL.md +463 -0
  152. package/assets/opencode/skills/tdd-workflow/agents/openai.yaml +7 -0
  153. package/assets/opencode/skills/verification-loop/.openskills.json +7 -0
  154. package/assets/opencode/skills/verification-loop/SKILL.md +126 -0
  155. package/assets/opencode/skills/verification-loop/agents/openai.yaml +7 -0
  156. package/assets/opencode/skills/vite-patterns/SKILL.md +449 -0
  157. package/assets/opencode/skills/web-doc-search/SKILL.md +51 -0
  158. package/assets/opencode/templates/README.md +3 -0
  159. package/assets/opencode/templates/bros/adr.md +39 -0
  160. package/assets/opencode/templates/bros/delivery-report.md +71 -0
  161. package/assets/opencode/templates/bros/explorer-evidence-packet.md +51 -0
  162. package/assets/opencode/templates/bros/prd.md +72 -0
  163. package/assets/opencode/templates/bros/security-review.md +48 -0
  164. package/assets/opencode/templates/bros/status-board.md +33 -0
  165. package/assets/opencode/templates/bros/task-packet.md +94 -0
  166. package/assets/opencode/templates/bros/test-strategy.md +57 -0
  167. package/assets/opencode/templates/bros/ui-implementation-packet.md +64 -0
  168. package/assets/skills.manifest.json +650 -0
  169. package/assets/templates.manifest.json +55 -0
  170. package/bin/bros.mjs +122 -0
  171. package/docs/compatibility.md +9 -0
  172. package/docs/installation.md +66 -0
  173. package/docs/integrations/claude.md +5 -0
  174. package/docs/integrations/codex.md +5 -0
  175. package/docs/integrations/opencode.md +39 -0
  176. package/docs/migration/from-local-opencode-config.md +10 -0
  177. package/docs/release-process.md +11 -0
  178. package/docs/repository-structure.md +15 -0
  179. package/docs/roadmap.md +20 -0
  180. package/docs/security.md +18 -0
  181. package/docs/testing.md +9 -0
  182. package/examples/opencode/README.md +11 -0
  183. package/examples/opencode/opencode.example.jsonc +4 -0
  184. package/package.json +43 -0
  185. package/scripts/validate-assets.mjs +22 -0
  186. package/scripts/verify-no-secrets.mjs +38 -0
  187. package/src/plugin.mjs +98 -0
@@ -0,0 +1,231 @@
1
+ ---
2
+ name: springboot-verification
3
+ description: "Verification loop for Spring Boot projects: build, static analysis, tests with coverage, security scans, and diff review before release or PR."
4
+ origin: ECC
5
+ ---
6
+
7
+ # Spring Boot Verification Loop
8
+
9
+ Run before PRs, after major changes, and pre-deploy.
10
+
11
+ ## When to Activate
12
+
13
+ - Before opening a pull request for a Spring Boot service
14
+ - After major refactoring or dependency upgrades
15
+ - Pre-deployment verification for staging or production
16
+ - Running full build → lint → test → security scan pipeline
17
+ - Validating test coverage meets thresholds
18
+
19
+ ## Phase 1: Build
20
+
21
+ ```bash
22
+ mvn -T 4 clean verify -DskipTests
23
+ # or
24
+ ./gradlew clean assemble -x test
25
+ ```
26
+
27
+ If build fails, stop and fix.
28
+
29
+ ## Phase 2: Static Analysis
30
+
31
+ Maven (common plugins):
32
+ ```bash
33
+ mvn -T 4 spotbugs:check pmd:check checkstyle:check
34
+ ```
35
+
36
+ Gradle (if configured):
37
+ ```bash
38
+ ./gradlew checkstyleMain pmdMain spotbugsMain
39
+ ```
40
+
41
+ ## Phase 3: Tests + Coverage
42
+
43
+ ```bash
44
+ mvn -T 4 test
45
+ mvn jacoco:report # verify 80%+ coverage
46
+ # or
47
+ ./gradlew test jacocoTestReport
48
+ ```
49
+
50
+ Report:
51
+ - Total tests, passed/failed
52
+ - Coverage % (lines/branches)
53
+
54
+ ### Unit Tests
55
+
56
+ Test service logic in isolation with mocked dependencies:
57
+
58
+ ```java
59
+ @ExtendWith(MockitoExtension.class)
60
+ class UserServiceTest {
61
+
62
+ @Mock private UserRepository userRepository;
63
+ @InjectMocks private UserService userService;
64
+
65
+ @Test
66
+ void createUser_validInput_returnsUser() {
67
+ var dto = new CreateUserDto("Alice", "alice@example.com");
68
+ var expected = new User(1L, "Alice", "alice@example.com");
69
+ when(userRepository.save(any(User.class))).thenReturn(expected);
70
+
71
+ var result = userService.create(dto);
72
+
73
+ assertThat(result.name()).isEqualTo("Alice");
74
+ verify(userRepository).save(any(User.class));
75
+ }
76
+
77
+ @Test
78
+ void createUser_duplicateEmail_throwsException() {
79
+ var dto = new CreateUserDto("Alice", "existing@example.com");
80
+ when(userRepository.existsByEmail(dto.email())).thenReturn(true);
81
+
82
+ assertThatThrownBy(() -> userService.create(dto))
83
+ .isInstanceOf(DuplicateEmailException.class);
84
+ }
85
+ }
86
+ ```
87
+
88
+ ### Integration Tests with Testcontainers
89
+
90
+ Test against a real database instead of H2:
91
+
92
+ ```java
93
+ @SpringBootTest
94
+ @Testcontainers
95
+ class UserRepositoryIntegrationTest {
96
+
97
+ @Container
98
+ static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:16-alpine")
99
+ .withDatabaseName("testdb");
100
+
101
+ @DynamicPropertySource
102
+ static void configureProperties(DynamicPropertyRegistry registry) {
103
+ registry.add("spring.datasource.url", postgres::getJdbcUrl);
104
+ registry.add("spring.datasource.username", postgres::getUsername);
105
+ registry.add("spring.datasource.password", postgres::getPassword);
106
+ }
107
+
108
+ @Autowired private UserRepository userRepository;
109
+
110
+ @Test
111
+ void findByEmail_existingUser_returnsUser() {
112
+ userRepository.save(new User("Alice", "alice@example.com"));
113
+
114
+ var found = userRepository.findByEmail("alice@example.com");
115
+
116
+ assertThat(found).isPresent();
117
+ assertThat(found.get().getName()).isEqualTo("Alice");
118
+ }
119
+ }
120
+ ```
121
+
122
+ ### API Tests with MockMvc
123
+
124
+ Test controller layer with full Spring context:
125
+
126
+ ```java
127
+ @WebMvcTest(UserController.class)
128
+ class UserControllerTest {
129
+
130
+ @Autowired private MockMvc mockMvc;
131
+ @MockBean private UserService userService;
132
+
133
+ @Test
134
+ void createUser_validInput_returns201() throws Exception {
135
+ var user = new UserDto(1L, "Alice", "alice@example.com");
136
+ when(userService.create(any())).thenReturn(user);
137
+
138
+ mockMvc.perform(post("/api/users")
139
+ .contentType(MediaType.APPLICATION_JSON)
140
+ .content("""
141
+ {"name": "Alice", "email": "alice@example.com"}
142
+ """))
143
+ .andExpect(status().isCreated())
144
+ .andExpect(jsonPath("$.name").value("Alice"));
145
+ }
146
+
147
+ @Test
148
+ void createUser_invalidEmail_returns400() throws Exception {
149
+ mockMvc.perform(post("/api/users")
150
+ .contentType(MediaType.APPLICATION_JSON)
151
+ .content("""
152
+ {"name": "Alice", "email": "not-an-email"}
153
+ """))
154
+ .andExpect(status().isBadRequest());
155
+ }
156
+ }
157
+ ```
158
+
159
+ ## Phase 4: Security Scan
160
+
161
+ ```bash
162
+ # Dependency CVEs
163
+ mvn org.owasp:dependency-check-maven:check
164
+ # or
165
+ ./gradlew dependencyCheckAnalyze
166
+
167
+ # Secrets in source
168
+ grep -rn "password\s*=\s*\"" src/ --include="*.java" --include="*.yml" --include="*.properties"
169
+ grep -rn "sk-\|api_key\|secret" src/ --include="*.java" --include="*.yml"
170
+
171
+ # Secrets (git history)
172
+ git secrets --scan # if configured
173
+ ```
174
+
175
+ ### Common Security Findings
176
+
177
+ ```
178
+ # Check for System.out.println (use logger instead)
179
+ grep -rn "System\.out\.print" src/main/ --include="*.java"
180
+
181
+ # Check for raw exception messages in responses
182
+ grep -rn "e\.getMessage()" src/main/ --include="*.java"
183
+
184
+ # Check for wildcard CORS
185
+ grep -rn "allowedOrigins.*\*" src/main/ --include="*.java"
186
+ ```
187
+
188
+ ## Phase 5: Lint/Format (optional gate)
189
+
190
+ ```bash
191
+ mvn spotless:apply # if using Spotless plugin
192
+ ./gradlew spotlessApply
193
+ ```
194
+
195
+ ## Phase 6: Diff Review
196
+
197
+ ```bash
198
+ git diff --stat
199
+ git diff
200
+ ```
201
+
202
+ Checklist:
203
+ - No debugging logs left (`System.out`, `log.debug` without guards)
204
+ - Meaningful errors and HTTP statuses
205
+ - Transactions and validation present where needed
206
+ - Config changes documented
207
+
208
+ ## Output Template
209
+
210
+ ```
211
+ VERIFICATION REPORT
212
+ ===================
213
+ Build: [PASS/FAIL]
214
+ Static: [PASS/FAIL] (spotbugs/pmd/checkstyle)
215
+ Tests: [PASS/FAIL] (X/Y passed, Z% coverage)
216
+ Security: [PASS/FAIL] (CVE findings: N)
217
+ Diff: [X files changed]
218
+
219
+ Overall: [READY / NOT READY]
220
+
221
+ Issues to Fix:
222
+ 1. ...
223
+ 2. ...
224
+ ```
225
+
226
+ ## Continuous Mode
227
+
228
+ - Re-run phases on significant changes or every 30–60 minutes in long sessions
229
+ - Keep a short loop: `mvn -T 4 test` + spotbugs for quick feedback
230
+
231
+ **Remember**: Fast feedback beats late surprises. Keep the gate strict—treat warnings as defects in production systems.
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": "affaan-m/everything-claude-code",
3
+ "sourceType": "git",
4
+ "repoUrl": "https://github.com/affaan-m/everything-claude-code",
5
+ "subpath": "skills/strategic-compact",
6
+ "installedAt": "2026-04-16T03:02:37.208Z"
7
+ }
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: strategic-compact
3
+ description: Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.
4
+ origin: ECC
5
+ ---
6
+
7
+ # Strategic Compact Skill
8
+
9
+ Suggests manual `/compact` at strategic points in your workflow rather than relying on arbitrary auto-compaction.
10
+
11
+ ## When to Activate
12
+
13
+ - Running long sessions that approach context limits (200K+ tokens)
14
+ - Working on multi-phase tasks (research → plan → implement → test)
15
+ - Switching between unrelated tasks within the same session
16
+ - After completing a major milestone and starting new work
17
+ - When responses slow down or become less coherent (context pressure)
18
+
19
+ ## Why Strategic Compaction?
20
+
21
+ Auto-compaction triggers at arbitrary points:
22
+ - Often mid-task, losing important context
23
+ - No awareness of logical task boundaries
24
+ - Can interrupt complex multi-step operations
25
+
26
+ Strategic compaction at logical boundaries:
27
+ - **After exploration, before execution** — Compact research context, keep implementation plan
28
+ - **After completing a milestone** — Fresh start for next phase
29
+ - **Before major context shifts** — Clear exploration context before different task
30
+
31
+ ## How It Works
32
+
33
+ The `suggest-compact.js` script runs on PreToolUse (Edit/Write) and:
34
+
35
+ 1. **Tracks tool calls** — Counts tool invocations in session
36
+ 2. **Threshold detection** — Suggests at configurable threshold (default: 50 calls)
37
+ 3. **Periodic reminders** — Reminds every 25 calls after threshold
38
+
39
+ ## Hook Setup
40
+
41
+ Add to your `~/.claude/settings.json`:
42
+
43
+ ```json
44
+ {
45
+ "hooks": {
46
+ "PreToolUse": [
47
+ {
48
+ "matcher": "Edit",
49
+ "hooks": [{ "type": "command", "command": "node ~/.claude/scripts/hooks/suggest-compact.js" }]
50
+ },
51
+ {
52
+ "matcher": "Write",
53
+ "hooks": [{ "type": "command", "command": "node ~/.claude/scripts/hooks/suggest-compact.js" }]
54
+ }
55
+ ]
56
+ }
57
+ }
58
+ ```
59
+
60
+ ## Configuration
61
+
62
+ Environment variables:
63
+ - `COMPACT_THRESHOLD` — Tool calls before first suggestion (default: 50)
64
+
65
+ ## Compaction Decision Guide
66
+
67
+ Use this table to decide when to compact:
68
+
69
+ | Phase Transition | Compact? | Why |
70
+ |-----------------|----------|-----|
71
+ | Research → Planning | Yes | Research context is bulky; plan is the distilled output |
72
+ | Planning → Implementation | Yes | Plan is in TodoWrite or a file; free up context for code |
73
+ | Implementation → Testing | Maybe | Keep if tests reference recent code; compact if switching focus |
74
+ | Debugging → Next feature | Yes | Debug traces pollute context for unrelated work |
75
+ | Mid-implementation | No | Losing variable names, file paths, and partial state is costly |
76
+ | After a failed approach | Yes | Clear the dead-end reasoning before trying a new approach |
77
+
78
+ ## What Survives Compaction
79
+
80
+ Understanding what persists helps you compact with confidence:
81
+
82
+ | Persists | Lost |
83
+ |----------|------|
84
+ | CLAUDE.md instructions | Intermediate reasoning and analysis |
85
+ | TodoWrite task list | File contents you previously read |
86
+ | Memory files (`~/.claude/memory/`) | Multi-step conversation context |
87
+ | Git state (commits, branches) | Tool call history and counts |
88
+ | Files on disk | Nuanced user preferences stated verbally |
89
+
90
+ ## Best Practices
91
+
92
+ 1. **Compact after planning** — Once plan is finalized in TodoWrite, compact to start fresh
93
+ 2. **Compact after debugging** — Clear error-resolution context before continuing
94
+ 3. **Don't compact mid-implementation** — Preserve context for related changes
95
+ 4. **Read the suggestion** — The hook tells you *when*, you decide *if*
96
+ 5. **Write before compacting** — Save important context to files or memory before compacting
97
+ 6. **Use `/compact` with a summary** — Add a custom message: `/compact Focus on implementing auth middleware next`
98
+
99
+ ## Token Optimization Patterns
100
+
101
+ ### Trigger-Table Lazy Loading
102
+ Instead of loading full skill content at session start, use a trigger table that maps keywords to skill paths. Skills load only when triggered, reducing baseline context by 50%+:
103
+
104
+ | Trigger | Skill | Load When |
105
+ |---------|-------|-----------|
106
+ | "test", "tdd", "coverage" | tdd-workflow | User mentions testing |
107
+ | "security", "auth", "xss" | security-review | Security-related work |
108
+ | "deploy", "ci/cd" | deployment-patterns | Deployment context |
109
+
110
+ ### Context Composition Awareness
111
+ Monitor what's consuming your context window:
112
+ - **CLAUDE.md files** — Always loaded, keep lean
113
+ - **Loaded skills** — Each skill adds 1-5K tokens
114
+ - **Conversation history** — Grows with each exchange
115
+ - **Tool results** — File reads, search results add bulk
116
+
117
+ ### Duplicate Instruction Detection
118
+ Common sources of duplicate context:
119
+ - Same rules in both `~/.claude/rules/` and project `.claude/rules/`
120
+ - Skills that repeat CLAUDE.md instructions
121
+ - Multiple skills covering overlapping domains
122
+
123
+ ### Context Optimization Tools
124
+ - `token-optimizer` MCP — Automated 95%+ token reduction via content deduplication
125
+ - `context-mode` — Context virtualization (315KB to 5.4KB demonstrated)
126
+
127
+ ## Related
128
+
129
+ - [The Longform Guide](https://x.com/affaanmustafa/status/2014040193557471352) — Token optimization section
130
+ - Memory persistence hooks — For state that survives compaction
131
+ - `continuous-learning` skill — Extracts patterns before session ends
@@ -0,0 +1,7 @@
1
+ interface:
2
+ display_name: "Strategic Compact"
3
+ short_description: "Context management via strategic compaction"
4
+ brand_color: "#14B8A6"
5
+ default_prompt: "Suggest task boundary compaction for context management"
6
+ policy:
7
+ allow_implicit_invocation: true
@@ -0,0 +1,54 @@
1
+ #!/bin/bash
2
+ # Strategic Compact Suggester
3
+ # Runs on PreToolUse or periodically to suggest manual compaction at logical intervals
4
+ #
5
+ # Why manual over auto-compact:
6
+ # - Auto-compact happens at arbitrary points, often mid-task
7
+ # - Strategic compacting preserves context through logical phases
8
+ # - Compact after exploration, before execution
9
+ # - Compact after completing a milestone, before starting next
10
+ #
11
+ # Hook config (in ~/.claude/settings.json):
12
+ # {
13
+ # "hooks": {
14
+ # "PreToolUse": [{
15
+ # "matcher": "Edit|Write",
16
+ # "hooks": [{
17
+ # "type": "command",
18
+ # "command": "~/.claude/skills/strategic-compact/suggest-compact.sh"
19
+ # }]
20
+ # }]
21
+ # }
22
+ # }
23
+ #
24
+ # Criteria for suggesting compact:
25
+ # - Session has been running for extended period
26
+ # - Large number of tool calls made
27
+ # - Transitioning from research/exploration to implementation
28
+ # - Plan has been finalized
29
+
30
+ # Track tool call count (increment in a temp file)
31
+ # Use CLAUDE_SESSION_ID for session-specific counter (not $$ which changes per invocation)
32
+ SESSION_ID="${CLAUDE_SESSION_ID:-${PPID:-default}}"
33
+ COUNTER_FILE="/tmp/claude-tool-count-${SESSION_ID}"
34
+ THRESHOLD=${COMPACT_THRESHOLD:-50}
35
+
36
+ # Initialize or increment counter
37
+ if [ -f "$COUNTER_FILE" ]; then
38
+ count=$(cat "$COUNTER_FILE")
39
+ count=$((count + 1))
40
+ echo "$count" > "$COUNTER_FILE"
41
+ else
42
+ echo "1" > "$COUNTER_FILE"
43
+ count=1
44
+ fi
45
+
46
+ # Suggest compact after threshold tool calls
47
+ if [ "$count" -eq "$THRESHOLD" ]; then
48
+ echo "[StrategicCompact] $THRESHOLD tool calls reached - consider /compact if transitioning phases" >&2
49
+ fi
50
+
51
+ # Suggest at regular intervals after threshold
52
+ if [ "$count" -gt "$THRESHOLD" ] && [ $((count % 25)) -eq 0 ]; then
53
+ echo "[StrategicCompact] $count tool calls - good checkpoint for /compact if context is stale" >&2
54
+ fi
@@ -0,0 +1,7 @@
1
+ {
2
+ "source": "affaan-m/everything-claude-code",
3
+ "sourceType": "git",
4
+ "repoUrl": "https://github.com/affaan-m/everything-claude-code",
5
+ "subpath": "skills/tdd-workflow",
6
+ "installedAt": "2026-04-16T03:02:38.367Z"
7
+ }