DEV Community

joygqz
joygqz

Posted on

Stop Teaching Your AI the Same Rules Every Session — mirrorai Mirrors Your Codebase Automatically

You spent six months building a Vue admin panel. You have a wrapped request layer, a shared component library, a consistent page structure. Every file follows the same pattern.

Then you opened Cursor and asked it to add a new list page.

It imported axios directly. It wrote inline fetch logic. It named the component wrong. It ignored your entire architecture.

Sound familiar?

The Real Problem with AI Coding Assistants

The problem isn't that AI tools are bad — it's that every session starts from zero. The AI doesn't know your conventions. It doesn't know your wrappers. It invents its own style on the spot.

You end up spending more time correcting AI output than you saved generating it.

The fix isn't to write better prompts. The fix is to give the AI a permanent memory of how your project works.

Introducing mirrorai

mirrorai is a codebase-aware AI rules generator. It analyzes your existing code and produces rule files for the AI tools you actually use:

Output file Tool
CLAUDE.md + .claude/commands/ Claude Code
.cursorrules Cursor
.windsurfrules Windsurf
.github/copilot-instructions.md GitHub Copilot
.clinerules Cline

One command to install. One /mirror-init to run. Your AI assistant finally understands your project.

How It Works

npx mirrorai install
Enter fullscreen mode Exit fullscreen mode

This drops a single mirror-init.md into .claude/commands/. Then you run /mirror-init in your AI tool.

The AI does the real work — analyzing your project, not filling in some generic template:

Your project
   ↓
Detect language, framework, and stack from manifest files
   ↓
Scan business code and cluster files by unit type
   ↓
Score patterns: appears ≥ 3 times, ≥ 50 lines per file, ≥ 80% similarity
   ↓
Generate rule files + slash commands + scaffolding templates
Enter fullscreen mode Exit fullscreen mode

The entire analysis runs inside your AI tool on your existing subscription. No API key. No cloud service. No data leaves your machine.

What Gets Generated

Rule files built from your real code

Not a generic "write clean code" checklist. The generated CLAUDE.md contains:

  • Your actual stack — exact frameworks, libraries, versions
  • Your directory layout and what each folder is for
  • Your core abstractions, and which layers must never be bypassed
  • Your infrastructure wrappers (HTTP client, auth, logging) with real usage examples
  • Your naming conventions, import order, and typing requirements
  • A reference file per pattern: "Before writing a new CRUD endpoint, read internal/handler/user.go"

Auto-execute rules that fire without a prompt

The real magic is the Auto-Execute Rules section in each generated file:

## Auto-Execute Rules

When the current task matches any of the patterns below,
immediately apply the corresponding rule without asking.

### New list page
- Trigger: "add a list page", "create a list view", "build a table page"
- Rule: use src/views/UserList.vue as reference; wrap requests with useRequest()
- Side effects: register the route in src/router/index.ts
- Scaffold first: npx mirrorai new new-list <name>
Enter fullscreen mode Exit fullscreen mode

You describe the requirement in plain English. The AI recognizes the pattern and applies the right conventions — automatically, every single time, without you repeating yourself.

Zero-token scaffolding (opt-in)

If you opt in, mirrorai also generates a plopfile.js and Handlebars templates extracted from your actual code. Scaffold locally without spending a single token, then let the AI fill in only the business logic:

npx mirrorai new new-list LeaveApproval
# → generates the skeleton from your real project pattern
# → AI writes only the business logic on top
Enter fullscreen mode Exit fullscreen mode

Works With Any Stack

mirrorai is fully language-agnostic. It adapts to whatever it finds:

  • Vue / React / Svelte / Angular frontends
  • Go / Rust / Python / Node.js backends
  • FastAPI, Django, NestJS, Spring Boot, Rails
  • Flutter mobile apps
  • CLI tools, data pipelines, GraphQL services

Re-running Is Safe

Run /mirror-init again after a major refactor. It detects existing files and asks what to do:

  • Regenerate everything
  • Refresh only existing files
  • Choose file by file

Files you wrote yourself — detected by the absence of a <!-- mirrorai:generated --> marker — get a per-file prompt: merge, overwrite, or skip. Your content is never silently clobbered.

The Before / After

Before mirrorai:

You: Add a leave-of-absence approval flow.
AI:  *imports axios directly*
     *creates a new custom fetch utility*
     *names the component inconsistently*
     *forgets to register the route*
Enter fullscreen mode Exit fullscreen mode

After mirrorai:

You: Add a leave-of-absence approval flow.
AI:  (recognizes the approval pattern from CLAUDE.md)
     → reads src/views/ApprovalList.vue as reference
     → uses useRequest() for all data fetching
     → names and structures the component correctly
     → registers the route in src/router/index.ts
     → suggests: npx mirrorai new new-approval LeaveApproval
Enter fullscreen mode Exit fullscreen mode

Get Started in 30 Seconds

# Step 1: install the command into your project
npx mirrorai install

# Step 2: run this inside Claude Code, Cursor, Windsurf, or Cline
/mirror-init
Enter fullscreen mode Exit fullscreen mode

Answer two questions — which AI tools to target, and whether to generate scaffolding — and mirrorai does the rest.


GitHub → github.com/joygqz/mirrorai

npm → npmjs.com/package/mirrorai

If this saves you from re-explaining your architecture one more time, a ⭐ on GitHub goes a long way. Issues and PRs are very welcome.

Top comments (0)