claude-dev-env 2.0.2 → 2.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 (88) hide show
  1. package/CLAUDE.md +1 -1
  2. package/hooks/blocking/CLAUDE.md +1 -0
  3. package/hooks/blocking/code_rules_shared.py +126 -47
  4. package/hooks/blocking/config/CLAUDE.md +2 -0
  5. package/hooks/blocking/config/verified_commit_context_constants.py +21 -0
  6. package/hooks/blocking/config/verified_commit_gate_output_constants.py +14 -0
  7. package/hooks/blocking/conftest.py +36 -30
  8. package/hooks/blocking/convergence_gate_blocker.py +76 -8
  9. package/hooks/blocking/plain_language_blocker.py +8 -0
  10. package/hooks/blocking/state_description_blocker.py +4 -1
  11. package/hooks/blocking/test_code_rules_shared.py +120 -20
  12. package/hooks/blocking/test_convergence_gate_blocker.py +146 -0
  13. package/hooks/blocking/test_plain_language_blocker.py +15 -0
  14. package/hooks/blocking/test_state_description_blocker.py +15 -0
  15. package/hooks/blocking/test_verified_commit_config_bootstrap.py +18 -0
  16. package/hooks/blocking/test_verified_commit_gate_additional_context.py +134 -0
  17. package/hooks/blocking/tests/test_verified_commit_gate.py +41 -0
  18. package/hooks/blocking/verified_commit_config_bootstrap.py +22 -10
  19. package/hooks/blocking/verified_commit_gate.py +113 -568
  20. package/hooks/blocking/verified_commit_gate_parts/CLAUDE.md +28 -0
  21. package/hooks/blocking/verified_commit_gate_parts/__init__.py +1 -0
  22. package/hooks/blocking/verified_commit_gate_parts/command_tokenization.py +174 -0
  23. package/hooks/blocking/verified_commit_gate_parts/deny_payload.py +53 -0
  24. package/hooks/blocking/verified_commit_gate_parts/deny_reason.py +80 -0
  25. package/hooks/blocking/verified_commit_gate_parts/directory_resolution.py +170 -0
  26. package/hooks/blocking/verified_commit_gate_parts/gated_invocations.py +205 -0
  27. package/hooks/blocking/verified_commit_gate_parts/tests/conftest.py +10 -0
  28. package/hooks/blocking/verified_commit_gate_parts/tests/test_command_tokenization.py +94 -0
  29. package/hooks/blocking/verified_commit_gate_parts/tests/test_deny_payload.py +17 -0
  30. package/hooks/blocking/verified_commit_gate_parts/tests/test_deny_reason.py +38 -0
  31. package/hooks/blocking/verified_commit_gate_parts/tests/test_directory_resolution.py +71 -0
  32. package/hooks/blocking/verified_commit_gate_parts/tests/test_gated_invocations.py +61 -0
  33. package/hooks/hooks_constants/CLAUDE.md +4 -1
  34. package/hooks/hooks_constants/code_rules_path_utils_constants.py +1 -0
  35. package/hooks/hooks_constants/convergence_gate_blocker_constants.py +36 -0
  36. package/hooks/hooks_constants/harness_scratchpad_constants.py +10 -9
  37. package/hooks/hooks_constants/mypy_integration_constants.py +16 -0
  38. package/hooks/validators/mypy_integration.py +145 -24
  39. package/hooks/validators/python_antipattern_checks.py +16 -0
  40. package/hooks/validators/run_all_validators.py +9 -3
  41. package/hooks/validators/test_mypy_integration.py +154 -0
  42. package/hooks/validators/test_python_antipattern_checks.py +112 -1
  43. package/hooks/validators/test_run_all_validators_pretooluse.py +16 -0
  44. package/package.json +1 -1
  45. package/rules/CLAUDE.md +1 -0
  46. package/rules/verified-commit-gate-skip.md +28 -0
  47. package/skills/auditing-claude-config/CLAUDE.md +2 -1
  48. package/skills/auditing-claude-config/SKILL.md +114 -176
  49. package/skills/auditing-claude-config/reference/probe-hook.md +74 -0
  50. package/skills/autoconverge/CLAUDE.md +1 -0
  51. package/skills/autoconverge/SKILL.md +310 -346
  52. package/skills/autoconverge/reference/CLAUDE.md +1 -0
  53. package/skills/autoconverge/reference/copilot-findings.md +51 -0
  54. package/skills/closeout/SKILL.md +7 -9
  55. package/skills/copilot-finding-triage/SKILL.md +5 -7
  56. package/skills/copilot-review/CLAUDE.md +3 -2
  57. package/skills/copilot-review/SKILL.md +119 -155
  58. package/skills/copilot-review/templates/subagent-prompt.md +49 -0
  59. package/skills/fresh-branch/CLAUDE.md +6 -9
  60. package/skills/fresh-branch/SKILL.md +84 -33
  61. package/skills/fresh-branch/scripts/create_fresh_branch.py +445 -0
  62. package/skills/fresh-branch/scripts/fresh_branch_scripts_constants/__init__.py +1 -0
  63. package/skills/fresh-branch/scripts/fresh_branch_scripts_constants/fresh_branch_cli_constants.py +74 -0
  64. package/skills/fresh-branch/scripts/test_create_fresh_branch.py +670 -0
  65. package/skills/pr-converge/SKILL.md +277 -422
  66. package/skills/pr-converge/reference/CLAUDE.md +1 -0
  67. package/skills/pr-converge/reference/progress-checklist.md +168 -0
  68. package/skills/pr-converge/test_step5_host_branch.py +8 -6
  69. package/skills/pr-loop-cloud-transport/SKILL.md +1 -1
  70. package/skills/privacy-hygiene/SKILL.md +68 -115
  71. package/skills/privacy-hygiene/reference/sweep-procedure.md +62 -0
  72. package/skills/session-log/CLAUDE.md +2 -1
  73. package/skills/session-log/SKILL.md +4 -26
  74. package/skills/session-log/templates/frontmatter.md +40 -0
  75. package/skills/skill-builder/CLAUDE.md +8 -7
  76. package/skills/skill-builder/SKILL.md +26 -11
  77. package/skills/skill-builder/references/CLAUDE.md +3 -1
  78. package/skills/skill-builder/references/delegation-map.md +21 -12
  79. package/skills/skill-builder/references/description-field.md +9 -11
  80. package/skills/skill-builder/references/deterministic-elements.md +218 -0
  81. package/skills/skill-builder/references/self-audit-checklist.md +62 -45
  82. package/skills/skill-builder/references/skill-modularity.md +8 -9
  83. package/skills/skill-builder/templates/CLAUDE.md +2 -2
  84. package/skills/skill-builder/templates/gap-analysis.md +15 -0
  85. package/skills/skill-builder/workflows/CLAUDE.md +5 -5
  86. package/skills/skill-builder/workflows/improve-skill.md +18 -9
  87. package/skills/skill-builder/workflows/new-skill.md +23 -15
  88. package/skills/skill-builder/workflows/polish-skill.md +28 -21
@@ -1,176 +1,114 @@
1
- ---
2
- name: auditing-claude-config
3
- description: >-
4
- Audits a Claude Code setup (user CLAUDE.md, ~/.claude/rules/, project .claude/) for
5
- context-budget waste — duplicate @-imports, always-on rules to path-scope or convert
6
- to skills, oversized files — and produces a migration table with savings. Use when
7
- reviewing the startup/instruction load, when /memory shows surprising loads, when
8
- adding new rules, or for periodic config hygiene.
9
- ---
10
-
11
- # Auditing Claude Config
12
-
13
- This skill audits what gets eagerly loaded into every Claude Code session and identifies wins — duplicate imports, lazy-load candidates, skill-conversion candidates, and pointer-shrink opportunities. It is grounded in three Anthropic docs cited at the bottom.
14
-
15
- ## When to invoke
16
-
17
- - `/memory` shows files the user did not expect to be loaded
18
- - The user is adding new rules and wants to know if the preload is growing past the recommended ceiling (CLAUDE.md target: under 200 lines)
19
- - Sessions feel sluggish or adherence to rules has degraded (the docs warn that bloated CLAUDE.md files cause Claude to ignore actual instructions)
20
- - A new template or shared `.claude/` directory has just been adopted
21
- - Periodic hygiene — quarterly is a reasonable cadence
22
-
23
- ## Background facts the audit relies on
24
-
25
- These come from the official Claude Code documentation; do not re-derive them.
26
-
27
- | Fact | Source phrasing |
28
- |---|---|
29
- | `@path` imports in CLAUDE.md and rules expand into context **at launch** — they are not pointers | "Imported files are expanded and loaded into context at launch alongside the CLAUDE.md that references them" |
30
- | Splitting into `@`-imports does **not** reduce context | "Splitting into `@path` imports helps organization but does not reduce context, since imported files load at launch" |
31
- | Files in `.claude/rules/` without `paths:` frontmatter load **every** session | "Rules without `paths` frontmatter are loaded unconditionally and apply to all files" |
32
- | Path-scoped rules load **lazily** when matching files are accessed | "Rules can be scoped to specific files using YAML frontmatter with the `paths` field. These conditional rules only apply when Claude is working with files matching the specified patterns" |
33
- | Skills preload **metadata only** | "At startup, only the metadata (name and description) from all Skills is pre-loaded. Claude reads SKILL.md only when the Skill becomes relevant, and reads additional files only as needed" |
34
- | `@`-imports inside fenced/inline code blocks do not trigger imports | Empirical (`InstructionsLoaded` hook): a bare `@`-import fires an `include` load event; the same path wrapped in backticks fires none, so the referenced file stays out of session-start context |
35
-
36
- ## Audit workflow
37
-
38
- ### Step 1 — Inventory the always-loaded set
39
-
40
- ```
41
- Files to count:
42
- ~/.claude/CLAUDE.md
43
- ~/.claude/CLAUDE.local.md (if present)
44
- ./CLAUDE.md (project root)
45
- ./.claude/CLAUDE.md (project alt)
46
- ./CLAUDE.local.md
47
- every file in ~/.claude/rules/ without `paths:` frontmatter
48
- every file in ./.claude/rules/ without `paths:` frontmatter
49
- every file referenced via @-import from any of the above (recursively, max depth 5)
50
- ```
51
-
52
- Count lines with `wc -l` (cygwin/Git Bash) or `Get-Content … | Measure-Object -Line` (PowerShell). Sum is the always-loaded line budget.
53
-
54
- Flag the result against the docs:
55
- - CLAUDE.md alone over 200 lines → strong nudge to slim
56
- - Total preload over ~1,000 lines → likely losing instruction adherence
57
-
58
- ### Step 2 — Find duplicate `@`-imports
59
-
60
- Search every always-loaded file (CLAUDE.md and every rule file without `paths:`) for `@`-references. Build a multimap of `imported_path → [referrer_path, ...]`. Any entry with two or more referrers is loading the import twice into context.
61
-
62
- Fix: delete the import from one of the parents (keep it in the file with the broader scope, typically CLAUDE.md).
63
-
64
- ### Step 3 — Classify each rule
65
-
66
- For every rule in `~/.claude/rules/` (and project `.claude/rules/`), apply this matrix:
67
-
68
- | Rule body describes | Verdict | Action |
69
- |---|---|---|
70
- | Behavior that applies every turn (TDD, conservative-action, ask-via-tool, etc.) | Keep always-on | No change |
71
- | File-type-specific patterns (Python idioms, JS/TS, Windows fs, test patterns) | Path-scope | Add `paths:` frontmatter with appropriate globs |
72
- | A multi-step workflow or procedure | Convert to skill | Move body to `~/.claude/skills/<name>/SKILL.md`, leave a 2-3 line pointer rule |
73
- | Content already covered by an existing skill in `~/.claude/skills/` | Shrink to pointer | Replace body with a 2-3 line reference to the skill |
74
- | Reference doc consumed only by one rule | Inline or co-locate | Move into the consumer rule or skill, drop the standalone doc |
75
-
76
- When suggesting `paths:` globs, derive them from the rule's body — do not guess. Examples:
77
- - Body discusses `shutil.rmtree`, `os.unlink` → `paths: ["**/*.py"]`
78
- - Body discusses `mkdirSync`, `fs.promises` → `paths: ["**/*.{mjs,js,ts}"]`
79
- - Body discusses pytest fixtures, test naming → `paths: ["**/test_*.py", "**/*_test.py", "**/conftest.py"]`
80
-
81
- ### Step 4 — Produce the migration table
82
-
83
- Output one table with these columns: `Rule | Lines today | Verdict | Specific action | Lines removed from preload`. Total the savings. Express as both an absolute line count and a percentage of step 1's baseline.
84
-
85
- ### Step 5 — Stage the changes
86
-
87
- Group recommendations by risk:
88
- - **Zero-risk:** duplicate-import deletion (largest single win in most setups)
89
- - **Low-risk:** adding `paths:` frontmatter (the docs guarantee fallback to "applies to all files" if syntax is wrong; verify with `/memory`)
90
- - **Medium-risk:** moving content into skills (changes when content reaches Claude — skill-discovery dependent)
91
- - **Author-required:** shrinking rules to pointers (requires deciding what content survives)
92
-
93
- ## Empirical verification (optional)
94
-
95
- If the audit's recommendations rest on assumptions about lazy-load behavior — especially `@`-imports nested inside path-scoped rules — install this probe hook to capture every `InstructionsLoaded` event.
96
-
97
- ### Hook script
98
-
99
- Path: `~/.claude/hooks/observability/instructions_loaded_logger.py`
100
-
101
- ```python
102
- #!/usr/bin/env python3
103
- import json
104
- import sys
105
- from datetime import datetime, timezone
106
- from pathlib import Path
107
-
108
-
109
- def main() -> int:
110
- log_path = Path.home() / ".claude" / "logs" / "instructions_loaded.jsonl"
111
- try:
112
- payload = json.load(sys.stdin)
113
- record = {
114
- "timestamp": datetime.now(timezone.utc).isoformat(),
115
- "file_path": payload.get("file_path"),
116
- "load_reason": payload.get("load_reason"),
117
- "memory_type": payload.get("memory_type"),
118
- "trigger_file_path": payload.get("trigger_file_path"),
119
- "parent_file_path": payload.get("parent_file_path"),
120
- "globs": payload.get("globs"),
121
- "session_id": payload.get("session_id"),
122
- }
123
- except Exception as exception:
124
- record = {
125
- "timestamp": datetime.now(timezone.utc).isoformat(),
126
- "error": str(exception),
127
- }
128
- try:
129
- log_path.parent.mkdir(parents=True, exist_ok=True)
130
- with log_path.open("a", encoding="utf-8") as log_file:
131
- log_file.write(json.dumps(record) + "\n")
132
- except OSError:
133
- pass
134
- return 0
135
-
136
-
137
- if __name__ == "__main__":
138
- raise SystemExit(main())
139
- ```
140
-
141
- ### settings.json registration
142
-
143
- Merge under `hooks.InstructionsLoaded` in `~/.claude/settings.json`:
144
-
145
- ```json
146
- {
147
- "matcher": "session_start|nested_traversal|path_glob_match|include|compact",
148
- "hooks": [
149
- {
150
- "type": "command",
151
- "command": "python ~/.claude/hooks/observability/instructions_loaded_logger.py"
152
- }
153
- ]
154
- }
155
- ```
156
-
157
- ### Test protocol
158
-
159
- 1. Start a fresh Claude Code session in a directory with no test files (`*.test.*`, `test_*.py`, etc.).
160
- 2. Read `~/.claude/logs/instructions_loaded.jsonl`. Every entry should have `load_reason: "session_start"` (plus any `nested_traversal` for ancestor CLAUDE.md files). Entries for path-scoped rules should be absent.
161
- 3. Open a `.test.tsx` (or `test_foo.py`) file. Re-read the log. New entries should have `load_reason: "path_glob_match"` for the rule itself, and `load_reason: "include"` (with `parent_file_path` pointing at the rule) for any `@`-imports nested inside it.
162
- 4. Acceptance: a rule classified as path-scoped does not appear in step 2 but does appear in step 3. Its nested imports follow the same pattern.
163
-
164
- ## Output format
165
-
166
- Always end an audit run with:
167
- 1. **Baseline:** total always-loaded lines today, broken down by file
168
- 2. **Findings:** the migration table from step 4
169
- 3. **Recommended next step:** the single highest-leverage change (usually duplicate-import deletion)
170
- 4. **Open questions:** anything not verified empirically
171
-
172
- ## Sources
173
-
174
- - [Claude Code — How Claude remembers your project](https://code.claude.com/docs/en/memory)
175
- - [Claude Code — Hooks (InstructionsLoaded)](https://code.claude.com/docs/en/hooks)
176
- - [Claude API — Skill authoring best practices](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/best-practices)
1
+ ---
2
+ name: auditing-claude-config
3
+ description: >-
4
+ Audits a Claude Code setup (user CLAUDE.md, ~/.claude/rules/, project .claude/) for
5
+ context-budget waste — duplicate @-imports, always-on rules to path-scope or convert
6
+ to skills, oversized files — and produces a migration table with savings. Use when
7
+ reviewing the startup/instruction load, when /memory shows surprising loads, when
8
+ adding new rules, or for periodic config hygiene.
9
+ ---
10
+
11
+ # Auditing Claude Config
12
+
13
+ This skill audits what gets eagerly loaded into every Claude Code session and identifies wins — duplicate imports, lazy-load candidates, skill-conversion candidates, and pointer-shrink opportunities. It is grounded in three Anthropic docs cited at the bottom.
14
+
15
+ ## When to invoke
16
+
17
+ - `/memory` shows files the user did not expect to be loaded
18
+ - The user is adding new rules and wants to know if the preload is growing past the recommended ceiling (CLAUDE.md target: under 200 lines)
19
+ - Sessions feel sluggish or adherence to rules has degraded (the docs warn that bloated CLAUDE.md files cause Claude to ignore actual instructions)
20
+ - A new template or shared `.claude/` directory has just been adopted
21
+ - Periodic hygiene — quarterly is a reasonable cadence
22
+
23
+ ## Background facts the audit relies on
24
+
25
+ These come from the official Claude Code documentation; do not re-derive them.
26
+
27
+ | Fact | Source phrasing |
28
+ |---|---|
29
+ | `@path` imports in CLAUDE.md and rules expand into context **at launch** — they are not pointers | "Imported files are expanded and loaded into context at launch alongside the CLAUDE.md that references them" |
30
+ | Splitting into `@`-imports does **not** reduce context | "Splitting into `@path` imports helps organization but does not reduce context, since imported files load at launch" |
31
+ | Files in `.claude/rules/` without `paths:` frontmatter load **every** session | "Rules without `paths` frontmatter are loaded unconditionally and apply to all files" |
32
+ | Path-scoped rules load **lazily** when matching files are accessed | "Rules can be scoped to specific files using YAML frontmatter with the `paths` field. These conditional rules only apply when Claude is working with files matching the specified patterns" |
33
+ | Skills preload **metadata only** | "At startup, only the metadata (name and description) from all Skills is pre-loaded. Claude reads SKILL.md only when the Skill becomes relevant, and reads additional files only as needed" |
34
+ | `@`-imports inside fenced/inline code blocks do not trigger imports | Empirical (verified in this skill's source session) referenced files alongside backtick-wrapped `@` paths do not appear in session-start context |
35
+
36
+ ## Audit workflow
37
+
38
+ ### Step 1 — Inventory the always-loaded set
39
+
40
+ ```
41
+ Files to count:
42
+ ~/.claude/CLAUDE.md
43
+ ~/.claude/CLAUDE.local.md (if present)
44
+ ./CLAUDE.md (project root)
45
+ ./.claude/CLAUDE.md (project alt)
46
+ ./CLAUDE.local.md
47
+ every file in ~/.claude/rules/ without `paths:` frontmatter
48
+ every file in ./.claude/rules/ without `paths:` frontmatter
49
+ every file referenced via @-import from any of the above (recursively, max depth 5)
50
+ ```
51
+
52
+ Count lines with `wc -l` (cygwin/Git Bash) or `Get-Content … | Measure-Object -Line` (PowerShell). Sum is the always-loaded line budget.
53
+
54
+ Flag the result against the docs:
55
+ - CLAUDE.md alone over 200 lines → strong nudge to slim
56
+ - Total preload over ~1,000 lines → likely losing instruction adherence
57
+
58
+ ### Step 2 — Find duplicate `@`-imports
59
+
60
+ Search every always-loaded file (CLAUDE.md and every rule file without `paths:`) for `@`-references. Build a multimap of `imported_path → [referrer_path, ...]`. Any entry with two or more referrers is loading the import twice into context.
61
+
62
+ Fix: delete the import from one of the parents (keep it in the file with the broader scope, typically CLAUDE.md).
63
+
64
+ ### Step 3 — Classify each rule
65
+
66
+ For every rule in `~/.claude/rules/` (and project `.claude/rules/`), apply this matrix:
67
+
68
+ | Rule body describes | Verdict | Action |
69
+ |---|---|---|
70
+ | Behavior that applies every turn (TDD, conservative-action, ask-via-tool, etc.) | Keep always-on | No change |
71
+ | File-type-specific patterns (Python idioms, JS/TS, Windows fs, test patterns) | Path-scope | Add `paths:` frontmatter with appropriate globs |
72
+ | A multi-step workflow or procedure | Convert to skill | Move body to `~/.claude/skills/<name>/SKILL.md`, leave a 2-3 line pointer rule |
73
+ | Content already covered by an existing skill in `~/.claude/skills/` | Shrink to pointer | Replace body with a 2-3 line reference to the skill |
74
+ | Reference doc consumed only by one rule | Inline or co-locate | Move into the consumer rule or skill, drop the standalone doc |
75
+
76
+ When suggesting `paths:` globs, derive them from the rule's body — do not guess. Examples:
77
+ - Body discusses `shutil.rmtree`, `os.unlink` → `paths: ["**/*.py"]`
78
+ - Body discusses `mkdirSync`, `fs.promises` → `paths: ["**/*.{mjs,js,ts}"]`
79
+ - Body discusses pytest fixtures, test naming → `paths: ["**/test_*.py", "**/*_test.py", "**/conftest.py"]`
80
+
81
+ ### Step 4 — Produce the migration table
82
+
83
+ Output one table with these columns: `Rule | Lines today | Verdict | Specific action | Lines removed from preload`. Total the savings. Express as both an absolute line count and a percentage of step 1's baseline.
84
+
85
+ ### Step 5 — Stage the changes
86
+
87
+ Group recommendations by risk:
88
+ - **Zero-risk:** duplicate-import deletion (largest single win in most setups)
89
+ - **Low-risk:** adding `paths:` frontmatter (the docs guarantee fallback to "applies to all files" if syntax is wrong; verify with `/memory`)
90
+ - **Medium-risk:** moving content into skills (changes when content reaches Claude — skill-discovery dependent)
91
+ - **Author-required:** shrinking rules to pointers (requires deciding what content survives)
92
+
93
+ ## Empirical verification (optional)
94
+
95
+ When the audit's recommendations rest on assumptions about lazy-load behavior —
96
+ especially `@`-imports nested inside path-scoped rules — install the probe hook
97
+ in [`reference/probe-hook.md`](reference/probe-hook.md) to capture every
98
+ `InstructionsLoaded` event. It carries the hook script, the `settings.json`
99
+ registration, and the test protocol that confirms a path-scoped rule loads
100
+ lazily while its nested imports follow.
101
+
102
+ ## Output format
103
+
104
+ Always end an audit run with:
105
+ 1. **Baseline:** total always-loaded lines today, broken down by file
106
+ 2. **Findings:** the migration table from step 4
107
+ 3. **Recommended next step:** the single highest-leverage change (usually duplicate-import deletion)
108
+ 4. **Open questions:** anything not verified empirically
109
+
110
+ ## Sources
111
+
112
+ - [Claude Code — How Claude remembers your project](https://code.claude.com/docs/en/memory)
113
+ - [Claude Code — Hooks (InstructionsLoaded)](https://code.claude.com/docs/en/hooks)
114
+ - [Claude API — Skill authoring best practices](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/best-practices)
@@ -0,0 +1,74 @@
1
+ # Lazy-load probe hook
2
+
3
+ Optional empirical check for the `auditing-claude-config` skill. When the audit's
4
+ recommendations rest on assumptions about lazy-load behavior — especially
5
+ `@`-imports nested inside path-scoped rules — install this probe hook to capture
6
+ every `InstructionsLoaded` event. The hub ([`../SKILL.md`](../SKILL.md) §
7
+ Empirical verification) points here.
8
+
9
+ ## Hook script
10
+
11
+ Path: `~/.claude/hooks/observability/instructions_loaded_logger.py`
12
+
13
+ ```python
14
+ #!/usr/bin/env python3
15
+ import json
16
+ import sys
17
+ from datetime import datetime, timezone
18
+ from pathlib import Path
19
+
20
+
21
+ def main() -> int:
22
+ log_path = Path.home() / ".claude" / "logs" / "instructions_loaded.jsonl"
23
+ try:
24
+ payload = json.load(sys.stdin)
25
+ record = {
26
+ "timestamp": datetime.now(timezone.utc).isoformat(),
27
+ "file_path": payload.get("file_path"),
28
+ "load_reason": payload.get("load_reason"),
29
+ "memory_type": payload.get("memory_type"),
30
+ "trigger_file_path": payload.get("trigger_file_path"),
31
+ "parent_file_path": payload.get("parent_file_path"),
32
+ "globs": payload.get("globs"),
33
+ "session_id": payload.get("session_id"),
34
+ }
35
+ except Exception as exception:
36
+ record = {
37
+ "timestamp": datetime.now(timezone.utc).isoformat(),
38
+ "error": str(exception),
39
+ }
40
+ try:
41
+ log_path.parent.mkdir(parents=True, exist_ok=True)
42
+ with log_path.open("a", encoding="utf-8") as log_file:
43
+ log_file.write(json.dumps(record) + "\n")
44
+ except OSError:
45
+ pass
46
+ return 0
47
+
48
+
49
+ if __name__ == "__main__":
50
+ raise SystemExit(main())
51
+ ```
52
+
53
+ ## settings.json registration
54
+
55
+ Merge under `hooks.InstructionsLoaded` in `~/.claude/settings.json`:
56
+
57
+ ```json
58
+ {
59
+ "matcher": "session_start|nested_traversal|path_glob_match|include|compact",
60
+ "hooks": [
61
+ {
62
+ "type": "command",
63
+ "command": "python ~/.claude/hooks/observability/instructions_loaded_logger.py"
64
+ }
65
+ ]
66
+ }
67
+ ```
68
+
69
+ ## Test protocol
70
+
71
+ 1. Start a fresh Claude Code session in a directory with no test files (`*.test.*`, `test_*.py`, etc.).
72
+ 2. Read `~/.claude/logs/instructions_loaded.jsonl`. Every entry should have `load_reason: "session_start"` (plus any `nested_traversal` for ancestor CLAUDE.md files). Entries for path-scoped rules should be absent.
73
+ 3. Open a `.test.tsx` (or `test_foo.py`) file. Re-read the log. New entries should have `load_reason: "path_glob_match"` for the rule itself, and `load_reason: "include"` (with `parent_file_path` pointing at the rule) for any `@`-imports nested inside it.
74
+ 4. Acceptance: a rule classified as path-scoped does not appear in step 2 but does appear in step 3. Its nested imports follow the same pattern.
@@ -21,6 +21,7 @@ Drives one draft PR to convergence in a single autonomous workflow run. Each rou
21
21
  | `workflow/convergence_summary.py` | Builds the convergence-summary agent prompt over the merged findings. |
22
22
  | `workflow/render_report.py` | Builds the closing HTML report from the merged journal and summary. |
23
23
  | `reference/convergence.md` | Round shape: the static sweep, the three parallel internal lenses, deduplication, fix commit, the terminal Bugbot, Copilot, and Codex gates, and the ready definition. |
24
+ | `reference/copilot-findings.md` | The Copilot gate tiering, per-finding verification, and the `userReview` return contract. |
24
25
  | `reference/stop-conditions.md` | Every way the run ends short of ready, including the budget stop. |
25
26
  | `reference/gotchas.md` | Hard-won failure lessons. |
26
27
  | `reference/closing-report.md` | The closing HTML report: data source, build steps, publishing. |