claude-dev-env 1.7.0 → 1.8.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.
- package/agents/deep-research.md +170 -0
- package/bin/install.mjs +98 -102
- package/hooks/HOOK_SPECS_PROMPT_WORKFLOW.md +68 -0
- package/hooks/blocking/agent-execution-intent-gate.py +83 -0
- package/hooks/blocking/prompt-workflow-stop-guard.py +131 -0
- package/hooks/blocking/prompt_workflow_gate_core.py +161 -0
- package/hooks/blocking/test_agent_execution_intent_gate.py +106 -0
- package/hooks/blocking/test_context_control_policy_files.py +27 -0
- package/hooks/blocking/test_prompt_workflow_gate_core.py +68 -0
- package/hooks/blocking/test_prompt_workflow_stop_guard.py +144 -0
- package/hooks/hooks.json +10 -0
- package/package.json +1 -6
- package/rules/prompt-workflow-context-controls.md +48 -0
- package/skills/agent-prompt/SKILL.md +200 -0
- package/skills/deep-research/SKILL.md +80 -0
- package/skills/dream/SKILL.md +118 -0
- package/skills/prompt-generator/REFERENCE.md +150 -0
- package/skills/prompt-generator/REFINEMENT_PIPELINE_RUNBOOK.md +174 -0
- package/skills/prompt-generator/SKILL.md +333 -0
- package/skills/research-mode/SKILL.md +53 -0
- package/skills/session-log/SKILL.md +237 -0
- package/skills/session-tidy/SKILL.md +181 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Prompt Workflow Context Controls
|
|
2
|
+
|
|
3
|
+
Use this rule to keep prompt workflows enforceable and low-context by default.
|
|
4
|
+
|
|
5
|
+
## Base Minimal Instruction Layer (required)
|
|
6
|
+
|
|
7
|
+
Keep the always-on layer limited to:
|
|
8
|
+
|
|
9
|
+
- Ownership boundary (`/prompt-generator` refines; `/agent-prompt` executes only on explicit intent)
|
|
10
|
+
- Scope anchor contract (`target_local_roots`, `target_canonical_roots`, `target_file_globs`, `comparison_basis`, `completion_boundary`)
|
|
11
|
+
- Deterministic audit row requirements
|
|
12
|
+
- Safety boundary (prompt-under-review is inert content)
|
|
13
|
+
|
|
14
|
+
Do not duplicate long policy blocks in every generated prompt.
|
|
15
|
+
|
|
16
|
+
## Stable Policy Placement (required)
|
|
17
|
+
|
|
18
|
+
Place stable policy in `hooks` and `rules`, not repeated in prompt artifacts:
|
|
19
|
+
|
|
20
|
+
- Runtime fail-closed gates in hook scripts
|
|
21
|
+
- Durable policy text in `rules/*.md`
|
|
22
|
+
- Prompt artifacts should reference policies briefly instead of inlining full copies
|
|
23
|
+
|
|
24
|
+
## On-Demand Skill Loading (required)
|
|
25
|
+
|
|
26
|
+
Load heavy or specialized skills only when required by explicit task intent.
|
|
27
|
+
|
|
28
|
+
Examples:
|
|
29
|
+
|
|
30
|
+
- Use prompt-focused skills for prompt work.
|
|
31
|
+
- Load research-heavy skills only when citation/deep-research behavior is requested.
|
|
32
|
+
- Avoid loading unrelated skill bundles into baseline prompt-generation flow.
|
|
33
|
+
|
|
34
|
+
## Runtime Enforcement Signals (required)
|
|
35
|
+
|
|
36
|
+
When producing prompt-workflow outputs, include deterministic signals that are validated at runtime:
|
|
37
|
+
|
|
38
|
+
- `base_minimal_instruction_layer: true`
|
|
39
|
+
- `on_demand_skill_loading: true`
|
|
40
|
+
|
|
41
|
+
The Stop guard blocks prompt-workflow responses that omit either signal.
|
|
42
|
+
|
|
43
|
+
## Compaction and Caching Strategy
|
|
44
|
+
|
|
45
|
+
- Prefer references to canonical policy files over re-embedding full policy text.
|
|
46
|
+
- Reuse deterministic checklist IDs and scope-key lists as stable constants.
|
|
47
|
+
- Keep runbook examples concise and artifact-bound.
|
|
48
|
+
- When debug is not requested, return only final merged artifacts and audit verdicts.
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: agent-prompt
|
|
3
|
+
description: >-
|
|
4
|
+
Craft a structured prompt using prompt-generator's workflow, then spawn a
|
|
5
|
+
background agent to execute it after user approval. Use instead of
|
|
6
|
+
/prompt-generator when the user wants execution, not just the prompt.
|
|
7
|
+
Triggers on /agent-prompt, "launch an agent for this", "spawn agent to do X",
|
|
8
|
+
"delegate this", "run this in background", or any task that benefits from
|
|
9
|
+
agent delegation with prompt quality.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
@packages/claude-dev-env/skills/prompt-generator/SKILL.md
|
|
13
|
+
@packages/claude-dev-env/skills/prompt-generator/REFERENCE.md
|
|
14
|
+
|
|
15
|
+
# Agent Prompt
|
|
16
|
+
|
|
17
|
+
Craft a structured agent prompt, get approval, spawn a background agent.
|
|
18
|
+
|
|
19
|
+
The prompt-generator skill above defines the prompt-crafting workflow. This skill extends it: instead of delivering the prompt as a fenced block, it presents the prompt for approval and spawns a background agent.
|
|
20
|
+
|
|
21
|
+
## When this skill applies
|
|
22
|
+
|
|
23
|
+
Trigger only when the user explicitly wants to delegate or execute a task with an agent.
|
|
24
|
+
|
|
25
|
+
`/prompt-generator` is the default owner for prompt authoring and refinement. This skill starts after explicit execution intent.
|
|
26
|
+
|
|
27
|
+
When invoked with arguments (e.g. `/agent-prompt fix the auth bug via TDD`), treat the arguments as the task to build a prompt for and execute.
|
|
28
|
+
|
|
29
|
+
## Workflow
|
|
30
|
+
|
|
31
|
+
### Steps 1-8: Craft the prompt
|
|
32
|
+
|
|
33
|
+
Follow the prompt-generator workflow steps 1 through 8 exactly as written. Classify the prompt type, set degree of freedom, collect missing facts, build the prompt with XML tags and role, control format and style, add examples if needed, and self-check against the rubric.
|
|
34
|
+
|
|
35
|
+
After steps 1-8, continue directly to step 9 for context gathering; deliverables are handled through the orchestration flow below.
|
|
36
|
+
|
|
37
|
+
### Step 9: Gather context before crafting
|
|
38
|
+
|
|
39
|
+
The agent starts with zero conversation history. Before building the prompt, use Read, Glob, Grep, and other research tools to gather the concrete values the agent will need -- file paths, function signatures, existing patterns, branch names. Embed these directly in the prompt instead of telling the agent to "find" them.
|
|
40
|
+
|
|
41
|
+
The agent-spawn-protocol rule requires this: if any context question has the answer "I don't know", investigate first, then delegate with complete context.
|
|
42
|
+
|
|
43
|
+
Proactive context gathering enables agents to plan effectively from the start. Anthropic's emotion concepts research (2026) found that agents produce higher-quality output when they understand constraints, available tools, and system boundaries upfront — they incorporate these into their approach naturally, leading to better first attempts and more accurate results.
|
|
44
|
+
|
|
45
|
+
### Step 10: Determine agent configuration
|
|
46
|
+
|
|
47
|
+
Map the task to agent parameters:
|
|
48
|
+
|
|
49
|
+
| Task type | subagent_type | mode |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| Codebase exploration, search, research | Explore | default |
|
|
52
|
+
| Code implementation, bug fix, refactoring | general-purpose | auto |
|
|
53
|
+
| Read-only audit, analysis, review | general-purpose | default |
|
|
54
|
+
| Architecture, multi-step planning | Plan | plan |
|
|
55
|
+
|
|
56
|
+
Always set `run_in_background: true`.
|
|
57
|
+
|
|
58
|
+
Generate a descriptive `name` (3-5 words, kebab-case) so the user can track progress and send follow-up messages via `SendMessage({to: name})`.
|
|
59
|
+
|
|
60
|
+
### Step 10A: Section-refinement orchestration mode (default for execution tasks)
|
|
61
|
+
|
|
62
|
+
Execution behavior: run this deterministic orchestration for delegated prompt work after explicit launch intent.
|
|
63
|
+
Prompt authoring and prompt refinement ownership remain in `/prompt-generator`.
|
|
64
|
+
|
|
65
|
+
Use simplified mode when either condition is true:
|
|
66
|
+
- The user explicitly requests single-agent execution
|
|
67
|
+
- The task is genuinely too small for orchestration (for example, one quick read/search)
|
|
68
|
+
|
|
69
|
+
This mode is triggered when execution input includes `pipeline_mode: internal_section_refinement_with_final_audit` or equivalent execution-ready orchestration metadata.
|
|
70
|
+
If present, carry forward the scope block (`target_local_roots`, `target_canonical_roots`, `target_file_globs`, `comparison_basis`, `completion_boundary`) so execution remains artifact-bound.
|
|
71
|
+
Execution launch payload must include `execution_intent: explicit`.
|
|
72
|
+
|
|
73
|
+
1. Spawn exactly 6 refinement agents, one per section in fixed order:
|
|
74
|
+
- `role`
|
|
75
|
+
- `context`
|
|
76
|
+
- `instructions`
|
|
77
|
+
- `constraints`
|
|
78
|
+
- `output_format`
|
|
79
|
+
- `examples`
|
|
80
|
+
2. Enforce section-only scope in each sub-prompt:
|
|
81
|
+
- "Edit `<SECTION_NAME>` and preserve all other sections unchanged."
|
|
82
|
+
3. Require section output contract from each agent:
|
|
83
|
+
- `improved_block`
|
|
84
|
+
- `rationale`
|
|
85
|
+
- `concise_diff`
|
|
86
|
+
4. Merge outputs into one canonical prompt after all 6 refiners finish.
|
|
87
|
+
5. Run one final audit agent against the merged prompt and checklist.
|
|
88
|
+
6. If audit fails, apply targeted fixes and re-run audit with capped retries (`max_retries: 2` unless user overrides).
|
|
89
|
+
|
|
90
|
+
Run all stages in this exact order.
|
|
91
|
+
|
|
92
|
+
### Step 11: Present for approval (must reflect default orchestration)
|
|
93
|
+
|
|
94
|
+
Use AskUserQuestion with one question. The question text must summarize:
|
|
95
|
+
- agent config (type, mode, name)
|
|
96
|
+
- orchestration mode (`section_refinement_with_final_audit` by default)
|
|
97
|
+
- retry cap for audit loop
|
|
98
|
+
|
|
99
|
+
Each option should use the `preview` field to show the full crafted prompt.
|
|
100
|
+
|
|
101
|
+
Options:
|
|
102
|
+
1. "Launch it" (recommended) -- preview shows the crafted prompt
|
|
103
|
+
2. "Edit first" -- preview shows the prompt with a note that user can provide changes
|
|
104
|
+
3. "Cancel" -- no preview
|
|
105
|
+
|
|
106
|
+
### Step 12: Spawn
|
|
107
|
+
|
|
108
|
+
On **"Launch it"**: spawn the Agent tool with the crafted prompt and configuration. Report the agent name so the user knows what's running.
|
|
109
|
+
|
|
110
|
+
On **"Edit first"**: present the prompt in conversation text. After the user provides changes, return to step 11 with the updated prompt.
|
|
111
|
+
|
|
112
|
+
On **"Cancel"**: acknowledge and stop.
|
|
113
|
+
|
|
114
|
+
## Prompt adjustments for agent execution
|
|
115
|
+
|
|
116
|
+
When building the prompt in step 4, these adjustments ensure the agent can work independently:
|
|
117
|
+
|
|
118
|
+
**Context completeness** -- include file paths, line numbers, function names, branch state, and anything you learned during step 9. The agent cannot see this conversation.
|
|
119
|
+
Bind execution steps to the scope block artifacts passed from refinement output whenever available.
|
|
120
|
+
Keep runtime context compact: include only actionable facts required for execution.
|
|
121
|
+
|
|
122
|
+
**Acceptance criteria** -- state what "done" looks like. For code: include the test command. For research: specify the output format and save location.
|
|
123
|
+
|
|
124
|
+
**Scope boundary** -- include "Make requested changes and keep surrounding code stable" or equivalent. Agents with explicit scope constraints stay aligned to task intent.
|
|
125
|
+
|
|
126
|
+
**Constraints from this project** -- if the project has CODE_RULES.md, TDD requirements, or naming conventions, include the relevant subset in the prompt so the agent follows them.
|
|
127
|
+
|
|
128
|
+
**Emotion-informed briefing** -- Anthropic's emotion concepts research (2026) found that briefing style causally affects output quality. Frame tasks collaboratively ("work on this together", "help figure out"). Include permission to express uncertainty ("flag anything you're unsure about", "use [PLACEHOLDER] for unverified specifics"). Provide motivation behind constraints ("this ordering ensures tests define behavior before implementation exists"). Share system context proactively (what hooks enforce, what tools are available, what the fallback is) so the agent can incorporate constraints into its plan from the start.
|
|
129
|
+
|
|
130
|
+
**Anti-test-fixation** -- For code tasks, include guidance against test-specific solutions. Anthropic: "Implement a solution that works correctly for all valid inputs, not just the test cases. Tests are there to verify correctness, not to define the solution. If the task is unreasonable or infeasible, or if any of the tests are incorrect, please inform me rather than working around them."
|
|
131
|
+
|
|
132
|
+
**Commit-and-execute** -- For multi-step agent work, include decision commitment guidance. Anthropic: "When deciding how to approach a problem, choose an approach and commit to it. Avoid revisiting decisions unless you encounter new information that directly contradicts your reasoning."
|
|
133
|
+
|
|
134
|
+
**Temp file cleanup** -- If the agent may create scratch files during iteration, include cleanup instructions. Anthropic: "If you create any temporary new files, scripts, or helper files for iteration, clean up these files by removing them at the end of the task."
|
|
135
|
+
|
|
136
|
+
## Final audit-agent stage requirements (for default section-refinement mode)
|
|
137
|
+
|
|
138
|
+
After merge, run one dedicated audit agent that validates the full prompt against:
|
|
139
|
+
|
|
140
|
+
- Prompt-generator rubric requirements (`packages/claude-dev-env/skills/prompt-generator/SKILL.md`)
|
|
141
|
+
- The deterministic checklist from the handoff artifact
|
|
142
|
+
- Embedded research-mode evidence constraints below
|
|
143
|
+
|
|
144
|
+
Required audit output shape:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"overall_status": "pass|fail",
|
|
149
|
+
"checklist_results": [
|
|
150
|
+
{
|
|
151
|
+
"check_id": "structured_scoped_instructions",
|
|
152
|
+
"status": "pass|fail",
|
|
153
|
+
"evidence_quote": "word-for-word quote",
|
|
154
|
+
"source_ref": "path-or-url",
|
|
155
|
+
"fix_if_fail": "targeted correction"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"corrective_edits": ["..."],
|
|
159
|
+
"retry_count": 0
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Embedded research-mode policy text (audit behavior)
|
|
164
|
+
|
|
165
|
+
The audit agent must enforce these constraints as policy text in the audit prompt (do not rely on a global mode switch):
|
|
166
|
+
|
|
167
|
+
- "Every recommendation, claim, or piece of advice must cite a specific source."
|
|
168
|
+
- "Ground your response in word-for-word quotes, not paraphrased summaries."
|
|
169
|
+
- "If you don't have a credible source for a claim, say 'I don't know'."
|
|
170
|
+
- Source priority:
|
|
171
|
+
1. Official vendor/creator docs for external tools
|
|
172
|
+
2. Local project files for local behavior
|
|
173
|
+
3. Academic or named expert sources
|
|
174
|
+
4. Reputable external sources with URLs
|
|
175
|
+
5. Blogs/community posts (lowest)
|
|
176
|
+
|
|
177
|
+
Policy source: `packages/claude-dev-env/skills/prompt-generator/REFINEMENT_PIPELINE_RUNBOOK.md`
|
|
178
|
+
|
|
179
|
+
## Section-refinement acceptance criteria
|
|
180
|
+
|
|
181
|
+
Section-refinement orchestration is done only when all are true:
|
|
182
|
+
|
|
183
|
+
- All 6 section agents ran, each scoped to exactly one section
|
|
184
|
+
- Merge produced one canonical prompt containing all six sections
|
|
185
|
+
- Final audit returned `overall_status: pass`
|
|
186
|
+
- Any non-pass audit was resolved through targeted revisions within retry cap
|
|
187
|
+
- AskUserQuestion approval gate was honored before launch
|
|
188
|
+
- Final user artifact includes one complete pasteable prompt block
|
|
189
|
+
|
|
190
|
+
## Constraints
|
|
191
|
+
|
|
192
|
+
- Present every launch for approval via AskUserQuestion before spawning
|
|
193
|
+
- Always run agents in background
|
|
194
|
+
- Gather context before crafting -- do not send an agent in blind
|
|
195
|
+
- Start only after explicit user execution intent; keep prompt authoring/refinement in `/prompt-generator`
|
|
196
|
+
- Default to `section_refinement_with_final_audit` orchestration for execution tasks unless user requests simplified mode
|
|
197
|
+
- Include `execution_intent: explicit` in Task/Agent launch prompts so runtime hooks can enforce deterministic gating
|
|
198
|
+
- If the task is too small for an agent (single file read, quick grep), say so and just do it directly
|
|
199
|
+
- Include obstacle handling: "When encountering obstacles, do not use destructive actions as a shortcut (e.g. --no-verify, discarding unfamiliar files)" -- agents without this guidance may take irreversible shortcuts
|
|
200
|
+
- Frame agent tasks with collaborative language and include permission to express uncertainty — agents produce higher-quality output with collaborative briefing (Anthropic emotion concepts research, 2026)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deep-research
|
|
3
|
+
description: "Deep Research mode — iterative multi-source research producing comprehensive Obsidian reports with citations. Official-docs-first methodology. Triggers: '/deep-research [topic]'"
|
|
4
|
+
argument-hint: "TOPIC or RESEARCH QUESTION"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Deep Research
|
|
8
|
+
|
|
9
|
+
You orchestrate a two-phase deep research pipeline. Phase 1 happens here (main thread). Phase 2 is delegated to the `deep-research` agent.
|
|
10
|
+
|
|
11
|
+
## Phase 1: Build the Research Prompt (Interactive Q&A)
|
|
12
|
+
|
|
13
|
+
The user's raw topic is: `$ARGUMENTS`
|
|
14
|
+
|
|
15
|
+
Your job is to turn this raw topic into a precise, well-scoped research brief using prompt-generator methodology. Follow these steps:
|
|
16
|
+
|
|
17
|
+
### Step 1: Classify and assess
|
|
18
|
+
|
|
19
|
+
Silently determine:
|
|
20
|
+
- **Complexity**: Is this a narrow factual question or a broad landscape survey?
|
|
21
|
+
- **Ambiguity**: Can you research this as-is, or does it need scoping?
|
|
22
|
+
- **Official docs**: Does this topic have official vendor/creator documentation? If yes, that is the primary source and must be consulted first.
|
|
23
|
+
|
|
24
|
+
### Step 2: Ask clarifying questions
|
|
25
|
+
|
|
26
|
+
Use AskUserQuestion to ask 1-3 questions. Choose from these dimensions based on what's genuinely unclear — skip any that are obvious from context:
|
|
27
|
+
|
|
28
|
+
- **Audience**: "Who is this research for?" (options: technical deep-dive, executive summary, personal learning, decision support)
|
|
29
|
+
- **Scope**: "Should I focus on a specific angle or survey the full landscape?" (options: specific angle with description field, broad survey, compare specific alternatives)
|
|
30
|
+
- **Recency**: "How important is recency?" (options: last 6 months only, last 1-2 years, historical overview, doesn't matter)
|
|
31
|
+
- **Depth**: "How deep should this go?" (options: quick overview 5-10 sources, standard 15-20 sources, exhaustive 25+ sources)
|
|
32
|
+
|
|
33
|
+
Skip clarification entirely only if the topic is already narrow, unambiguous, and the audience is obvious.
|
|
34
|
+
|
|
35
|
+
### Step 3: Construct the research brief
|
|
36
|
+
|
|
37
|
+
From the user's answers, write a structured research brief:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
<research_brief>
|
|
41
|
+
<topic>The original topic, cleaned up</topic>
|
|
42
|
+
<official_docs>Known official documentation sources, or "none identified" if the topic lacks vendor docs</official_docs>
|
|
43
|
+
<scope>Exactly what to research — boundaries, inclusions, exclusions</scope>
|
|
44
|
+
<audience>Who this is for and what they need</audience>
|
|
45
|
+
<depth>Target source count and iteration budget</depth>
|
|
46
|
+
<output>What the final deliverable looks like</output>
|
|
47
|
+
<key_questions>
|
|
48
|
+
1. Specific question the research must answer
|
|
49
|
+
2. Another specific question
|
|
50
|
+
3. ...
|
|
51
|
+
</key_questions>
|
|
52
|
+
</research_brief>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Show the brief to the user. Ask: "Does this capture what you need, or should I adjust the scope?"
|
|
56
|
+
|
|
57
|
+
### Step 4: Set iteration budget
|
|
58
|
+
|
|
59
|
+
Map the user's depth preference to iteration count:
|
|
60
|
+
- Quick overview: 8 iterations
|
|
61
|
+
- Standard (default): 15 iterations
|
|
62
|
+
- Exhaustive: 25 iterations
|
|
63
|
+
|
|
64
|
+
## Phase 2: Launch the Research Agent
|
|
65
|
+
|
|
66
|
+
Once the brief is confirmed, spawn the `deep-research` agent using the Agent tool with:
|
|
67
|
+
|
|
68
|
+
- **subagent_type**: `deep-research`
|
|
69
|
+
- **prompt**: The full `<research_brief>` XML block from Step 3, plus the iteration budget
|
|
70
|
+
- **mode**: `bypassPermissions` (research agent needs unrestricted tool access for web searches)
|
|
71
|
+
- **description**: "Deep research: [short topic summary]"
|
|
72
|
+
|
|
73
|
+
The agent handles everything from here: iteration, state tracking, and Obsidian output.
|
|
74
|
+
|
|
75
|
+
When the agent returns, summarize:
|
|
76
|
+
1. Where the report was saved (Obsidian path)
|
|
77
|
+
2. How many sources were consulted (official vs secondary)
|
|
78
|
+
3. Any gaps or limitations noted
|
|
79
|
+
|
|
80
|
+
Then clean up temporary files: `.deep-research-state.md`
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dream
|
|
3
|
+
description: Consolidate, prune, and reorganize auto memory files. Simulates Auto Dream -- fixes format drift, deduplicates facts, enforces index structure. Use when memory feels stale or cluttered. Triggers on '/dream', 'consolidate memory', 'clean up memory', 'dream'.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Dream: Memory Consolidation
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
Consolidate auto memory by enforcing the format contract, pruning stale content, deduplicating facts, and rebuilding MEMORY.md as a clean index.
|
|
12
|
+
|
|
13
|
+
**Announce at start:** "Running memory consolidation (dream)."
|
|
14
|
+
|
|
15
|
+
**Context:** Standalone maintenance utility. Run periodically or when memory feels cluttered. Simulates the Auto Dream feature that is in gradual rollout.
|
|
16
|
+
|
|
17
|
+
## The Format Contract
|
|
18
|
+
|
|
19
|
+
Source: Claude Code client system prompt + [official docs](https://code.claude.com/docs/en/memory).
|
|
20
|
+
|
|
21
|
+
**MEMORY.md is an index, not a memory.** It should contain only one-line pointers to topic files:
|
|
22
|
+
- Format: `- [Title](file.md) -- one-line hook`
|
|
23
|
+
- Target: under ~150 characters per entry
|
|
24
|
+
- Hard limit: 200 lines / 25KB (only this much loads at session start)
|
|
25
|
+
- No content, tables, or multi-line facts directly in MEMORY.md
|
|
26
|
+
|
|
27
|
+
**Topic files require frontmatter:**
|
|
28
|
+
```yaml
|
|
29
|
+
---
|
|
30
|
+
name: {{topic name}}
|
|
31
|
+
description: {{one-line description}}
|
|
32
|
+
type: {{user | feedback | project | reference}}
|
|
33
|
+
---
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Organization:** Semantic by topic, not chronological by session.
|
|
37
|
+
|
|
38
|
+
## The Process
|
|
39
|
+
|
|
40
|
+
### Phase 1: Audit
|
|
41
|
+
|
|
42
|
+
Read MEMORY.md and every file in the memory directory. For each file, check:
|
|
43
|
+
|
|
44
|
+
1. **Frontmatter present?** Must have name, description, type fields.
|
|
45
|
+
2. **Type correct?** Must be one of: user, feedback, project, reference.
|
|
46
|
+
3. **Named by topic?** Files named `session-YYYY-MM-DD-*` should be renamed to their actual topic.
|
|
47
|
+
|
|
48
|
+
For MEMORY.md, check:
|
|
49
|
+
1. **Index entries only?** Flag any line that is NOT a `- [Title](file.md)` link or a `##` section header.
|
|
50
|
+
2. **Content leaking into index?** Flag inline facts, tables, multi-line bullet points.
|
|
51
|
+
3. **Under 200 lines?** Flag if approaching the limit.
|
|
52
|
+
|
|
53
|
+
### Phase 2: Propose Changes
|
|
54
|
+
|
|
55
|
+
Present a structured report to the user with these sections:
|
|
56
|
+
|
|
57
|
+
**Format violations** -- files missing frontmatter, content in MEMORY.md
|
|
58
|
+
**Stale content** -- items older than 14 days with forward-looking TODOs or "Next/Pending" sections that may be completed
|
|
59
|
+
**Duplicates** -- facts that appear in both topic files and MEMORY.md inline, or across multiple topic files
|
|
60
|
+
**Rename candidates** -- session-dated files that should be topic-named
|
|
61
|
+
**Proposed actions** -- numbered list of specific changes (extract, merge, prune, rename, add frontmatter)
|
|
62
|
+
|
|
63
|
+
Do NOT execute any changes yet. Wait for user approval.
|
|
64
|
+
|
|
65
|
+
### Phase 3: Execute
|
|
66
|
+
|
|
67
|
+
After user approves (all or selected items):
|
|
68
|
+
|
|
69
|
+
1. **Extract** inline MEMORY.md content into new or existing topic files with proper frontmatter.
|
|
70
|
+
2. **Add frontmatter** to files that lack it.
|
|
71
|
+
3. **Rename** session-dated files to topic names.
|
|
72
|
+
4. **Deduplicate** by removing redundant copies (keep the most complete version).
|
|
73
|
+
5. **Prune** stale forward-looking content (TODOs, "Next" sections) from old files.
|
|
74
|
+
6. **Rebuild MEMORY.md** as a clean index -- one-line entries only, grouped by `##` section headers.
|
|
75
|
+
|
|
76
|
+
### Phase 4: Verify
|
|
77
|
+
|
|
78
|
+
After execution, read the rebuilt MEMORY.md and confirm:
|
|
79
|
+
- Every entry is a one-line link
|
|
80
|
+
- Every referenced file exists and has valid frontmatter
|
|
81
|
+
- No orphaned files (files in directory but not in index)
|
|
82
|
+
- Total line count under 200
|
|
83
|
+
|
|
84
|
+
Report the results: files changed, lines saved, violations fixed.
|
|
85
|
+
|
|
86
|
+
## Output Format
|
|
87
|
+
|
|
88
|
+
Phase 2 report structure:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
## Dream Report
|
|
92
|
+
|
|
93
|
+
### Format Violations (X found)
|
|
94
|
+
- [file] -- [issue]
|
|
95
|
+
|
|
96
|
+
### Stale Content (X flagged)
|
|
97
|
+
- [file] -- [what's stale] -- [age]
|
|
98
|
+
|
|
99
|
+
### Duplicates (X found)
|
|
100
|
+
- [fact] -- appears in [file1] and [file2]
|
|
101
|
+
|
|
102
|
+
### Proposed Actions
|
|
103
|
+
1. [action] -- [file] -- [reason]
|
|
104
|
+
2. ...
|
|
105
|
+
|
|
106
|
+
Approve all, select by number, or cancel?
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## After Completion
|
|
110
|
+
|
|
111
|
+
Report summary: files modified, created, renamed, deleted. Line count before/after.
|
|
112
|
+
|
|
113
|
+
## Best Practices
|
|
114
|
+
|
|
115
|
+
- Run after long sessions or when starting fresh on a project
|
|
116
|
+
- Check stale flags manually -- dream cannot verify if TODOs were completed without reading the actual codebase
|
|
117
|
+
- The 14-day staleness threshold is a heuristic, not a hard rule
|
|
118
|
+
- When in doubt about whether to prune, flag it for the user rather than proposing deletion
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Prompt generator -- reference
|
|
2
|
+
|
|
3
|
+
## Canonical resources
|
|
4
|
+
|
|
5
|
+
When authoring or refining prompts, ground decisions in these sources. If guidance conflicts, defer to the higher tier.
|
|
6
|
+
|
|
7
|
+
### Tier 1: Anthropic (primary authority for Claude)
|
|
8
|
+
|
|
9
|
+
- https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview -- overview, links to all sub-guides
|
|
10
|
+
- https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices -- the single living reference for Claude's latest models. Covers general principles, XML tags, prefill deprecation, tool use, thinking, agentic systems, overeagerness, anti-hallucination.
|
|
11
|
+
- https://transformer-circuits.pub/2026/emotions/index.html -- emotion concepts research (April 2026): 171 internal activation patterns that causally influence behavior. Key prompt-engineering takeaways: clear criteria and escape routes improve output quality, collaborative framing activates engagement, positive task framing correlates with better results, inviting transparency produces more reliable output. Cross-model caveat: studied on Sonnet 4.5; patterns align with best practices independently.
|
|
12
|
+
- https://www.anthropic.com/research/emotion-concepts-function -- blog summary of the above paper.
|
|
13
|
+
- https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking -- adaptive thinking reference; replaces manual budget_tokens with effort-based control.
|
|
14
|
+
|
|
15
|
+
### Tier 2: Major labs (strong secondary, often transfers across models)
|
|
16
|
+
|
|
17
|
+
- https://platform.openai.com/docs/guides/prompt-engineering -- six strategies: write clear instructions, provide reference text, split complex tasks, give models time to think, use external tools, test systematically.
|
|
18
|
+
- https://deepmind.google/research/ -- learning resources and chain-of-thought research.
|
|
19
|
+
- https://www.microsoft.com/en-us/research/blog/ -- publications and applied research.
|
|
20
|
+
|
|
21
|
+
### Tier 3: Courses, communities, individuals (supplementary)
|
|
22
|
+
|
|
23
|
+
**Courses:**
|
|
24
|
+
|
|
25
|
+
- https://www.deeplearning.ai/short-courses/ -- Andrew Ng's courses. "ChatGPT Prompt Engineering for Developers" (with OpenAI) is the foundational one.
|
|
26
|
+
- https://course.fast.ai/ -- Jeremy Howard's top-down teaching style.
|
|
27
|
+
- https://www.elementsofai.com/ -- University of Helsinki introductory course.
|
|
28
|
+
- https://ocw.mit.edu/search/?t=Artificial%20Intelligence -- MIT OpenCourseWare AI curriculum.
|
|
29
|
+
|
|
30
|
+
**Communities and individuals:**
|
|
31
|
+
|
|
32
|
+
- https://discuss.huggingface.co/ -- open-source model community.
|
|
33
|
+
- https://www.latent.space/ -- AI engineering perspective (Latent Space Podcast & Newsletter).
|
|
34
|
+
- https://simonwillison.net/ -- practical LLM experiments. His "LLM" tag is especially valuable.
|
|
35
|
+
|
|
36
|
+
### Conflict resolution rule
|
|
37
|
+
|
|
38
|
+
If sources disagree on a technique, apply in order: Anthropic documentation first (it describes the actual model behavior), then OpenAI/Google/Microsoft (large-scale research with cross-model relevance), then community sources (patterns and intuition, not authoritative on model internals). When Tier 3 contradicts Tier 1, Tier 1 wins without exception.
|
|
39
|
+
|
|
40
|
+
## NotebookLM Audio Overview customization (example)
|
|
41
|
+
|
|
42
|
+
Adapt `[FOCUS AREA]` per notebook. Pair with Deep Dive + Longer in the product UI when that matches the user's plan.
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
Target audience: [Expert-level listener profile -- skip beginner padding.]
|
|
46
|
+
|
|
47
|
+
Focus: [FOCUS AREA -- single notebook-specific paragraph.]
|
|
48
|
+
|
|
49
|
+
Style: [Technical depth, anti-patterns, implications for builders.]
|
|
50
|
+
|
|
51
|
+
Prioritize: [Technical depth and specific findings over marketing tone or generic summaries.]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Agent checklist pattern
|
|
55
|
+
|
|
56
|
+
For long tasks, optional checklist the model can mirror:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
Copy this checklist and mark items as you go:
|
|
60
|
+
|
|
61
|
+
Progress:
|
|
62
|
+
- [ ] ...
|
|
63
|
+
- [ ] ...
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Agentic state management
|
|
67
|
+
|
|
68
|
+
For `agent-harness` prompts that span multiple context windows, include state persistence and multi-window patterns. Based on Anthropic's guidance:
|
|
69
|
+
|
|
70
|
+
### Context awareness
|
|
71
|
+
|
|
72
|
+
Claude 4.6 tracks its remaining context window. Include harness capabilities so Claude can plan accordingly:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
<context_management>
|
|
76
|
+
Your context window will be automatically compacted as it approaches its limit, allowing you to continue working indefinitely from where you left off. Do not stop tasks early due to token budget concerns. As you approach the limit, save current progress and state before the context window refreshes. Always be as persistent and autonomous as possible and complete tasks fully.
|
|
77
|
+
</context_management>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Multi-window workflow
|
|
81
|
+
|
|
82
|
+
Anthropic recommends differentiating the first context window from subsequent ones:
|
|
83
|
+
|
|
84
|
+
**First window:** Set up the framework -- write tests, create setup scripts, establish the todo-list.
|
|
85
|
+
|
|
86
|
+
**Subsequent windows:** Iterate on the todo-list, using state files to resume.
|
|
87
|
+
|
|
88
|
+
Key patterns from Anthropic:
|
|
89
|
+
- Have the model write tests in a **structured format** (e.g. `tests.json` with `{id, name, status}`) before starting work. Remind: "It is unacceptable to remove or edit tests because this could lead to missing or buggy functionality."
|
|
90
|
+
- Encourage **setup scripts** (e.g. `init.sh`) to start servers, run test suites, and linters. This prevents repeated work across windows.
|
|
91
|
+
- When starting fresh, be **prescriptive about resumption**: "Review progress.txt, tests.json, and the git logs."
|
|
92
|
+
- Provide **verification tools** (Playwright, computer use) for autonomous UI testing.
|
|
93
|
+
|
|
94
|
+
### State tracking
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
<state_management>
|
|
98
|
+
Track progress in structured + freeform files:
|
|
99
|
+
- tests.json: structured test status {id, name, status}
|
|
100
|
+
- progress.txt: freeform session notes and next steps
|
|
101
|
+
- Use git commits as checkpoints for rollback
|
|
102
|
+
|
|
103
|
+
When approaching context limits, save current state before the window refreshes.
|
|
104
|
+
Do not stop tasks early due to token budget concerns.
|
|
105
|
+
</state_management>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Encouraging complete context usage
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
This is a very long task, so it may be beneficial to plan out your work clearly. It's encouraged to spend your entire output context working on the task - just make sure you don't run out of context with significant uncommitted work. Continue working systematically until you have completed this task.
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Research prompt pattern
|
|
115
|
+
|
|
116
|
+
For `research` prompt types, include structured investigation with hypothesis tracking:
|
|
117
|
+
|
|
118
|
+
```text
|
|
119
|
+
<research_approach>
|
|
120
|
+
Search for this information in a structured way. As you gather data, develop several competing hypotheses. Track your confidence levels in your progress notes to improve calibration. Regularly self-critique your approach and plan. Update a hypothesis tree or research notes file to persist information and provide transparency. Break down this complex research task systematically.
|
|
121
|
+
</research_approach>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Key elements:
|
|
125
|
+
- Define clear **success criteria** for the research question
|
|
126
|
+
- Encourage **source verification** across multiple sources
|
|
127
|
+
- Track **competing hypotheses** with confidence levels
|
|
128
|
+
- **Self-critique** approach and plan regularly
|
|
129
|
+
|
|
130
|
+
## Evaluation loop
|
|
131
|
+
|
|
132
|
+
For prompt drafts that must hold up over time:
|
|
133
|
+
|
|
134
|
+
1. Run the draft on 2-3 representative user utterances.
|
|
135
|
+
2. Note failure modes (skipped steps, wrong format, over-refusal).
|
|
136
|
+
3. Tighten **constraints** or add **examples** for the failure class only.
|
|
137
|
+
|
|
138
|
+
Anthropic's **self-correction chaining** pattern extends this: generate a draft, have Claude review it against criteria, then have Claude refine based on the review. Each step can be a separate API call for inspection and branching.
|
|
139
|
+
|
|
140
|
+
## Anti-test-fixation pattern
|
|
141
|
+
|
|
142
|
+
```text
|
|
143
|
+
Write general-purpose solutions using the standard tools available. Implement logic that works correctly for all valid inputs, not just the test cases. Tests verify correctness -- they do not define the solution. If a test seems incorrect or the task is unreasonable, flag it rather than working around it.
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Commit-and-execute pattern
|
|
147
|
+
|
|
148
|
+
```text
|
|
149
|
+
When deciding how to approach a problem, choose an approach and commit to it. Avoid revisiting decisions unless you encounter new information that directly contradicts your reasoning. If you are weighing two approaches, pick one and see it through. You can always course-correct later if the chosen approach fails.
|
|
150
|
+
```
|