memories generate
Generate IDE rule and instruction files from memories.
memories generate [target] [options]Generate native configuration files for AI coding tools from your memory store. Uses a two-step pipeline: memories are first written to a canonical .agents/ directory, then adapted to each tool's native format.
This command reads stored memories and writes files; it does not create new memories in the database.
How It Works
Memory Store → .agents/ (canonical) → Tool-specific configs- Step 1 — Memories are written to
.agents/as tool-agnostic files (instructions.md,rules/*.md,skills/**/SKILL.md,settings.json) - Step 2 — The
.agents/content is translated to each target's native format
This two-step pipeline means every tool gets the richest possible configuration from a single source of truth.
Targets
| Target | Default Output Path | Description |
|---|---|---|
agents | .agents/ | Canonical tool-agnostic directory |
cursor | .cursor/rules/ | Cursor rules with YAML frontmatter |
claude | CLAUDE.md + .claude/ | Claude Code instructions and rules |
factory | .factory/instructions.md | Factory (Droid) instructions |
copilot | .github/copilot-instructions.md | GitHub Copilot instructions |
windsurf | .windsurf/rules/memories.md | Windsurf rules (6000 char limit) |
cline | .clinerules/memories.md | Cline rules |
roo | .roo/rules/memories.md | Roo rules |
gemini | GEMINI.md | Gemini instructions |
Options
| Option | Description |
|---|---|
--types <types> | Comma-separated memory types to include (default: rule,decision,fact) |
--dry-run | Preview generated content without writing files |
--force | Overwrite files even if not managed by memories.sh |
-o, --output <path> | Custom output path (per-target subcommands only) |
-w, --watch | Watch for database changes and auto-regenerate |
Examples
Interactive target selection:
memories generateGenerate the canonical .agents/ directory:
memories generate agentsGenerate for a specific tool (runs .agents/ then adapts):
memories generate cursor
memories generate claudeGenerate for all detected targets:
memories generate allWatch mode (auto-regenerate on database changes):
memories generate all --watchPreview without writing:
memories generate cursor --dry-runThe .agents/ Directory
The canonical output directory used as the intermediate format for all adapters:
.agents/
├── instructions.md # Global rules, decisions, facts
├── rules/ # Path-scoped rules with frontmatter
│ ├── api.md
│ └── testing.md
├── skills/ # Agent Skills standard (SKILL.md)
│ └── deploy/
│ └── SKILL.md
└── settings.json # Permissions, hooks, env varsPath-Scoped Rules
Memories with a paths field generate individual rule files with YAML frontmatter:
---
paths:
- "src/api/**"
- "lib/api/**"
---
- Use RESTful naming conventions
- Return consistent error response formatThese translate naturally to each tool's native path-scoping mechanism.
Adapter Behavior
Claude Code
.agents/ source | Output | Strategy |
|---|---|---|
instructions.md | CLAUDE.md | Copy with header |
rules/*.md | .claude/rules/*.md | Copy (native paths: support) |
skills/**/SKILL.md | .claude/skills/**/SKILL.md | Copy (identical format) |
settings.json | .claude/settings.json | Merge permissions |
Cursor
.agents/ source | Output | Strategy |
|---|---|---|
instructions.md | .cursor/rules/memories.mdc | Wrap with MDC frontmatter |
rules/*.md | .cursor/rules/{name}.mdc | Translate paths: → globs: |
skills/**/SKILL.md | .cursor/skills/**/SKILL.md | Copy (identical format) |
Flat-File Targets
Copilot, Windsurf, Gemini, Cline, and Roo receive a single merged markdown file combining all instructions and rules with inline path annotations.
Overwrite Safety
Generated files include a <!-- Generated by memories.sh --> marker comment. The generate command will not overwrite files that lack this marker unless --force is used. This prevents accidentally overwriting hand-edited files.
Watch Mode
Watch mode monitors the database file for changes and auto-regenerates using the full two-step pipeline with a 500ms debounce. Useful during development when you're actively adding memories and want config files to stay in sync.