@uzysjung/agent-harness 26.83.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 (212) hide show
  1. package/LICENSE +21 -0
  2. package/README.ko.md +279 -0
  3. package/README.md +306 -0
  4. package/dist/chunk-SDVAM5JZ.js +775 -0
  5. package/dist/chunk-SDVAM5JZ.js.map +1 -0
  6. package/dist/index.js +5412 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/trust-tier-drift.js +67 -0
  9. package/dist/trust-tier-drift.js.map +1 -0
  10. package/package.json +53 -0
  11. package/scripts/prune-ecc.sh +310 -0
  12. package/templates/CLAUDE.md +86 -0
  13. package/templates/agents/build-error-resolver.md +114 -0
  14. package/templates/agents/code-reviewer.md +237 -0
  15. package/templates/agents/data-analyst.md +69 -0
  16. package/templates/agents/plan-checker.md +118 -0
  17. package/templates/agents/reviewer.md +128 -0
  18. package/templates/agents/security-reviewer.md +108 -0
  19. package/templates/agents/silent-failure-hunter.md +50 -0
  20. package/templates/agents/strategist.md +86 -0
  21. package/templates/antigravity/AGENTS.md.template +58 -0
  22. package/templates/codex/AGENTS.md.template +94 -0
  23. package/templates/codex/README.md +69 -0
  24. package/templates/codex/config.toml.template +108 -0
  25. package/templates/codex/hooks/README.md +40 -0
  26. package/templates/codex/hooks/gate-check.sh +7 -0
  27. package/templates/codex/hooks/hito-counter.sh +7 -0
  28. package/templates/codex/hooks/session-start.sh +7 -0
  29. package/templates/codex/hooks/uncommitted-check.sh +7 -0
  30. package/templates/codex/skills/uzys-build/SKILL.md +24 -0
  31. package/templates/codex/skills/uzys-plan/SKILL.md +24 -0
  32. package/templates/codex/skills/uzys-review/SKILL.md +24 -0
  33. package/templates/codex/skills/uzys-ship/SKILL.md +24 -0
  34. package/templates/codex/skills/uzys-spec/SKILL.md +28 -0
  35. package/templates/codex/skills/uzys-test/SKILL.md +24 -0
  36. package/templates/commands/ecc/checkpoint.md +32 -0
  37. package/templates/commands/ecc/e2e.md +105 -0
  38. package/templates/commands/ecc/eval.md +88 -0
  39. package/templates/commands/ecc/evolve.md +7 -0
  40. package/templates/commands/ecc/harness-audit.md +73 -0
  41. package/templates/commands/ecc/instinct-status.md +8 -0
  42. package/templates/commands/ecc/promote.md +10 -0
  43. package/templates/commands/ecc/security-scan.md +10 -0
  44. package/templates/commands/uzys/auto.md +190 -0
  45. package/templates/commands/uzys/build.md +42 -0
  46. package/templates/commands/uzys/plan.md +55 -0
  47. package/templates/commands/uzys/review.md +44 -0
  48. package/templates/commands/uzys/ship.md +49 -0
  49. package/templates/commands/uzys/spec.md +93 -0
  50. package/templates/commands/uzys/test.md +58 -0
  51. package/templates/docs/PLAN.template.md +102 -0
  52. package/templates/hooks/agentshield-gate.sh +101 -0
  53. package/templates/hooks/checkpoint-snapshot.sh +115 -0
  54. package/templates/hooks/gate-check.sh +138 -0
  55. package/templates/hooks/hito-counter.sh +26 -0
  56. package/templates/hooks/karpathy-gate.sh +59 -0
  57. package/templates/hooks/mcp-pre-exec.sh +104 -0
  58. package/templates/hooks/protect-files.sh +41 -0
  59. package/templates/hooks/session-start.sh +40 -0
  60. package/templates/hooks/spec-drift-check.sh +86 -0
  61. package/templates/mcp-allowlist.example +24 -0
  62. package/templates/mcp.json +20 -0
  63. package/templates/opencode/.opencode/commands/uzys-build.md +22 -0
  64. package/templates/opencode/.opencode/commands/uzys-plan.md +22 -0
  65. package/templates/opencode/.opencode/commands/uzys-review.md +22 -0
  66. package/templates/opencode/.opencode/commands/uzys-ship.md +22 -0
  67. package/templates/opencode/.opencode/commands/uzys-spec.md +28 -0
  68. package/templates/opencode/.opencode/commands/uzys-test.md +22 -0
  69. package/templates/opencode/.opencode/plugins/uzys-harness.ts +146 -0
  70. package/templates/opencode/AGENTS.md.template +98 -0
  71. package/templates/opencode/README.md +34 -0
  72. package/templates/opencode/opencode.json.template +42 -0
  73. package/templates/project-claude/_base.md +23 -0
  74. package/templates/project-claude/fragments/csr-fastapi/active-rules.md +13 -0
  75. package/templates/project-claude/fragments/csr-fastapi/agents.md +5 -0
  76. package/templates/project-claude/fragments/csr-fastapi/boundaries.md +18 -0
  77. package/templates/project-claude/fragments/csr-fastapi/commands.md +6 -0
  78. package/templates/project-claude/fragments/csr-fastapi/plugins.md +2 -0
  79. package/templates/project-claude/fragments/csr-fastapi/skills.md +5 -0
  80. package/templates/project-claude/fragments/csr-fastapi/stack.md +6 -0
  81. package/templates/project-claude/fragments/csr-fastapi/tagline.md +1 -0
  82. package/templates/project-claude/fragments/csr-fastapi/workflow.md +8 -0
  83. package/templates/project-claude/fragments/csr-fastify/active-rules.md +13 -0
  84. package/templates/project-claude/fragments/csr-fastify/agents.md +5 -0
  85. package/templates/project-claude/fragments/csr-fastify/boundaries.md +18 -0
  86. package/templates/project-claude/fragments/csr-fastify/commands.md +6 -0
  87. package/templates/project-claude/fragments/csr-fastify/plugins.md +2 -0
  88. package/templates/project-claude/fragments/csr-fastify/skills.md +5 -0
  89. package/templates/project-claude/fragments/csr-fastify/stack.md +6 -0
  90. package/templates/project-claude/fragments/csr-fastify/tagline.md +1 -0
  91. package/templates/project-claude/fragments/csr-fastify/workflow.md +8 -0
  92. package/templates/project-claude/fragments/csr-supabase/active-rules.md +12 -0
  93. package/templates/project-claude/fragments/csr-supabase/agents.md +5 -0
  94. package/templates/project-claude/fragments/csr-supabase/boundaries.md +19 -0
  95. package/templates/project-claude/fragments/csr-supabase/commands.md +6 -0
  96. package/templates/project-claude/fragments/csr-supabase/plugins.md +4 -0
  97. package/templates/project-claude/fragments/csr-supabase/skills.md +7 -0
  98. package/templates/project-claude/fragments/csr-supabase/stack.md +6 -0
  99. package/templates/project-claude/fragments/csr-supabase/supabase-auth.md +21 -0
  100. package/templates/project-claude/fragments/csr-supabase/tagline.md +1 -0
  101. package/templates/project-claude/fragments/csr-supabase/workflow.md +8 -0
  102. package/templates/project-claude/fragments/data/active-rules.md +10 -0
  103. package/templates/project-claude/fragments/data/agents.md +6 -0
  104. package/templates/project-claude/fragments/data/boundaries.md +20 -0
  105. package/templates/project-claude/fragments/data/commands.md +6 -0
  106. package/templates/project-claude/fragments/data/plugins.md +2 -0
  107. package/templates/project-claude/fragments/data/skills.md +3 -0
  108. package/templates/project-claude/fragments/data/stack.md +7 -0
  109. package/templates/project-claude/fragments/data/tagline.md +1 -0
  110. package/templates/project-claude/fragments/data/workflow.md +9 -0
  111. package/templates/project-claude/fragments/executive/active-rules.md +6 -0
  112. package/templates/project-claude/fragments/executive/agents.md +6 -0
  113. package/templates/project-claude/fragments/executive/boundaries.md +17 -0
  114. package/templates/project-claude/fragments/executive/commands.md +11 -0
  115. package/templates/project-claude/fragments/executive/plugins.md +1 -0
  116. package/templates/project-claude/fragments/executive/skills.md +7 -0
  117. package/templates/project-claude/fragments/executive/stack.md +4 -0
  118. package/templates/project-claude/fragments/executive/tagline.md +1 -0
  119. package/templates/project-claude/fragments/executive/workflow.md +10 -0
  120. package/templates/project-claude/fragments/growth-marketing/active-rules.md +7 -0
  121. package/templates/project-claude/fragments/growth-marketing/agents.md +6 -0
  122. package/templates/project-claude/fragments/growth-marketing/boundaries.md +17 -0
  123. package/templates/project-claude/fragments/growth-marketing/commands.md +11 -0
  124. package/templates/project-claude/fragments/growth-marketing/plugins.md +9 -0
  125. package/templates/project-claude/fragments/growth-marketing/skills.md +8 -0
  126. package/templates/project-claude/fragments/growth-marketing/stack.md +7 -0
  127. package/templates/project-claude/fragments/growth-marketing/tagline.md +1 -0
  128. package/templates/project-claude/fragments/growth-marketing/workflow.md +11 -0
  129. package/templates/project-claude/fragments/project-management/active-rules.md +7 -0
  130. package/templates/project-claude/fragments/project-management/agents.md +6 -0
  131. package/templates/project-claude/fragments/project-management/boundaries.md +16 -0
  132. package/templates/project-claude/fragments/project-management/commands.md +10 -0
  133. package/templates/project-claude/fragments/project-management/plugins.md +6 -0
  134. package/templates/project-claude/fragments/project-management/skills.md +5 -0
  135. package/templates/project-claude/fragments/project-management/stack.md +4 -0
  136. package/templates/project-claude/fragments/project-management/tagline.md +1 -0
  137. package/templates/project-claude/fragments/project-management/workflow.md +12 -0
  138. package/templates/project-claude/fragments/ssr-htmx/active-rules.md +11 -0
  139. package/templates/project-claude/fragments/ssr-htmx/agents.md +5 -0
  140. package/templates/project-claude/fragments/ssr-htmx/boundaries.md +20 -0
  141. package/templates/project-claude/fragments/ssr-htmx/commands.md +6 -0
  142. package/templates/project-claude/fragments/ssr-htmx/plugins.md +2 -0
  143. package/templates/project-claude/fragments/ssr-htmx/skills.md +3 -0
  144. package/templates/project-claude/fragments/ssr-htmx/stack.md +6 -0
  145. package/templates/project-claude/fragments/ssr-htmx/tagline.md +1 -0
  146. package/templates/project-claude/fragments/ssr-htmx/workflow.md +8 -0
  147. package/templates/project-claude/fragments/ssr-nextjs/active-rules.md +12 -0
  148. package/templates/project-claude/fragments/ssr-nextjs/agents.md +5 -0
  149. package/templates/project-claude/fragments/ssr-nextjs/boundaries.md +20 -0
  150. package/templates/project-claude/fragments/ssr-nextjs/commands.md +6 -0
  151. package/templates/project-claude/fragments/ssr-nextjs/plugins.md +2 -0
  152. package/templates/project-claude/fragments/ssr-nextjs/skills.md +5 -0
  153. package/templates/project-claude/fragments/ssr-nextjs/stack.md +5 -0
  154. package/templates/project-claude/fragments/ssr-nextjs/tagline.md +1 -0
  155. package/templates/project-claude/fragments/ssr-nextjs/workflow.md +8 -0
  156. package/templates/project-claude/fragments/tooling/active-rules.md +11 -0
  157. package/templates/project-claude/fragments/tooling/agents.md +5 -0
  158. package/templates/project-claude/fragments/tooling/boundaries.md +17 -0
  159. package/templates/project-claude/fragments/tooling/commands.md +4 -0
  160. package/templates/project-claude/fragments/tooling/skills.md +4 -0
  161. package/templates/project-claude/fragments/tooling/stack.md +5 -0
  162. package/templates/project-claude/fragments/tooling/tagline.md +1 -0
  163. package/templates/project-claude/fragments/tooling/workflow.md +5 -0
  164. package/templates/rules/api-contract.md +33 -0
  165. package/templates/rules/change-management.md +80 -0
  166. package/templates/rules/cli-development.md +39 -0
  167. package/templates/rules/code-style.md +23 -0
  168. package/templates/rules/data-analysis.md +61 -0
  169. package/templates/rules/database.md +29 -0
  170. package/templates/rules/design-workflow.md +17 -0
  171. package/templates/rules/error-handling.md +23 -0
  172. package/templates/rules/gates-taxonomy.md +21 -0
  173. package/templates/rules/git-policy.md +102 -0
  174. package/templates/rules/htmx.md +42 -0
  175. package/templates/rules/nextjs.md +35 -0
  176. package/templates/rules/playwright-launch.md +66 -0
  177. package/templates/rules/pyside6.md +59 -0
  178. package/templates/rules/shadcn.md +33 -0
  179. package/templates/rules/ship-checklist.md +24 -0
  180. package/templates/rules/tauri.md +40 -0
  181. package/templates/rules/test-policy.md +62 -0
  182. package/templates/settings.json +71 -0
  183. package/templates/skills/agent-introspection-debugging/SKILL.md +153 -0
  184. package/templates/skills/continuous-learning-v2/SKILL.md +365 -0
  185. package/templates/skills/continuous-learning-v2/config.json +8 -0
  186. package/templates/skills/continuous-learning-v2/hooks/observe.sh +428 -0
  187. package/templates/skills/continuous-learning-v2/scripts/detect-project.sh +228 -0
  188. package/templates/skills/continuous-learning-v2/scripts/instinct-cli.py +1426 -0
  189. package/templates/skills/deep-research/SKILL.md +155 -0
  190. package/templates/skills/deep-research/agents/openai.yaml +7 -0
  191. package/templates/skills/e2e-testing/SKILL.md +326 -0
  192. package/templates/skills/e2e-testing/agents/openai.yaml +7 -0
  193. package/templates/skills/eval-harness/SKILL.md +279 -0
  194. package/templates/skills/eval-harness/agents/openai.yaml +7 -0
  195. package/templates/skills/gh-issue-workflow/ISSUE.template.md +58 -0
  196. package/templates/skills/gh-issue-workflow/SKILL.md +184 -0
  197. package/templates/skills/investor-materials/SKILL.md +96 -0
  198. package/templates/skills/investor-outreach/SKILL.md +91 -0
  199. package/templates/skills/market-research/SKILL.md +75 -0
  200. package/templates/skills/market-research/agents/openai.yaml +7 -0
  201. package/templates/skills/nextjs-turbopack/SKILL.md +44 -0
  202. package/templates/skills/north-star/NORTH_STAR.template.md +114 -0
  203. package/templates/skills/north-star/SKILL.md +103 -0
  204. package/templates/skills/python-patterns/SKILL.md +750 -0
  205. package/templates/skills/python-testing/SKILL.md +816 -0
  206. package/templates/skills/spec-scaling/SKILL.md +89 -0
  207. package/templates/skills/strategic-compact/SKILL.md +131 -0
  208. package/templates/skills/strategic-compact/suggest-compact.sh +54 -0
  209. package/templates/skills/ui-visual-review/SKILL.md +154 -0
  210. package/templates/skills/verification-loop/SKILL.md +126 -0
  211. package/templates/skills/verification-loop/agents/openai.yaml +7 -0
  212. package/templates/track-mcp-map.tsv +15 -0
@@ -0,0 +1,40 @@
1
+ # Tauri Rules
2
+
3
+ CSR Track에서 데스크탑/모바일 확장 시 적용. PRD에 데스크탑 요구사항이 있을 때만.
4
+
5
+ ## Structure
6
+
7
+ - Tauri 코드는 `src-tauri/` 에만 위치.
8
+ - 프론트엔드 ↔ Tauri IPC는 `src/lib/tauri.ts` 래퍼를 통해서만.
9
+ - 직접 `@tauri-apps/api` import 금지 — 래퍼 사용.
10
+
11
+ ## IPC Pattern
12
+
13
+ ```typescript
14
+ // src/lib/tauri.ts
15
+ import { invoke } from '@tauri-apps/api/core';
16
+
17
+ export async function readConfig(): Promise<Config> {
18
+ return invoke<Config>('read_config');
19
+ }
20
+ ```
21
+
22
+ ## Feature Detection
23
+
24
+ ```typescript
25
+ const isTauri = () => typeof window !== 'undefined' && '__TAURI__' in window;
26
+ ```
27
+
28
+ 웹과 데스크탑 모두에서 동작해야 할 때 feature detection 사용.
29
+
30
+ ## Build
31
+
32
+ - `cargo tauri dev` — 개발 모드
33
+ - `cargo tauri build` — 프로덕션 빌드
34
+ - 빌드 전 프론트엔드 빌드가 먼저 완료되어야 함.
35
+
36
+ ## Security
37
+
38
+ - Tauri의 capability 시스템으로 최소 권한 부여.
39
+ - 파일 시스템 접근은 명시적으로 허용된 경로만.
40
+ - IPC 핸들러에서 사용자 입력 검증 필수.
@@ -0,0 +1,62 @@
1
+ # Test Policy
2
+
3
+ ## Coverage Thresholds (Track-Specific)
4
+
5
+ | 영역 | 최소 커버리지 | 적용 Track |
6
+ |------|-------------|-----------|
7
+ | UI 컴포넌트 | 60% | csr-*, ssr-* |
8
+ | API 엔드포인트 | 80% | csr-*, ssr-*, data |
9
+ | 비즈니스 로직 | 90% | 전체 개발 Track |
10
+
11
+ ## Test Types (All Required)
12
+
13
+ 1. **Unit Tests** — 개별 함수, 유틸리티, 컴포넌트
14
+ 2. **Integration Tests** — API 엔드포인트, DB 연동
15
+ 3. **E2E Tests** — 핵심 사용자 흐름 (Ship 단계 필수)
16
+
17
+ ## Dev-Prod Parity (필수)
18
+
19
+ 개발/테스트 DB 엔진은 Prod와 **동일**해야 한다. Prod가 Postgres면 테스트도 Postgres (testcontainer 또는 docker-compose). SQLite 대체 금지 — CI 속도/편의는 근거가 아니다. 구체적 설정은 test-driven-development 스킬 참조.
20
+
21
+ ## TDD Workflow (Mandatory)
22
+
23
+ ```
24
+ 1. RED — 실패하는 테스트 먼저 작성
25
+ 2. GREEN — 테스트를 통과하는 최소 구현
26
+ 3. REFACTOR — 코드 개선 (테스트 유지)
27
+ 4. VERIFY — 커버리지 확인
28
+ ```
29
+
30
+ ## Test Structure (AAA Pattern)
31
+
32
+ ```python
33
+ def test_calculates_similarity():
34
+ # Arrange
35
+ vector1 = [1, 0, 0]
36
+ vector2 = [0, 1, 0]
37
+ # Act
38
+ result = calculate_cosine_similarity(vector1, vector2)
39
+ # Assert
40
+ assert result == 0
41
+ ```
42
+
43
+ ## Test Naming
44
+
45
+ 동작을 설명하는 이름:
46
+ - `test_returns_empty_array_when_no_markets_match_query`
47
+ - `test_throws_error_when_api_key_is_missing`
48
+ - `test_falls_back_to_substring_search_when_redis_unavailable`
49
+
50
+ ## Framework Mapping
51
+
52
+ | Stack | Unit/Integration | E2E |
53
+ |-------|-----------------|-----|
54
+ | Python (FastAPI) | pytest + pytest-asyncio + httpx | Playwright |
55
+ | TypeScript (React) | Vitest + React Testing Library | Playwright |
56
+ | Next.js | Vitest + RTL | Playwright |
57
+
58
+ ## Troubleshooting
59
+
60
+ 1. 테스트 격리 확인 (공유 상태 없는지)
61
+ 2. mock이 실제 동작과 일치하는지 확인
62
+ 3. 구현을 수정하라, 테스트를 수정하지 마라 (테스트가 틀린 경우 제외)
@@ -0,0 +1,71 @@
1
+ {
2
+ "_comment": "프로젝트 .claude/settings.json 템플릿. $CLAUDE_PROJECT_DIR 사용으로 절대 경로 제거. committable. 글로벌 ~/.claude/settings.json은 절대 건드리지 않음.",
3
+ "statusLine": {
4
+ "type": "command",
5
+ "command": "npx -y @owloops/claude-powerline@latest --style=tui"
6
+ },
7
+ "hooks": {
8
+ "SessionStart": [
9
+ {
10
+ "hooks": [
11
+ {
12
+ "type": "command",
13
+ "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/session-start.sh\""
14
+ }
15
+ ]
16
+ }
17
+ ],
18
+ "PreToolUse": [
19
+ {
20
+ "matcher": "Write|Edit",
21
+ "hooks": [
22
+ {
23
+ "type": "command",
24
+ "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/protect-files.sh\""
25
+ },
26
+ {
27
+ "type": "command",
28
+ "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/skills/strategic-compact/suggest-compact.sh\"",
29
+ "async": true,
30
+ "timeout": 5
31
+ }
32
+ ]
33
+ },
34
+ {
35
+ "matcher": "Skill",
36
+ "hooks": [
37
+ {
38
+ "type": "command",
39
+ "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/gate-check.sh\""
40
+ },
41
+ {
42
+ "type": "command",
43
+ "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/agentshield-gate.sh\""
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "matcher": "mcp__.*",
49
+ "hooks": [
50
+ {
51
+ "type": "command",
52
+ "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/mcp-pre-exec.sh\""
53
+ }
54
+ ]
55
+ }
56
+ ],
57
+ "PostToolUse": [],
58
+ "UserPromptSubmit": [
59
+ {
60
+ "hooks": [
61
+ {
62
+ "type": "command",
63
+ "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/hito-counter.sh\"",
64
+ "async": true,
65
+ "timeout": 2
66
+ }
67
+ ]
68
+ }
69
+ ]
70
+ }
71
+ }
@@ -0,0 +1,153 @@
1
+ ---
2
+ name: agent-introspection-debugging
3
+ description: Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports.
4
+ origin: ECC
5
+ ---
6
+
7
+ # Agent Introspection Debugging
8
+
9
+ Use this skill when an agent run is failing repeatedly, consuming tokens without progress, looping on the same tools, or drifting away from the intended task.
10
+
11
+ This is a workflow skill, not a hidden runtime. It teaches the agent to debug itself systematically before escalating to a human.
12
+
13
+ ## When to Activate
14
+
15
+ - Maximum tool call / loop-limit failures
16
+ - Repeated retries with no forward progress
17
+ - Context growth or prompt drift that starts degrading output quality
18
+ - File-system or environment state mismatch between expectation and reality
19
+ - Tool failures that are likely recoverable with diagnosis and a smaller corrective action
20
+
21
+ ## Scope Boundaries
22
+
23
+ Activate this skill for:
24
+ - capturing failure state before retrying blindly
25
+ - diagnosing common agent-specific failure patterns
26
+ - applying contained recovery actions
27
+ - producing a structured human-readable debug report
28
+
29
+ Do not use this skill as the primary source for:
30
+ - feature verification after code changes; use `verification-loop`
31
+ - framework-specific debugging when a narrower ECC skill already exists
32
+ - runtime promises the current harness cannot enforce automatically
33
+
34
+ ## Four-Phase Loop
35
+
36
+ ### Phase 1: Failure Capture
37
+
38
+ Before trying to recover, record the failure precisely.
39
+
40
+ Capture:
41
+ - error type, message, and stack trace when available
42
+ - last meaningful tool call sequence
43
+ - what the agent was trying to do
44
+ - current context pressure: repeated prompts, oversized pasted logs, duplicated plans, or runaway notes
45
+ - current environment assumptions: cwd, branch, relevant service state, expected files
46
+
47
+ Minimum capture template:
48
+
49
+ ```markdown
50
+ ## Failure Capture
51
+ - Session / task:
52
+ - Goal in progress:
53
+ - Error:
54
+ - Last successful step:
55
+ - Last failed tool / command:
56
+ - Repeated pattern seen:
57
+ - Environment assumptions to verify:
58
+ ```
59
+
60
+ ### Phase 2: Root-Cause Diagnosis
61
+
62
+ Match the failure to a known pattern before changing anything.
63
+
64
+ | Pattern | Likely Cause | Check |
65
+ | --- | --- | --- |
66
+ | Maximum tool calls / repeated same command | loop or no-exit observer path | inspect the last N tool calls for repetition |
67
+ | Context overflow / degraded reasoning | unbounded notes, repeated plans, oversized logs | inspect recent context for duplication and low-signal bulk |
68
+ | `ECONNREFUSED` / timeout | service unavailable or wrong port | verify service health, URL, and port assumptions |
69
+ | `429` / quota exhaustion | retry storm or missing backoff | count repeated calls and inspect retry spacing |
70
+ | file missing after write / stale diff | race, wrong cwd, or branch drift | re-check path, cwd, git status, and actual file existence |
71
+ | tests still failing after “fix” | wrong hypothesis | isolate the exact failing test and re-derive the bug |
72
+
73
+ Diagnosis questions:
74
+ - is this a logic failure, state failure, environment failure, or policy failure?
75
+ - did the agent lose the real objective and start optimizing the wrong subtask?
76
+ - is the failure deterministic or transient?
77
+ - what is the smallest reversible action that would validate the diagnosis?
78
+
79
+ ### Phase 3: Contained Recovery
80
+
81
+ Recover with the smallest action that changes the diagnosis surface.
82
+
83
+ Safe recovery actions:
84
+ - stop repeated retries and restate the hypothesis
85
+ - trim low-signal context and keep only the active goal, blockers, and evidence
86
+ - re-check the actual filesystem / branch / process state
87
+ - narrow the task to one failing command, one file, or one test
88
+ - switch from speculative reasoning to direct observation
89
+ - escalate to a human when the failure is high-risk or externally blocked
90
+
91
+ Do not claim unsupported auto-healing actions like “reset agent state” or “update harness config” unless you are actually doing them through real tools in the current environment.
92
+
93
+ Contained recovery checklist:
94
+
95
+ ```markdown
96
+ ## Recovery Action
97
+ - Diagnosis chosen:
98
+ - Smallest action taken:
99
+ - Why this is safe:
100
+ - What evidence would prove the fix worked:
101
+ ```
102
+
103
+ ### Phase 4: Introspection Report
104
+
105
+ End with a report that makes the recovery legible to the next agent or human.
106
+
107
+ ```markdown
108
+ ## Agent Self-Debug Report
109
+ - Session / task:
110
+ - Failure:
111
+ - Root cause:
112
+ - Recovery action:
113
+ - Result: success | partial | blocked
114
+ - Token / time burn risk:
115
+ - Follow-up needed:
116
+ - Preventive change to encode later:
117
+ ```
118
+
119
+ ## Recovery Heuristics
120
+
121
+ Prefer these interventions in order:
122
+
123
+ 1. Restate the real objective in one sentence.
124
+ 2. Verify the world state instead of trusting memory.
125
+ 3. Shrink the failing scope.
126
+ 4. Run one discriminating check.
127
+ 5. Only then retry.
128
+
129
+ Bad pattern:
130
+ - retrying the same action three times with slightly different wording
131
+
132
+ Good pattern:
133
+ - capture failure
134
+ - classify the pattern
135
+ - run one direct check
136
+ - change the plan only if the check supports it
137
+
138
+ ## Integration with ECC
139
+
140
+ - Use `verification-loop` after recovery if code was changed.
141
+ - Use `continuous-learning-v2` when the failure pattern is worth turning into an instinct or later skill.
142
+ - Use `council` when the issue is not technical failure but decision ambiguity.
143
+ - Use `workspace-surface-audit` if the failure came from conflicting local state or repo drift.
144
+
145
+ ## Output Standard
146
+
147
+ When this skill is active, do not end with “I fixed it” alone.
148
+
149
+ Always provide:
150
+ - the failure pattern
151
+ - the root-cause hypothesis
152
+ - the recovery action
153
+ - the evidence that the situation is now better or still blocked
@@ -0,0 +1,365 @@
1
+ ---
2
+ name: continuous-learning-v2
3
+ description: Instinct-based learning system that observes sessions via hooks, creates atomic instincts with confidence scoring, and evolves them into skills/commands/agents. v2.1 adds project-scoped instincts to prevent cross-project contamination.
4
+ origin: ECC
5
+ version: 2.1.0
6
+ ---
7
+
8
+ # Continuous Learning v2.1 - Instinct
9
+ -Based Architecture
10
+
11
+ An advanced learning system that turns your Claude Code sessions into reusable knowledge through atomic "instincts" - small learned behaviors with confidence scoring.
12
+
13
+ **v2.1** adds **project-scoped instincts** — React patterns stay in your React project, Python conventions stay in your Python project, and universal patterns (like "always validate input") are shared globally.
14
+
15
+ ## When to Activate
16
+
17
+ - Setting up automatic learning from Claude Code sessions
18
+ - Configuring instinct-based behavior extraction via hooks
19
+ - Tuning confidence thresholds for learned behaviors
20
+ - Reviewing, exporting, or importing instinct libraries
21
+ - Evolving instincts into full skills, commands, or agents
22
+ - Managing project-scoped vs global instincts
23
+ - Promoting instincts from project to global scope
24
+
25
+ ## What's New in v2.1
26
+
27
+ | Feature | v2.0 | v2.1 |
28
+ |---------|------|------|
29
+ | Storage | Global (~/.claude/homunculus/) | Project-scoped (projects/<hash>/) |
30
+ | Scope | All instincts apply everywhere | Project-scoped + global |
31
+ | Detection | None | git remote URL / repo path |
32
+ | Promotion | N/A | Project → global when seen in 2+ projects |
33
+ | Commands | 4 (status/evolve/export/import) | 6 (+promote/projects) |
34
+ | Cross-project | Contamination risk | Isolated by default |
35
+
36
+ ## What's New in v2 (vs v1)
37
+
38
+ | Feature | v1 | v2 |
39
+ |---------|----|----|
40
+ | Observation | Stop hook (session end) | PreToolUse/PostToolUse (100% reliable) |
41
+ | Analysis | Main context | Background agent (Haiku) |
42
+ | Granularity | Full skills | Atomic "instincts" |
43
+ | Confidence | None | 0.3-0.9 weighted |
44
+ | Evolution | Direct to skill | Instincts -> cluster -> skill/command/agent |
45
+ | Sharing | None | Export/import instincts |
46
+
47
+ ## The Instinct Model
48
+
49
+ An instinct is a small learned behavior:
50
+
51
+ ```yaml
52
+ ---
53
+ id: prefer-functional-style
54
+ trigger: "when writing new functions"
55
+ confidence: 0.7
56
+ domain: "code-style"
57
+ source: "session-observation"
58
+ scope: project
59
+ project_id: "a1b2c3d4e5f6"
60
+ project_name: "my-react-app"
61
+ ---
62
+
63
+ # Prefer Functional Style
64
+
65
+ ## Action
66
+ Use functional patterns over classes when appropriate.
67
+
68
+ ## Evidence
69
+ - Observed 5 instances of functional pattern preference
70
+ - User corrected class-based approach to functional on 2025-01-15
71
+ ```
72
+
73
+ **Properties:**
74
+ - **Atomic** -- one trigger, one action
75
+ - **Confidence-weighted** -- 0.3 = tentative, 0.9 = near certain
76
+ - **Domain-tagged** -- code-style, testing, git, debugging, workflow, etc.
77
+ - **Evidence-backed** -- tracks what observations created it
78
+ - **Scope-aware** -- `project` (default) or `global`
79
+
80
+ ## How It Works
81
+
82
+ ```
83
+ Session Activity (in a git repo)
84
+ |
85
+ | Hooks capture prompts + tool use (100% reliable)
86
+ | + detect project context (git remote / repo path)
87
+ v
88
+ +---------------------------------------------+
89
+ | projects/<project-hash>/observations.jsonl |
90
+ | (prompts, tool calls, outcomes, project) |
91
+ +---------------------------------------------+
92
+ |
93
+ | Observer agent reads (background, Haiku)
94
+ v
95
+ +---------------------------------------------+
96
+ | PATTERN DETECTION |
97
+ | * User corrections -> instinct |
98
+ | * Error resolutions -> instinct |
99
+ | * Repeated workflows -> instinct |
100
+ | * Scope decision: project or global? |
101
+ +---------------------------------------------+
102
+ |
103
+ | Creates/updates
104
+ v
105
+ +---------------------------------------------+
106
+ | projects/<project-hash>/instincts/personal/ |
107
+ | * prefer-functional.yaml (0.7) [project] |
108
+ | * use-react-hooks.yaml (0.9) [project] |
109
+ +---------------------------------------------+
110
+ | instincts/personal/ (GLOBAL) |
111
+ | * always-validate-input.yaml (0.85) [global]|
112
+ | * grep-before-edit.yaml (0.6) [global] |
113
+ +---------------------------------------------+
114
+ |
115
+ | /evolve clusters + /promote
116
+ v
117
+ +---------------------------------------------+
118
+ | projects/<hash>/evolved/ (project-scoped) |
119
+ | evolved/ (global) |
120
+ | * commands/new-feature.md |
121
+ | * skills/testing-workflow.md |
122
+ | * agents/refactor-specialist.md |
123
+ +---------------------------------------------+
124
+ ```
125
+
126
+ ## Project Detection
127
+
128
+ The system automatically detects your current project:
129
+
130
+ 1. **`CLAUDE_PROJECT_DIR` env var** (highest priority)
131
+ 2. **`git remote get-url origin`** -- hashed to create a portable project ID (same repo on different machines gets the same ID)
132
+ 3. **`git rev-parse --show-toplevel`** -- fallback using repo path (machine-specific)
133
+ 4. **Global fallback** -- if no project is detected, instincts go to global scope
134
+
135
+ Each project gets a 12-character hash ID (e.g., `a1b2c3d4e5f6`). A registry file at `~/.claude/homunculus/projects.json` maps IDs to human-readable names.
136
+
137
+ ## Quick Start
138
+
139
+ ### 1. Enable Observation Hooks
140
+
141
+ Add to your `~/.claude/settings.json`.
142
+
143
+ **If installed as a plugin** (recommended):
144
+
145
+ ```json
146
+ {
147
+ "hooks": {
148
+ "PreToolUse": [{
149
+ "matcher": "*",
150
+ "hooks": [{
151
+ "type": "command",
152
+ "command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh"
153
+ }]
154
+ }],
155
+ "PostToolUse": [{
156
+ "matcher": "*",
157
+ "hooks": [{
158
+ "type": "command",
159
+ "command": "${CLAUDE_PLUGIN_ROOT}/skills/continuous-learning-v2/hooks/observe.sh"
160
+ }]
161
+ }]
162
+ }
163
+ }
164
+ ```
165
+
166
+ **If installed manually** to `~/.claude/skills`:
167
+
168
+ ```json
169
+ {
170
+ "hooks": {
171
+ "PreToolUse": [{
172
+ "matcher": "*",
173
+ "hooks": [{
174
+ "type": "command",
175
+ "command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh"
176
+ }]
177
+ }],
178
+ "PostToolUse": [{
179
+ "matcher": "*",
180
+ "hooks": [{
181
+ "type": "command",
182
+ "command": "~/.claude/skills/continuous-learning-v2/hooks/observe.sh"
183
+ }]
184
+ }]
185
+ }
186
+ }
187
+ ```
188
+
189
+ ### 2. Initialize Directory Structure
190
+
191
+ The system creates directories automatically on first use, but you can also create them manually:
192
+
193
+ ```bash
194
+ # Global directories
195
+ mkdir -p ~/.claude/homunculus/{instincts/{personal,inherited},evolved/{agents,skills,commands},projects}
196
+
197
+ # Project directories are auto-created when the hook first runs in a git repo
198
+ ```
199
+
200
+ ### 3. Use the Instinct Commands
201
+
202
+ ```bash
203
+ /instinct-status # Show learned instincts (project + global)
204
+ /evolve # Cluster related instincts into skills/commands
205
+ /instinct-export # Export instincts to file
206
+ /instinct-import # Import instincts from others
207
+ /promote # Promote project instincts to global scope
208
+ /projects # List all known projects and their instinct counts
209
+ ```
210
+
211
+ ## Commands
212
+
213
+ | Command | Description |
214
+ |---------|-------------|
215
+ | `/instinct-status` | Show all instincts (project-scoped + global) with confidence |
216
+ | `/evolve` | Cluster related instincts into skills/commands, suggest promotions |
217
+ | `/instinct-export` | Export instincts (filterable by scope/domain) |
218
+ | `/instinct-import <file>` | Import instincts with scope control |
219
+ | `/promote [id]` | Promote project instincts to global scope |
220
+ | `/projects` | List all known projects and their instinct counts |
221
+
222
+ ## Configuration
223
+
224
+ Edit `config.json` to control the background observer:
225
+
226
+ ```json
227
+ {
228
+ "version": "2.1",
229
+ "observer": {
230
+ "enabled": false,
231
+ "run_interval_minutes": 5,
232
+ "min_observations_to_analyze": 20
233
+ }
234
+ }
235
+ ```
236
+
237
+ | Key | Default | Description |
238
+ |-----|---------|-------------|
239
+ | `observer.enabled` | `false` | Enable the background observer agent |
240
+ | `observer.run_interval_minutes` | `5` | How often the observer analyzes observations |
241
+ | `observer.min_observations_to_analyze` | `20` | Minimum observations before analysis runs |
242
+
243
+ Other behavior (observation capture, instinct thresholds, project scoping, promotion criteria) is configured via code defaults in `instinct-cli.py` and `observe.sh`.
244
+
245
+ ## File Structure
246
+
247
+ ```
248
+ ~/.claude/homunculus/
249
+ +-- identity.json # Your profile, technical level
250
+ +-- projects.json # Registry: project hash -> name/path/remote
251
+ +-- observations.jsonl # Global observations (fallback)
252
+ +-- instincts/
253
+ | +-- personal/ # Global auto-learned instincts
254
+ | +-- inherited/ # Global imported instincts
255
+ +-- evolved/
256
+ | +-- agents/ # Global generated agents
257
+ | +-- skills/ # Global generated skills
258
+ | +-- commands/ # Global generated commands
259
+ +-- projects/
260
+ +-- a1b2c3d4e5f6/ # Project hash (from git remote URL)
261
+ | +-- project.json # Per-project metadata mirror (id/name/root/remote)
262
+ | +-- observations.jsonl
263
+ | +-- observations.archive/
264
+ | +-- instincts/
265
+ | | +-- personal/ # Project-specific auto-learned
266
+ | | +-- inherited/ # Project-specific imported
267
+ | +-- evolved/
268
+ | +-- skills/
269
+ | +-- commands/
270
+ | +-- agents/
271
+ +-- f6e5d4c3b2a1/ # Another project
272
+ +-- ...
273
+ ```
274
+
275
+ ## Scope Decision Guide
276
+
277
+ | Pattern Type | Scope | Examples |
278
+ |-------------|-------|---------|
279
+ | Language/framework conventions | **project** | "Use React hooks", "Follow Django REST patterns" |
280
+ | File structure preferences | **project** | "Tests in `__tests__`/", "Components in src/components/" |
281
+ | Code style | **project** | "Use functional style", "Prefer dataclasses" |
282
+ | Error handling strategies | **project** | "Use Result type for errors" |
283
+ | Security practices | **global** | "Validate user input", "Sanitize SQL" |
284
+ | General best practices | **global** | "Write tests first", "Always handle errors" |
285
+ | Tool workflow preferences | **global** | "Grep before Edit", "Read before Write" |
286
+ | Git practices | **global** | "Conventional commits", "Small focused commits" |
287
+
288
+ ## Instinct Promotion (Project -> Global)
289
+
290
+ When the same instinct appears in multiple projects with high confidence, it's a candidate for promotion to global scope.
291
+
292
+ **Auto-promotion criteria:**
293
+ - Same instinct ID in 2+ projects
294
+ - Average confidence >= 0.8
295
+
296
+ **How to promote:**
297
+
298
+ ```bash
299
+ # Promote a specific instinct
300
+ python3 instinct-cli.py promote prefer-explicit-errors
301
+
302
+ # Auto-promote all qualifying instincts
303
+ python3 instinct-cli.py promote
304
+
305
+ # Preview without changes
306
+ python3 instinct-cli.py promote --dry-run
307
+ ```
308
+
309
+ The `/evolve` command also suggests promotion candidates.
310
+
311
+ ## Confidence Scoring
312
+
313
+ Confidence evolves over time:
314
+
315
+ | Score | Meaning | Behavior |
316
+ |-------|---------|----------|
317
+ | 0.3 | Tentative | Suggested but not enforced |
318
+ | 0.5 | Moderate | Applied when relevant |
319
+ | 0.7 | Strong | Auto-approved for application |
320
+ | 0.9 | Near-certain | Core behavior |
321
+
322
+ **Confidence increases** when:
323
+ - Pattern is repeatedly observed
324
+ - User doesn't correct the suggested behavior
325
+ - Similar instincts from other sources agree
326
+
327
+ **Confidence decreases** when:
328
+ - User explicitly corrects the behavior
329
+ - Pattern isn't observed for extended periods
330
+ - Contradicting evidence appears
331
+
332
+ ## Why Hooks vs Skills for Observation?
333
+
334
+ > "v1 relied on skills to observe. Skills are probabilistic -- they fire ~50-80% of the time based on Claude's judgment."
335
+
336
+ Hooks fire **100% of the time**, deterministically. This means:
337
+ - Every tool call is observed
338
+ - No patterns are missed
339
+ - Learning is comprehensive
340
+
341
+ ## Backward Compatibility
342
+
343
+ v2.1 is fully compatible with v2.0 and v1:
344
+ - Existing global instincts in `~/.claude/homunculus/instincts/` still work as global instincts
345
+ - Existing `~/.claude/skills/learned/` skills from v1 still work
346
+ - Stop hook still runs (but now also feeds into v2)
347
+ - Gradual migration: run both in parallel
348
+
349
+ ## Privacy
350
+
351
+ - Observations stay **local** on your machine
352
+ - Project-scoped instincts are isolated per project
353
+ - Only **instincts** (patterns) can be exported — not raw observations
354
+ - No actual code or conversation content is shared
355
+ - You control what gets exported and promoted
356
+
357
+ ## Related
358
+
359
+ - [ECC-Tools GitHub App](https://github.com/apps/ecc-tools) - Generate instincts from repo history
360
+ - Homunculus - Community project that inspired the v2 instinct-based architecture (atomic observations, confidence scoring, instinct evolution pipeline)
361
+ - [The Longform Guide](https://x.com/affaanmustafa/status/2014040193557471352) - Continuous learning section
362
+
363
+ ---
364
+
365
+ *Instinct-based learning: teaching Claude your patterns, one project at a time.*
@@ -0,0 +1,8 @@
1
+ {
2
+ "version": "2.1",
3
+ "observer": {
4
+ "enabled": false,
5
+ "run_interval_minutes": 5,
6
+ "min_observations_to_analyze": 20
7
+ }
8
+ }