claude-dev-env 1.8.2 → 1.9.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.
@@ -3,8 +3,11 @@
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
+ import datetime
6
7
  import json
7
8
  import sys
9
+ from collections.abc import Callable
10
+ from pathlib import Path
8
11
 
9
12
  from prompt_workflow_gate_core import (
10
13
  find_ambiguous_scope_terms,
@@ -17,6 +20,8 @@ from prompt_workflow_gate_core import (
17
20
  missing_scope_anchors,
18
21
  )
19
22
 
23
+ PROMPT_GATE_LOG_PATH: Path = Path.home() / ".claude" / "logs" / "prompt-gate.log"
24
+ USER_FACING_PREFIX: str = "[prompt-gate]"
20
25
 
21
26
  def _extract_user_context(hook_input: dict) -> str:
22
27
  candidates = (
@@ -32,13 +37,114 @@ def _extract_user_context(hook_input: dict) -> str:
32
37
  return value
33
38
  return ""
34
39
 
35
-
36
- def _build_block(reason: str) -> dict:
40
+ def _append_diagnostic_to_log(brief_label: str, full_reason: str) -> None:
41
+ try:
42
+ PROMPT_GATE_LOG_PATH.parent.mkdir(parents=True, exist_ok=True)
43
+ timestamp_iso = datetime.datetime.now().isoformat()
44
+ log_entry = f"{timestamp_iso}\t{brief_label}\t{full_reason}\n"
45
+ with PROMPT_GATE_LOG_PATH.open("a", encoding="utf-8") as log_handle:
46
+ log_handle.write(log_entry)
47
+ except OSError:
48
+ pass
49
+
50
+ def _build_block(brief_label: str, full_reason: str) -> dict:
51
+ _append_diagnostic_to_log(brief_label, full_reason)
37
52
  return {
38
53
  "decision": "block",
39
- "reason": reason,
54
+ "reason": full_reason,
55
+ "systemMessage": f"{USER_FACING_PREFIX} {brief_label}",
56
+ "suppressOutput": True,
40
57
  }
41
58
 
59
+ def _check_internal_object_leak(
60
+ assistant_message: str,
61
+ debug_requested: bool,
62
+ ) -> dict | None:
63
+ if not has_internal_object_leak(assistant_message) or debug_requested:
64
+ return None
65
+ return _build_block(
66
+ brief_label="retrying: sanitize audit format",
67
+ full_reason=(
68
+ "PROMPT-WORKFLOW GATE: Raw internal refinement object leakage detected. "
69
+ "Return sanitized user-facing output unless explicit debug intent is present."
70
+ ),
71
+ )
72
+
73
+ def _check_checklist_container(assistant_message: str) -> dict | None:
74
+ if has_checklist_container(assistant_message):
75
+ return None
76
+ return _build_block(
77
+ brief_label="retrying: add checklist",
78
+ full_reason=(
79
+ "PROMPT-WORKFLOW GATE: Deterministic checklist container missing. "
80
+ "Include `checklist_results` with all required rows."
81
+ ),
82
+ )
83
+
84
+ def _check_missing_checklist_rows(assistant_message: str) -> dict | None:
85
+ missing_rows = missing_checklist_rows(assistant_message)
86
+ if not missing_rows:
87
+ return None
88
+ return _build_block(
89
+ brief_label="retrying: complete checklist",
90
+ full_reason=(
91
+ "PROMPT-WORKFLOW GATE: Deterministic checklist rows missing: "
92
+ + ", ".join(missing_rows)
93
+ ),
94
+ )
95
+
96
+ def _check_missing_scope_anchors(assistant_message: str) -> dict | None:
97
+ missing_anchors = missing_scope_anchors(assistant_message)
98
+ if not missing_anchors:
99
+ return None
100
+ return _build_block(
101
+ brief_label="retrying: add scope anchors",
102
+ full_reason=(
103
+ "PROMPT-WORKFLOW GATE: Required scope anchors missing: "
104
+ + ", ".join(missing_anchors)
105
+ ),
106
+ )
107
+
108
+ def _check_missing_context_signals(assistant_message: str) -> dict | None:
109
+ missing_signals = missing_context_control_signals(assistant_message)
110
+ if not missing_signals:
111
+ return None
112
+ return _build_block(
113
+ brief_label="retrying: add runtime signals",
114
+ full_reason=(
115
+ "PROMPT-WORKFLOW GATE: Runtime context-control preamble missing. "
116
+ "Include the two required lines from prompt-workflow-context-controls "
117
+ "(minimal instruction layer and on-demand skill loading)."
118
+ ),
119
+ )
120
+
121
+ def _check_ambiguous_scope(assistant_message: str) -> dict | None:
122
+ ambiguous_terms = find_ambiguous_scope_terms(assistant_message)
123
+ if not ambiguous_terms:
124
+ return None
125
+ return _build_block(
126
+ brief_label="retrying: rephrase scope refs",
127
+ full_reason=(
128
+ "PROMPT-WORKFLOW GATE: Ambiguous scope phrasing detected: "
129
+ + ", ".join(ambiguous_terms)
130
+ ),
131
+ )
132
+
133
+ def _evaluate_workflow_gates(assistant_message: str) -> dict | None:
134
+ if not is_prompt_workflow_response(assistant_message):
135
+ return None
136
+ workflow_gate_checks: tuple[Callable[[str], dict | None], ...] = (
137
+ _check_checklist_container,
138
+ _check_missing_checklist_rows,
139
+ _check_missing_scope_anchors,
140
+ _check_missing_context_signals,
141
+ _check_ambiguous_scope,
142
+ )
143
+ for check in workflow_gate_checks:
144
+ block = check(assistant_message)
145
+ if block is not None:
146
+ return block
147
+ return None
42
148
 
43
149
  def main() -> None:
44
150
  try:
@@ -53,79 +159,14 @@ def main() -> None:
53
159
  user_context = _extract_user_context(hook_input)
54
160
  debug_requested = has_debug_intent(user_context)
55
161
 
56
- if has_internal_object_leak(assistant_message) and not debug_requested:
57
- print(
58
- json.dumps(
59
- _build_block(
60
- "PROMPT-WORKFLOW GATE: Raw internal refinement object leakage detected. "
61
- "Return sanitized user-facing output unless explicit debug intent is present."
62
- )
63
- )
64
- )
65
- sys.exit(0)
162
+ block = _check_internal_object_leak(assistant_message, debug_requested)
163
+ if block is None:
164
+ block = _evaluate_workflow_gates(assistant_message)
66
165
 
67
- if is_prompt_workflow_response(assistant_message):
68
- if not has_checklist_container(assistant_message):
69
- print(
70
- json.dumps(
71
- _build_block(
72
- "PROMPT-WORKFLOW GATE: Deterministic checklist container missing. "
73
- "Include `checklist_results` with all required rows."
74
- )
75
- )
76
- )
77
- sys.exit(0)
78
-
79
- missing_rows = missing_checklist_rows(assistant_message)
80
- if missing_rows:
81
- print(
82
- json.dumps(
83
- _build_block(
84
- "PROMPT-WORKFLOW GATE: Deterministic checklist rows missing: "
85
- + ", ".join(missing_rows)
86
- )
87
- )
88
- )
89
- sys.exit(0)
90
-
91
- missing_anchors = missing_scope_anchors(assistant_message)
92
- if missing_anchors:
93
- print(
94
- json.dumps(
95
- _build_block(
96
- "PROMPT-WORKFLOW GATE: Required scope anchors missing: "
97
- + ", ".join(missing_anchors)
98
- )
99
- )
100
- )
101
- sys.exit(0)
102
-
103
- missing_context_signals = missing_context_control_signals(assistant_message)
104
- if missing_context_signals:
105
- print(
106
- json.dumps(
107
- _build_block(
108
- "PROMPT-WORKFLOW GATE: Runtime context-control signals missing: "
109
- + ", ".join(missing_context_signals)
110
- )
111
- )
112
- )
113
- sys.exit(0)
114
-
115
- ambiguous_terms = find_ambiguous_scope_terms(assistant_message)
116
- if ambiguous_terms:
117
- print(
118
- json.dumps(
119
- _build_block(
120
- "PROMPT-WORKFLOW GATE: Ambiguous scope phrasing detected: "
121
- + ", ".join(ambiguous_terms)
122
- )
123
- )
124
- )
125
- sys.exit(0)
166
+ if block is not None:
167
+ sys.stdout.write(json.dumps(block) + "\n")
126
168
 
127
169
  sys.exit(0)
128
170
 
129
-
130
171
  if __name__ == "__main__":
131
172
  main()
@@ -8,7 +8,6 @@ from pathlib import Path
8
8
 
9
9
  SCRIPT_PATH = Path(__file__).parent / "prompt-workflow-stop-guard.py"
10
10
 
11
-
12
11
  def _run_hook(payload: dict) -> subprocess.CompletedProcess[str]:
13
12
  return subprocess.run(
14
13
  [sys.executable, str(SCRIPT_PATH)],
@@ -18,7 +17,6 @@ def _run_hook(payload: dict) -> subprocess.CompletedProcess[str]:
18
17
  check=False,
19
18
  )
20
19
 
21
-
22
20
  def _full_checklist_rows() -> str:
23
21
  return (
24
22
  "checklist_results:\n"
@@ -38,7 +36,6 @@ def _full_checklist_rows() -> str:
38
36
  "- source_priority_rules_present\n"
39
37
  )
40
38
 
41
-
42
39
  def test_blocks_internal_object_leak_without_debug_intent() -> None:
43
40
  payload = {
44
41
  "last_assistant_message": '{"pipeline_mode": "internal_section_refinement_with_final_audit"}',
@@ -49,7 +46,6 @@ def test_blocks_internal_object_leak_without_debug_intent() -> None:
49
46
  assert response["decision"] == "block"
50
47
  assert "Raw internal refinement object leakage" in response["reason"]
51
48
 
52
-
53
49
  def test_allows_internal_object_with_debug_intent() -> None:
54
50
  payload = {
55
51
  "last_assistant_message": '{"pipeline_mode": "internal_section_refinement_with_final_audit"}',
@@ -58,7 +54,6 @@ def test_allows_internal_object_with_debug_intent() -> None:
58
54
  result = _run_hook(payload)
59
55
  assert result.stdout.strip() == ""
60
56
 
61
-
62
57
  def test_blocks_missing_checklist_rows() -> None:
63
58
  payload = {
64
59
  "last_assistant_message": "overall_status: pass\nchecklist_results: structured_scoped_instructions",
@@ -68,7 +63,6 @@ def test_blocks_missing_checklist_rows() -> None:
68
63
  assert response["decision"] == "block"
69
64
  assert "Deterministic checklist rows missing" in response["reason"]
70
65
 
71
-
72
66
  def test_blocks_missing_checklist_container_for_prompt_workflow_output() -> None:
73
67
  payload = {
74
68
  "last_assistant_message": (
@@ -87,7 +81,6 @@ def test_blocks_missing_checklist_container_for_prompt_workflow_output() -> None
87
81
  assert response["decision"] == "block"
88
82
  assert "Deterministic checklist container missing" in response["reason"]
89
83
 
90
-
91
84
  def test_blocks_missing_context_control_signals() -> None:
92
85
  payload = {
93
86
  "last_assistant_message": (
@@ -104,9 +97,8 @@ def test_blocks_missing_context_control_signals() -> None:
104
97
  result = _run_hook(payload)
105
98
  response = json.loads(result.stdout)
106
99
  assert response["decision"] == "block"
107
- assert "Runtime context-control signals missing" in response["reason"]
108
- assert "on_demand_skill_loading: true" in response["reason"]
109
-
100
+ assert "Runtime context-control preamble missing" in response["reason"]
101
+ assert "on-demand skill loading" in response["reason"]
110
102
 
111
103
  def test_blocks_ambiguous_scope_phrasing() -> None:
112
104
  payload = {
@@ -125,7 +117,6 @@ def test_blocks_ambiguous_scope_phrasing() -> None:
125
117
  assert response["decision"] == "block"
126
118
  assert "Ambiguous scope phrasing detected" in response["reason"]
127
119
 
128
-
129
120
  def test_allows_fully_structured_prompt_workflow_output() -> None:
130
121
  payload = {
131
122
  "last_assistant_message": (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-dev-env",
3
- "version": "1.8.2",
3
+ "version": "1.9.0",
4
4
  "description": "Claude Code development standards — rules, hooks, agents, commands, and skills",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,6 +17,8 @@ description: >-
17
17
 
18
18
  This skill produces prompt artifacts. It never performs the underlying task itself.
19
19
 
20
+ **Hook-survival invariant (read first):** The fenced prompt block is the primary deliverable and MUST survive Stop-hook retries. If a Stop hook rejects the response, only the surrounding audit summary and runtime signal scaffolding may change between retries — the prompt block itself MUST be re-emitted in full on every retry. Recovery pattern: re-emit the complete fenced prompt block first, then adjust the audit summary. Trimming, summarizing, or deferring the prompt artifact to satisfy a hook gate is forbidden.
21
+
20
22
  When this skill is active, your response contains exactly one of:
21
23
  1. **Clarifying questions** to gather information needed to write a better prompt (Step 3) -- then stop and wait.
22
24
  2. **The prompt artifact** in one or more fenced code blocks -- then stop.
@@ -83,8 +85,7 @@ Before drafting, define a concrete scope block with:
83
85
 
84
86
  Use this scope block as the grounding contract for all generated instructions.
85
87
  Express work in artifact-bound terms (paths, globs, comparisons, measurable completion checks).
86
- Treat all five keys as required: do not draft or refine until each key is populated with concrete values.
87
- If a scope key is missing, stop and request the missing value before continuing.
88
+ All five keys are required stop and request any missing value before drafting.
88
89
 
89
90
  ### 4. Build the prompt
90
91
 
@@ -98,7 +99,7 @@ Apply these principles (source: https://platform.claude.com/docs/en/build-with-c
98
99
 
99
100
  **Frame positively.** Anthropic: state the desired outcome directly. "Your response should be composed of smoothly flowing prose paragraphs" provides clearer guidance than a prohibition-only instruction.
100
101
 
101
- **Emotion-informed framing.** Anthropic's emotion concepts research (2026) found that internal activation patterns causally influence output quality. Five patterns apply to prompt design: (1) provide clear criteria and escape routes — the model produces better results when success criteria are explicit and "say so if you're unsure" is an accepted response; (2) use collaborative framing — collaborative language ("help figure out", "work on this together") activates engagement states that correlate with higher quality; (3) frame tasks with positive engagement — presenting tasks as interesting problems activates curiosity states; (4) invite transparency — include "say so if you're unsure" or placeholder notation so the model expresses uncertainty directly; (5) use constructive, forward-looking tone — post-training RLHF creates a reflective default that benefits from energetic counterbalancing. Cross-model caveat: studied on Sonnet 4.5; the patterns align with Anthropic's best practices independently.
102
+ **Emotion-informed framing.** Anthropic's emotion concepts research (2026) shows that internal activation patterns causally influence output quality. Apply: explicit success criteria with "say so if you're unsure" as an accepted answer; collaborative language ("help figure out", "work on this together"); framing tasks as interesting problems rather than chores; constructive, forward-looking tone. Cross-model caveat: studied on Sonnet 4.5; the patterns align with Anthropic's prompting best practices independently. Full pattern catalog and citations: `packages/claude-dev-env/docs/emotion-informed-prompt-design.md`.
102
103
 
103
104
  **Golden rule check.** Anthropic: "Show your prompt to a colleague with minimal context on the task and ask them to follow it. If they'd be confused, Claude will be too."
104
105
 
@@ -132,24 +133,16 @@ Anthropic notes Claude 4.6 is "more direct and grounded... less verbose: may ski
132
133
 
133
134
  Before delivering, verify against the rubric:
134
135
 
135
- - [ ] States desired behavior in positive terms
136
- - [ ] Output shape is specified if it matters (prose vs JSON vs XML vs structured outputs)
137
- - [ ] Communication style addressed (verbosity, summaries, preamble)
138
- - [ ] If tools exist: instructions tell Claude **when** to call each tool -- use natural phrasing ("Use this tool when...") over forceful directives to avoid overtriggering
139
- - [ ] No time-sensitive claims unless user asked for a snapshot date
140
- - [ ] For agent/tool prompts: includes a scope boundary ("Make requested changes and keep surrounding code stable")
141
- - [ ] For agent/tool prompts: includes autonomy/safety guidance (see pattern below)
142
- - [ ] For code/research prompts: includes grounding ("Read files before answering; say 'I don't know' when uncertain")
143
- - [ ] For research prompts: anti-hallucination ("Never speculate about code you have not opened")
144
- - [ ] For research prompts: structured approach ("Develop competing hypotheses, track confidence, self-critique")
145
- - [ ] Self-correction chain considered: would a generate-review-refine loop improve output?
146
- - [ ] For agentic prompts: state management addressed (context awareness, multi-window workflow, state tracking patterns)
147
- - [ ] Emotion-informed: uses collaborative framing (roles, motivation, partnership language)
148
- - [ ] Emotion-informed: includes permission to express uncertainty ("say so if unsure", placeholder notation)
149
- - [ ] Emotion-informed: proactive constraint awareness (inform about constraints upfront so the model can incorporate them into its plan)
150
- - [ ] For code prompts: includes anti-test-fixation ("Write general solutions, not code that only passes specific test cases; if tests seem wrong, flag them")
151
- - [ ] For agent prompts: includes temp file cleanup ("Clean up temporary files, scripts, or helper files created during the task")
152
- - [ ] For agent prompts: includes commit-and-execute pattern ("Choose an approach and commit; avoid revisiting decisions without new contradicting information")
136
+ - [ ] Output shape, communication style, and degree of freedom match the task (prose vs JSON vs XML, verbosity level, fragility-based specificity)
137
+ - [ ] Tool instructions use natural phrasing ("Use this tool when...") and tell Claude *when* to call each tool — no forceful directives that overtrigger
138
+ - [ ] Scope boundary and concrete artifact anchors are explicit; no time-sensitive claims unless the user asked for a snapshot date
139
+ - [ ] **Agent/tool prompts** include the autonomy/safety pattern, temp-file cleanup, and the commit-and-execute pattern
140
+ - [ ] **Code prompts** include grounding ("read files first; say 'I don't know' when uncertain") and anti-test-fixation (general solutions, flag bad tests)
141
+ - [ ] **Research prompts** include the structured-investigation pattern with competing hypotheses, confidence tracking, and self-critique
142
+ - [ ] **Agentic prompts** that span multiple context windows address state management (context awareness, multi-window workflow, structured state files)
143
+ - [ ] Emotion-informed framing is present: collaborative language, explicit success criteria, and explicit permission to express uncertainty ("say so if unsure")
144
+ - [ ] Constraints are surfaced upfront (proactive constraint awareness) so the model can incorporate them into its plan, and each non-obvious constraint carries its motivation
145
+ - [ ] Self-correction chaining is considered when the prompt must hold up over time (generate review refine)
153
146
 
154
147
  ### 9. Deliver
155
148
 
@@ -164,50 +157,64 @@ Use draft-only mode when the user explicitly requests it (for example: "just giv
164
157
  Fixed order:
165
158
 
166
159
  1. Base draft generation (this skill)
167
- 2. Section refinement (`role`)
168
- 3. Section refinement (`context`)
169
- 4. Section refinement (`instructions`)
170
- 5. Section refinement (`constraints`)
171
- 6. Section refinement (`output_format`)
172
- 7. Section refinement (`examples`)
173
- 8. Merge to one canonical prompt
174
- 9. Final audit pass/fail with evidence
175
- 10. If fail: targeted fixes + capped re-audit rounds
160
+ 2. Section refinement for each required section in order: `role`, `context`, `instructions`, `constraints`, `output_format`, `examples`
161
+ 3. Merge to one canonical prompt
162
+ 4. Final audit pass/fail with evidence
163
+ 5. If fail: targeted fixes + capped re-audit rounds
176
164
 
177
165
  Required section list is immutable for this pipeline: `role`, `context`, `instructions`, `constraints`, `output_format`, `examples`.
178
166
 
179
- ### 11. Internal refinement object format (required by default mode)
167
+ ### 11. User-facing audit shape and internal refinement object (default mode)
180
168
 
181
- When step 10 is active (default), build the refinement and audit state internally. Present the final merged prompt and a compact audit summary to the user. Keep the full internal object private unless the user explicitly asks for debug details.
169
+ When step 10 is active (default), build the refinement and audit state internally and present the user with the compact audit shape below — never the raw internal object. Reveal the internal object only when the user explicitly asks for debug details ("show debug", "show internal", "raw internal object", "pipeline object").
182
170
 
183
- **Default user-facing audit output (compact table):**
171
+ **Default user-facing audit emit exactly this shape:**
184
172
 
185
- ```
173
+ ```text
186
174
  **Audit: <overall_status>** | checklist_results: <pass_count>/14
187
175
 
188
- | Check | Status |
189
- |-------|--------|
190
- | structured_scoped_instructions | pass |
191
- | sequential_steps_present | pass |
192
- | positive_framing | pass |
193
- | acceptance_criteria_defined | pass |
194
- | safety_reversibility_language | pass |
195
- | no_destructive_shortcuts_guidance | pass |
196
- | concrete_output_contract | pass |
197
- | scope_boundary_present | pass |
198
- | explicit_scope_anchors_present | pass |
199
- | all_instructions_artifact_bound | pass |
200
- | no_ambiguous_scope_terms | pass |
201
- | completion_boundary_measurable | pass |
202
- | citation_grounding_policy_present | pass |
203
- | source_priority_rules_present | pass |
176
+ | Check | Status | Evidence |
177
+ |-----------------------------------|--------|------------------------------------------------|
178
+ | structured_scoped_instructions | pass | XML sections present in <instructions> |
179
+ | sequential_steps_present | pass | numbered steps inside <instructions> |
180
+ | positive_framing | pass | desired outcome stated directly in <role> |
181
+ | acceptance_criteria_defined | pass | <output_format> lists acceptance items |
182
+ | safety_reversibility_language | pass | reversibility note in <constraints> |
183
+ | no_destructive_shortcuts_guidance | pass | "no safety bypass" line in <constraints> |
184
+ | concrete_output_contract | pass | output schema fixed in <output_format> |
185
+ | scope_boundary_present | pass | "make requested changes only" in <constraints> |
186
+ | explicit_scope_anchors_present | pass | scope_block populated with five keys |
187
+ | all_instructions_artifact_bound | pass | every step references concrete paths or globs |
188
+ | no_ambiguous_scope_terms | pass | no positional or time-relative phrasing |
189
+ | completion_boundary_measurable | pass | comparison_basis and completion_boundary set |
190
+ | citation_grounding_policy_present | pass | source_refs cited per audited claim |
191
+ | source_priority_rules_present | pass | tier rules referenced in <constraints> |
192
+
193
+ Runtime signals: `base_minimal_instruction_layer: true` `on_demand_skill_loading: true`
194
+
195
+ scope_block:
196
+ - target_local_roots: [...]
197
+ - target_canonical_roots: [...]
198
+ - target_file_globs: [...]
199
+ - comparison_basis: ...
200
+ - completion_boundary: ...
201
+
202
+ Result: the refined prompt artifact for the <task name> refinement is ready for user review.
204
203
  ```
205
204
 
206
- Replace `<overall_status>` with `pass` or `fail`. Replace `<pass_count>` with the actual count. Replace each row's `pass` with `fail` where applicable.
205
+ Substitute real values for `<overall_status>`, `<pass_count>`, each row's `pass`/`fail`, the `scope_block` entries, and `<task name>`. Use one short evidence phrase per row. Append `execution_intent: explicit` after the runtime signals line when handing off to `/agent-prompt`. Refer to the prompt artifact by its position-independent identity (its role, purpose, or named scope) — avoid positional adverbs ("above", "below") and time-relative pointers ("just emitted", "the one I just sent"), because the hook flags them and because the audit must remain interpretable when re-rendered out of order.
206
+
207
+ **Do not emit in user-facing audits** (each item below trips a Stop-hook gate, with the reason it was added):
208
+
209
+ - Any `json` fenced code block — the internal-leak gate fires the moment one appears, because the only legitimate JSON in this skill is the debug-only object below.
210
+ - An opening `{` at the start of the audit — same gate, since it signals raw-object output.
211
+ - Internal-only object keys leaking into prose: `pipeline_mode`, `scope_block_validation`, `evidence_quotes`, `source_refs`, `corrective_edits`, `retry_count`, `audit_output_contract`, `section_output_contract`, `base_prompt_xml`, `required_sections`. They belong to the debug-only object below and nowhere else; the user-facing shape uses the column header `Evidence` and the named anchors instead.
207
212
 
208
- **Debug mode (full JSON, shown only when user requests debug details):**
213
+ **Hook-recovery contract:**
209
214
 
210
- When the user explicitly asks for debug details ("show debug", "show internal", "raw internal object", "pipeline object"), output the full internal object:
215
+ If a Stop hook rejects a user-facing audit, the next response must re-emit the complete fenced prompt artifact in full (per the Hook-survival invariant defined in the "Prompt-only output rule" section), then re-render the audit using this section's shape. Never trim the prompt block, the checklist, the runtime signals, or the scope anchors to satisfy a gate — fix the format, not the content.
216
+
217
+ **Debug-only internal object** (output only when the user explicitly asks for debug details):
211
218
 
212
219
  ```json
213
220
  {
@@ -249,36 +256,14 @@ When the user explicitly asks for debug details ("show debug", "show internal",
249
256
  }
250
257
  ```
251
258
 
252
- ### 12. Deterministic compliance checklist fields (audit reports all)
253
-
254
- If step 10 is active (default), the audit must evaluate all 14 fields below. Each row name must appear as a literal substring in the user-facing output (the compact table satisfies this).
255
-
256
- - `structured_scoped_instructions`
257
- - `sequential_steps_present`
258
- - `positive_framing`
259
- - `acceptance_criteria_defined`
260
- - `safety_reversibility_language`
261
- - `no_destructive_shortcuts_guidance`
262
- - `concrete_output_contract`
263
- - `scope_boundary_present`
264
- - `explicit_scope_anchors_present`
265
- - `all_instructions_artifact_bound`
266
- - `no_ambiguous_scope_terms`
267
- - `completion_boundary_measurable`
268
- - `citation_grounding_policy_present`
269
- - `source_priority_rules_present`
270
-
271
- For each checklist row, maintain internally:
272
- - `status`: `pass|fail`
273
- - `evidence_quote`: exact quote used for verification
274
- - `source_ref`: URL or local path
275
- - `fix_if_fail`: concrete edit text (empty only if pass)
276
-
277
- The compact table (step 11) shows `status` per row. The `evidence_quote`, `source_ref`, and `fix_if_fail` fields are internal-only and appear only in debug mode.
278
-
279
- Scope quality rule for generated prompts:
259
+ ### 12. Per-row internal audit contract
260
+
261
+ Step 11's user-facing template enumerates the 14 checklist row names. For each row, maintain the four fields defined in the debug-only internal object in Step 11 (`status`, `evidence_quote`, `source_ref`, `fix_if_fail`). The compact table surfaces `status` and a one-phrase `Evidence` summary derived from `evidence_quote`. The remaining fields stay in the debug-only object and surface only when the user explicitly asks for debug details.
262
+
263
+ **Scope quality rule for generated prompts:**
264
+
280
265
  - Bind every major instruction to explicit artifacts from the scope block.
281
- - Prefer concrete references (paths/globs/comparisons) over context-relative wording.
266
+ - Prefer concrete references (paths, globs, comparisons) over context-relative wording.
282
267
 
283
268
  ### 13. Source anchors for pipeline requirements
284
269
 
@@ -311,7 +296,6 @@ User-facing sequence:
311
296
  Execution-intent rule:
312
297
  - Treat `/prompt-generator` outputs as prompt artifacts.
313
298
  - Transition to `/agent-prompt` only after explicit execution/delegation intent from the user.
314
- - For execution handoff metadata, include `execution_intent: explicit`.
315
299
 
316
300
  ### 16. Context-footprint controls (low-context default)
317
301
 
@@ -331,8 +315,8 @@ When generating prompts for current Claude models, apply these patterns:
331
315
  - **Adaptive thinking replaces budget_tokens:** Claude 4.6 uses adaptive thinking (thinking: {type: "adaptive"}) where the model dynamically decides when and how much to think. Use the effort parameter (low | medium | high | max) to control depth. Anthropic: "In internal evaluations, adaptive thinking reliably drives better performance than extended thinking." Manual budget_tokens is deprecated.
332
316
  - **Subagent orchestration:** Include guidance for when subagents are warranted versus direct execution. Anthropic: "Use subagents when tasks can run in parallel, require isolated context, or involve independent workstreams that don't need to share state. For simple tasks, sequential operations, single-file edits, or tasks where you need to maintain context across steps, work directly rather than delegating."
333
317
  - **Conservative vs proactive action:** For tools that should act, use explicit language ("Change this function"). For tools that should advise, use: "Default to providing information... Only proceed with edits when the user explicitly requests them."
334
- - **Anti-hallucination:** Anthropic: "Never speculate about code you have not opened. If the user references a specific file, you MUST read the file before answering."
335
- - **Self-correction chaining:** Anthropic: "The most common chaining pattern is self-correction: generate a draft, have Claude review it against criteria, have Claude refine based on the review." Consider adding a generate-review-refine loop for prompts that must hold up over time.
318
+
319
+ (Anti-hallucination grounding and self-correction chaining are covered in Step 4 / Step 8 of the workflow above.)
336
320
 
337
321
  ## Autonomy and safety pattern
338
322