Daydreamer Skill
This skill emulates the human act of daydreaming. A Python conductor script (daydream.py, bundled with this skill) handles all mechanical work — cycle counting, random number generation, memory parsing, and state tracking. The agent handles only the creative work: semantic matching, hypothetical reasoning, web searches, analytical questioning, and final synthesis.
Architecture: Script as conductor, agent as musician.
Each cycle's prompt contains the full accumulated context from every previous cycle. The script reads the agent's response after each step, folds it into the running context, and generates the next prompt with everything included. The agent never has to reconstruct state or re-read old files.
Files
The conductor script (daydream.py) is bundled in this skill's directory. All other files are created in the current working directory (workspace root):
| File | Purpose |
|---|
| INLINECODE2 | Numbered list of daily memories. Each line is one memory entry. |
| INLINECODE3 |
Chronological log of completed daydream sessions and their outcomes. |
|
daydreamer-config.json | Persisted configuration (frequency, cycles per session, default daydream type). |
|
ideas/NNN-title.md | Standalone idea files — one per daydream session. Auto-numbered. |
|
.daydream-session/ | Temporary directory for script↔agent JSON exchange during a session. Cleaned up after finalization. |
Prerequisites
- - Python 3.8+ must be installed and available.
Locating the Script
The conductor script daydream.py is in the same directory as this SKILL.md file. To find it at runtime, resolve the path relative to this skill's installation directory. For example:
CODEBLOCK0
Throughout this document, $SCRIPT refers to the full path to daydream.py in this skill's directory. When executing commands, replace $SCRIPT with the actual resolved path.
Daydream Types
| Type | Name | Output |
|---|
| INLINECODE11 | Full Daydream | Open-ended — can produce an idea, recommendation, question, observation, warning, analogy, or anything else that emerges naturally. No constraints. |
| INLINECODE12 |
Idea Generation | Focused on producing a novel, actionable idea — something that could be built, implemented, or pursued. |
The default type is set in daydreamer-config.json (default_daydream_type). The user can override it per-session.
The traversal mechanics (modes 1–4) are identical for both types. The difference is entirely in the synthesis step — the synthesis prompt includes type-specific instructions telling the agent what kind of output to produce.
First Install
On first use, check whether daydreamer-config.json exists in the workspace root. If it does not exist, perform first-install setup:
- 1. Run the init command to create the files:
CODEBLOCK1
- 2. Ask about daydream type (this is its own question — do not bundle with other settings):
> "What kind of daydreams would you like as your default?
>
> -
Full — open-ended. Each session can produce anything: an idea, a recommendation, a question, an observation, or something unexpected.
> -
Idea — focused. Each session is specifically aimed at generating a novel, actionable idea.
>
> You can always run the other kind on demand — this just sets what happens by default."
- 3. Wait for the user's answer. Update
daydreamer-config.json with their choice:
CODEBLOCK2
- 4. Ask about schedule and cycles:
> "How often should I daydream, and how many cycles per session?
>
>
Defaults: Once per day, 10 cycles per session.
> Reply with
default to accept, or specify your preferences (e.g., 'twice a day, 15 cycles')."
- 5. Wait for the user's answer. Update
daydreamer-config.json if they specified custom values.
- 6. Confirm setup to the user and explain:
- Memories will be written here each day as you work.
- A daydream session can be triggered at any time with
/daydream.
- Automated sessions will run on the configured schedule.
- To run a different type than the default, say
/daydream idea or
/daydream full.
- 7. Seed starter memories (only when
Daydreams.MD is empty or has fewer than 2 entries):
CODEBLOCK3
The script outputs a list of Claude Code session log files (JSONL) and how many memories are needed. Read each file and extract meaningful events — decisions made, things built, bugs fixed, requests fulfilled, insights gained. Skip heartbeat checks, empty status polls, and trivial exchanges.
Write each event as a memory (aim for 50 total):
CODEBLOCK4
What counts as a meaningful event:
- A feature or tool the user asked to build
- A bug diagnosed or fixed
- A design decision or trade-off made
- A configuration or workflow set up
- An insight or pattern observed during the session
Read log files in reverse-chronological order (most recent first). Stop when you have 50 memories or have exhausted the logs. Tell the user how many memories were seeded.
Slash Command: /daydream
Users can trigger a forced daydream session with /daydream. Parse arguments flexibly:
- -
/daydream → default type and cycles - INLINECODE24 → 5 cycles, default type
- INLINECODE25 → default cycles, idea type
- INLINECODE26 → 5 cycles, idea type
- INLINECODE27 → 20 cycles, full type
Recognize full and idea as type keywords. Any number is the cycle count.
When triggered via /daydream, always pass --forced to both start and finalize. This ensures the daily schedule is not affected.
Writing Memories
Memory writing happens once per calendar day (tracked via last_memory_write_date in config).
What to write
Write a memory entry for each meaningful event that occurred during the session. A memory is a single, self-contained observation, experience, decision, or insight.
Memory format
Each memory should be 1–2 sentences capturing WHO, WHAT (the action or request), and WHY (if clear). No timestamps, no verbose detail.
Format: INLINECODE35
Good examples:
- - INLINECODE36
- INLINECODE37
- INLINECODE38
- INLINECODE39
- INLINECODE40
Aim for: one clear subject (who), one clear verb (what they did or asked), and context that would help connect this memory to others.
What NOT to write
Do not write entries for:
- - Heartbeat checks that returned no work.
- Polling loops with no result.
- Empty status checks.
- Duplicate or trivially similar entries already in the list.
How to write
Use the conductor script:
CODEBLOCK5
The script handles numbering, dating, and appending automatically.
Daydream Procedure
A daydream session is a conversation between the conductor script and the agent, one cycle at a time. Each cycle builds on the full accumulated context of every previous cycle.
Flow Diagram
CODEBLOCK6
Step 1 — Start the session
CODEBLOCK7
To specify a type:
CODEBLOCK8
For forced daydreams (won't update schedule):
CODEBLOCK9
The script outputs JSON with the seed memory, cycle 1's mode, and file paths.
Step 2 — Process cycle 1
Read .daydream-session/prompt_cycle_001.json. It contains:
- -
mode / mode_name: Which mode to execute (1–4) - INLINECODE44 : The seed memory text
- INLINECODE45 : Which memories have been visited
- INLINECODE46 : The full memory bank
- For Mode 3:
target_result_rank (which web search result to use)
Execute the mode (see mode descriptions below). Write a response file:
CODEBLOCK10
Step 3 — Advance to next cycle
CODEBLOCK11
The script:
- 1. Reads your response for the current cycle
- Folds it into the accumulated context
- Rolls a new random mode
- Writes the next prompt with the full accumulated context from all previous cycles
Read the new prompt and repeat Step 2.
Step 4 — Synthesis
After the last cycle, next-cycle writes prompt_synthesis.json instead of another cycle prompt. This contains the complete accumulated context from every cycle.
Review everything. Think creatively:
- - What unexpected connections emerge between the memories visited?
- Does the combination suggest a solution, idea, pattern, or question?
- Consider the original context of each memory — why did it matter?
The synthesis prompt includes a synthesis_instructions field that tells you what kind of output to produce based on the daydream type:
- - Full: Output is unconstrained — report whatever emerged honestly.
- Idea: Focus on producing a specific, actionable idea.
Follow those instructions when writing your synthesis.
Write .daydream-session/response_synthesis.json:
CODEBLOCK12
Use "Inconclusive" if no clear output emerged — describe recurring themes instead.
Step 5 — Finalize
CODEBLOCK13
For forced daydreams:
CODEBLOCK14
This:
- 1. Writes the session report to INLINECODE53
- Writes a standalone idea file to
ideas/NNN-title.md with the synthesis, memory trail, and cycle log - Updates
last_daydream_date (unless forced) - Cleans up INLINECODE56
The finalize output includes an idea_file path pointing to the new idea file.
Step 6 — Present results to the user
This is the most important step. After finalizing, tell the user what you concluded. Present the synthesis directly and conversationally — not as a log entry, but as an idea worth thinking about. Example:
CODEBLOCK15
If the session was inconclusive, say so honestly and describe what themes kept recurring — these may be worth exploring deliberately.
Mode Descriptions
Mode 1 — Semantic Association
- - Review the
accumulated_context from the prompt. - Create a short semantic search query from the most salient concepts.
- Scan
all_memories for the entry most conceptually similar. - Prefer memories not in
visited_memory_indices. - Write response with the matched memory index, text, and log entry.
Mode 2 — Hypothetical Exploration
- - Generate a brief "what if" question inspired by the accumulated context.
- Think through the hypothetical, drawing on 2–3 thematically related memories from the memory bank.
- Select the memory most relevant to your conclusion.
- Write response with the hypothetical, reasoning, selected memory, and log entry.
Mode 3 — Web Search Excursion
- - Construct a focused web search query from the core themes of accumulated context.
- Perform the search using WebSearch.
- The prompt includes
target_result_rank — use the search result at that position. - Summarize the key insight from that result.
- Find the memory in the bank that most closely matches the web insight.
- Write response with the search query, insight, selected memory, and log entry.
- If web search is unavailable: Write a skip response. Note it in the log.
Mode 4 — Analytical Question
- - Formulate a direct, analytical question about the accumulated context. Not a "what if" (that's Mode 2) — instead, ask something that interrogates what's already there: "How does X actually work?", "Does X apply in this context?", "Why did X lead to Y?", "What's the mechanism behind X?"
- Think through the answer carefully, drawing on the accumulated context and related memories from the memory bank.
- The answer becomes part of the accumulated context — it deepens understanding rather than branching to new territory.
- Select the memory most relevant to the answer you arrived at.
- Write response with the question, your answer, the selected memory, and log entry formatted as: INLINECODE62
Forced Daydream
The user may trigger a daydream at any time with /daydream or "force a daydream". Optional cycle count and type:
CODEBLOCK16
Always pass --forced to both start and finalize.
Scheduled Daydream
Check the schedule:
CODEBLOCK17
If "Daydream is DUE", run a full session (without --forced).
| Value | Meaning |
|---|
| INLINECODE68 | One session per calendar day |
| INLINECODE69 |
Two sessions per day |
|
every_N_hours | Every N hours |
|
manual | Only on explicit user request |
Utility Commands
CODEBLOCK18
Edge Cases
- - Fewer than 2 memories: The script returns an error. Tell the user more memories are needed.
- Web search unavailable (Mode 3): Write a skip response for the cycle.
- Same memory selected twice: Accept it — note the repetition in the log.
- Gaps in memory numbering: The script handles this automatically.
- Python not installed: Inform the user Python 3.8+ is required.
白日梦技能
该技能模拟人类做白日梦的行为。一个Python指挥脚本(daydream.py,与此技能捆绑)处理所有机械性工作——周期计数、随机数生成、记忆解析和状态跟踪。智能体仅处理创造性工作:语义匹配、假设推理、网络搜索、分析性提问和最终综合。
架构:脚本是指挥,智能体是演奏者。
每个周期的提示包含来自所有先前周期的完整累积上下文。脚本在每个步骤后读取智能体的响应,将其纳入运行中的上下文,并生成包含所有内容的下一轮提示。智能体无需重建状态或重新读取旧文件。
文件
指挥脚本(daydream.py)位于此技能目录中。所有其他文件在当前工作目录(工作区根目录)中创建:
| 文件 | 用途 |
|---|
| Daydreams.MD | 每日记忆的编号列表。每行是一个记忆条目。 |
| Daydreamlog.MD |
已完成白日梦会话及其结果的按时间顺序日志。 |
| daydreamer-config.json | 持久化配置(频率、每会话周期数、默认白日梦类型)。 |
| ideas/NNN-标题.md | 独立的创意文件——每个白日梦会话一个。自动编号。 |
| .daydream-session/ | 会话期间用于脚本↔智能体JSON交换的临时目录。最终完成后清理。 |
前提条件
定位脚本
指挥脚本daydream.py与此SKILL.md文件位于同一目录。要在运行时找到它,请解析相对于此技能安装目录的路径。例如:
bash
如果技能安装在 ~/.claude/skills/daydreamer/
python ~/.claude/skills/daydreamer/daydream.py status
在整个文档中,$SCRIPT指代此技能目录中daydream.py的完整路径。执行命令时,将$SCRIPT替换为实际解析的路径。
白日梦类型
| 类型 | 名称 | 输出 |
|---|
| full | 完整白日梦 | 开放式——可以产生创意、建议、问题、观察、警告、类比或任何自然涌现的内容。无约束。 |
| idea |
创意生成 | 专注于产生新颖、可操作的创意——可以构建、实施或追求的内容。 |
默认类型在daydreamer-config.json中设置(defaultdaydreamtype)。用户可以在每次会话中覆盖它。
两种类型的遍历机制(模式1-4)完全相同。区别完全在于综合步骤——综合提示包含类型特定的指令,告诉智能体要产生何种输出。
首次安装
首次使用时,检查daydreamer-config.json是否存在于工作区根目录。如果不存在,执行首次安装设置:
- 1. 运行初始化命令以创建文件:
bash
python $SCRIPT init
- 2. 询问白日梦类型(这是独立的问题——不要与其他设置捆绑):
> 您希望默认使用哪种白日梦?
>
> -
完整 — 开放式。每次会话可以产生任何内容:创意、建议、问题、观察或意想不到的东西。
> -
创意 — 聚焦。每次会话专门针对生成新颖、可操作的创意。
>
> 您随时可以按需运行另一种类型——这只是设置默认行为。
- 3. 等待用户回答。用他们的选择更新daydreamer-config.json:
bash
# 对于创意模式:
# 在 daydreamer-config.json 中设置 default
daydreamtype: idea
# 对于完整模式(已是默认):
# 无需更改
- 4. 询问日程和周期数:
> 我应该多久做一次白日梦,每次会话多少个周期?
>
>
默认值: 每天一次,每次会话10个周期。
> 回复
default 接受,或指定您的偏好(例如,每天两次,15个周期)。
- 5. 等待用户回答。如果他们指定了自定义值,更新daydreamer-config.json。
- 6. 向用户确认设置并解释:
- 每天工作时,记忆将在此处写入。
- 随时可以使用/daydream触发白日梦会话。
- 自动化会话将按配置的日程运行。
- 要运行不同于默认的类型,请说/daydream idea或/daydream full。
- 7. 播种初始记忆(仅当Daydreams.MD为空或少于2个条目时):
bash
python $SCRIPT seed-memories
脚本输出Claude Code会话日志文件(JSONL)列表以及需要多少条记忆。读取每个文件并提取有意义的事件——做出的决策、构建的内容、修复的bug、完成的请求、获得的见解。跳过心跳检查、空状态轮询和琐碎的交流。
将每个事件写为一条记忆(目标共50条):
bash
python $SCRIPT add-memory <记忆文本>
什么算是有意义的事件:
- 用户要求构建的功能或工具
- 诊断或修复的bug
- 做出的设计决策或权衡
- 设置的配置或工作流
- 会话期间观察到的见解或模式
按逆时间顺序读取日志文件(最新的优先)。当有50条记忆或日志已用尽时停止。告知用户播种了多少条记忆。
斜杠命令:/daydream
用户可以使用/daydream触发强制白日梦会话。灵活解析参数:
- - /daydream → 默认类型和周期数
- /daydream 5 → 5个周期,默认类型
- /daydream idea → 默认周期数,创意类型
- /daydream idea 5 → 5个周期,创意类型
- /daydream full 20 → 20个周期,完整类型
识别full和idea作为类型关键词。任何数字都是周期计数。
通过/daydream触发时,始终将--forced传递给start和finalize。这确保每日日程不受影响。
写入记忆
记忆写入每个日历日一次(通过配置中的lastmemorywrite_date跟踪)。
写入什么
为会话期间发生的每个有意义的事件写入一条记忆条目。记忆是一个独立的观察、体验、决策或见解。
记忆格式
每条记忆应为1-2句话,捕捉谁、什么(行动或请求)以及为什么(如果清楚)。无时间戳,无冗长细节。
格式: [谁] [做了什么]。[为什么如果清楚]。
好的示例:
- - 用户要求Claude调试分页逻辑中的差一错误;根本原因是0索引与1索引页码。
- 用户和Claude设计了Daydreamer技能的指挥/演奏者架构,将随机性与创造力分离。
- Claude应用户要求将支付管道重构为更小的服务,以提高可测试性。
- 用户要求对大数据集进行数据库查询优化;Claude建议使用基于索引的分页替代OFFSET。
- Claude根据PR审查模式观察到团队更喜欢显式错误类型而非通用异常。
目标是: 一个清晰的主语(谁),一个清晰的动词(他们做了什么或要求了什么),以及有助于将此记忆与其他记忆关联的上下文。
不要写什么
不要为以下内容写入条目:
- - 没有返回工作的心跳检查。
- 没有结果的轮询循环。
- 空状态检查。
- 列表中已有的重复或琐碎相似的条目。
如何写入
使用指挥脚本:
bash
python $SCRIPT add-memory 用户要求Claude调试分页逻辑中的差一错误;根本原因是0索引与1索引页码。
脚本自动处理编号、日期标注和追加。
白日梦流程
白日梦会话是指挥脚本与智能体之间一次一个周期的对话。每个周期建立在所有先前周期的完整累积上下文之上。
流程图
智能体 脚本
| |
| start --cycles 10 |
|----------------------------->| 选取种子,滚动模式1
| promptcycle001.json | 写入带有种子上下文的提示
|<-----------------------------|
| |
| [进行创造性工作] |
| responsecycle001.json |
|----------------------------->|
| |
| next-cycle |
|----------------------------->| 读取响应1
| | 纳入上下文:种子 + 周期1
| | 滚动模式2
| promptcycle002.json | 写入带有完整上下文的提示
|<-----------------------------|
| |
| [进行创造性工作] |
| responsecycle002.json |
|----------------------------->|
| |
| next-cycle |
|----------------------------->| 读取响应2
| | 上下文:种子 + 周期1 + 周期2
|