Skip to content

feat: cortex init should create .claude/rules/ files automatically #40

@Jmeg8r

Description

@Jmeg8r

Problem

When setting up Cortex in a new project, cortex init outputs the hooks JSON but does not create the required .claude/rules/ files. This leaves a manual gap that's easy to miss:

  1. .claude/rules/cortex-memory-instructions.md — Instructs Claude to use [MEMORY:] tags
  2. .claude/rules/cortex-briefing.md — Empty file that Cortex populates with extracted memories

Without these files, Layer 3 extraction (self-reporting via [MEMORY:] tags) doesn't work because Claude doesn't know to use the tags.

Current Setup Flow (with gap)

cortex init                    # ✅ Creates project hash, outputs hooks JSON
# User manually adds hooks to .claude/settings.local.json  ✅
# User manually creates .claude/rules/ directory           ❌ Easy to miss
# User manually copies template file                       ❌ Easy to miss
# User manually creates empty briefing file                ❌ Easy to miss

Proposed Solution

Enhance cortex init to handle full Claude Code integration:

Option A: New --setup flag

cortex init              # Current behavior (backward compatible)
cortex init --setup      # Creates .claude/rules/ with both files

Option B: Interactive prompt

$ cortex init
Created project hash: 9c50fee522dcb7a2

Set up Claude Code integration? [Y/n] Y

Created: .claude/rules/cortex-memory-instructions.md
Created: .claude/rules/cortex-briefing.md

Add the following to .claude/settings.local.json:
{
  "hooks": {
    "Stop": [...],
    "PreCompact": [...],
    "SessionStart": [...]
  }
}

Option C: Single command does everything

cortex init   # Always creates rules files if .claude/ exists

Files to Create

.claude/rules/cortex-memory-instructions.md
Copy from templates/cortex-memory-instructions.md (already exists in repo)

.claude/rules/cortex-briefing.md

<!-- Cortex briefing - auto-populated by cortex session-start -->

Acceptance Criteria

  • cortex init (or --setup variant) creates .claude/rules/ directory
  • Copies cortex-memory-instructions.md template to rules directory
  • Creates empty cortex-briefing.md file
  • Outputs clear instructions for adding hooks to settings
  • Doesn't overwrite existing files without --force flag
  • Update README with complete setup flow

Context

Discovered while setting up klockthingy project — hooks were configured and working, but Layer 3 extraction wasn't happening because the rules files were missing.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions