一键导入
memory-directory-exists-guidance
Ensure memory directories exist once and surface consistent guidance so agents skip redundant mkdir calls.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Ensure memory directories exist once and surface consistent guidance so agents skip redundant mkdir calls.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Collapse multiple change sources into one caller-facing boolean so headless bootstraps know whether a downstream refresh is necessary.
After awaiting persistence work, update the shared budget state for each `tool_use_id` exactly once so no concurrent reader ever sees a half-committed decision.
Issue continuation nudges while the turn stays under budget, then halt once diminishing returns or the budget cap justify stopping.
Lazily extract referenced files for bundled skills so large prompts stay offline until needed.
Persist a cache-safe stop-hook context snapshot only for main session queries so later helpers can resume from stable state without fork pollution.
Sweep stale extension caches before activation, then fall back to a sticky manual-refresh flag if the live refresh fails.
| name | memory-directory-exists-guidance |
| description | Ensure memory directories exist once and surface consistent guidance so agents skip redundant mkdir calls. |
| metadata | {"author":"ychampion"} |
Domain: context-management
Trigger: Use whenever you plan to write memory files so the agent can assume the directory exists instead of repeatedly running mkdir -p.
Source Pattern: Distilled from reviewed context, compaction, and memory-governance patterns.
Guarantee the auto-memory directory exists with a single idempotent mkdir (handled once per session) and prepend every guidance response with the standard instructions (DIR_EXISTS_GUIDANCE and DIRS_EXIST_GUIDANCE) so Claude knows not to rerun filesystem commands that are already satisfied. Log any mkdir failure asynchronously for telemetry but let the tool write operation report the real error to keep the workflow moving.
ensureMemoryDirExists before prompting the agent to write memory files so the path is settled; the helper already swallows EEXIST and warns only on genuine failures.DIR_EXISTS_GUIDANCE or DIRS_EXIST_GUIDANCE when summarizing the directory state to the assistant so it stops issuing mkdir commands.When saving a new memory from within the CLI, run ensureMemoryDirExists(memoryDir) at session start, mention DIR_EXISTS_GUIDANCE, and proceed to open the target file without extra mkdirs; this keeps the assistant focused on writing content instead of housekeeping.
mkdir -p right before every write; the persistent guidance plus singleton helper avoids redundant logs and permission stumbling blocks.