memories.sh logomemories.sh
CLI Reference

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
  1. Step 1 — Memories are written to .agents/ as tool-agnostic files (instructions.md, rules/*.md, skills/**/SKILL.md, settings.json)
  2. 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

TargetDefault Output PathDescription
agents.agents/Canonical tool-agnostic directory
cursor.cursor/rules/Cursor rules with YAML frontmatter
claudeCLAUDE.md + .claude/Claude Code instructions and rules
factory.factory/instructions.mdFactory (Droid) instructions
copilot.github/copilot-instructions.mdGitHub Copilot instructions
windsurf.windsurf/rules/memories.mdWindsurf rules (6000 char limit)
cline.clinerules/memories.mdCline rules
roo.roo/rules/memories.mdRoo rules
geminiGEMINI.mdGemini instructions

Options

OptionDescription
--types <types>Comma-separated memory types to include (default: rule,decision,fact)
--dry-runPreview generated content without writing files
--forceOverwrite files even if not managed by memories.sh
-o, --output <path>Custom output path (per-target subcommands only)
-w, --watchWatch for database changes and auto-regenerate

Examples

Interactive target selection:

memories generate

Generate the canonical .agents/ directory:

memories generate agents

Generate for a specific tool (runs .agents/ then adapts):

memories generate cursor
memories generate claude

Generate for all detected targets:

memories generate all

Watch mode (auto-regenerate on database changes):

memories generate all --watch

Preview without writing:

memories generate cursor --dry-run

The .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 vars

Path-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 format

These translate naturally to each tool's native path-scoping mechanism.

Adapter Behavior

Claude Code

.agents/ sourceOutputStrategy
instructions.mdCLAUDE.mdCopy with header
rules/*.md.claude/rules/*.mdCopy (native paths: support)
skills/**/SKILL.md.claude/skills/**/SKILL.mdCopy (identical format)
settings.json.claude/settings.jsonMerge permissions

Cursor

.agents/ sourceOutputStrategy
instructions.md.cursor/rules/memories.mdcWrap with MDC frontmatter
rules/*.md.cursor/rules/{name}.mdcTranslate paths:globs:
skills/**/SKILL.md.cursor/skills/**/SKILL.mdCopy (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.

On this page