Memory directory exists guidance

From ychampion/cskill-agents · View interactive version

Memory directory exists guidance is an AI agent skill from the GitHub repository ychampion/cskill-agents. Ensure memory directories exist once and surface consistent guidance so agents skip redundant mkdir calls.

How to use this skill

Skill file

SKILL: Memory Directory Exists Guidance

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.

Core Method

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.

Key Rules

Example Application

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.

Anti-Patterns (What NOT to do)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.