Skip to content

Rails engine that bootstraps AI-ready docs and project memory with SPEC-driven workflows and guides for Rails teams.

License

Notifications You must be signed in to change notification settings

puppe1990/memory_bank_rails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Memory Bank for Agents (Rails)

A Rails engine that bootstraps AI-ready development docs and project memory for Ruby on Rails teams. It ships generators, rake tasks, and optional IDE rules to keep context consistent across teammates and AI agents.

๐Ÿš€ Overview

Memory Bank for Agents (Rails) installs a structured documentation system, SPEC-driven feature workflow, and optional editor rules. Perfect for:

  • Rails (full-stack or API-only)
  • Plain Ruby service objects / gems inside your monorepo
  • Background jobs (Sidekiq/ActiveJob) and service-oriented codebases

โœจ Features

  • ๐ŸŽฏ AI-Ready Setup: Rails generators scaffold an opinionated docs workspace for agent collaboration
  • ๐Ÿ“š Memory Management: Organized Markdown docs for durable project knowledge
  • โš™๏ธ Rails Native: Installers, rake tasks, config under config/memory_bank.yml
  • ๐Ÿงช SPEC-Driven Development: Generators for requirements, design, and task breakdowns
  • ๐Ÿงฐ Editor/Tooling Hooks: Optional .cursorrules, RuboCop base config, and Solargraph hints
  • ๐Ÿ”ง Custom Guides: Point to your company playbooks and have them copied in on install
  • ๐Ÿงฏ Zero Config Defaults: Sensible paths; override via YAML when you need to

๐Ÿ“ฆ Installation

Add to your Gemfile:

gem "memory_bank_rails"

Then:

bundle install rails g memory_bank:install

The installer will create config/memory_bank.yml and (optionally) copy a default guide and .cursorrules.

One-off (no Gemfile)

bundle exec rails runner 'MemoryBank::CLI.run("init")'

Useful in sandboxes or CI steps, but the gem install is recommended.


๐ŸŽฎ Usage

Supported Development Environments

Built-in Rails Guides

  • ๐ŸŒ Rails Web โ€“ MVC, Turbo/Stimulus, Hotwire workflows
  • ๐Ÿงฑ Rails API โ€“ API-only, serializers, auth patterns
  • ๐Ÿ”Œ Background Jobs โ€“ ActiveJob/Sidekiq patterns

Custom Guides

  • ๐Ÿ”ง Company Standards โ€“ your internal conventions and checklists
  • ๐Ÿงฉ Team Workflows โ€“ squad-specific processes and release rituals
  • ๐Ÿ— Architecture Patterns โ€“ service objects, DDD, microservices boundary notes

Each guide provides:

  • Customized development guidelines and best practices
  • Architecture patterns tailored to Rails projects
  • Optional .cursorrules and RuboCop base config
  • Documentation templates for fast onboarding

โšก Quick Start

From your Rails app:

cd your-rails-app rails g memory_bank:install

Choose a development environment when prompted:

๐Ÿš€ Memory Bank Initializer (Rails) ================================= ๐Ÿ“ Available development guides: 1) ๐Ÿ“ฆ Rails Web - MVC/Turbo/Stimulus 2) ๐Ÿ“ฆ Rails API - API-only patterns 3) ๐Ÿ“ฆ Background Jobs - ActiveJob/Sidekiq 4) ๐Ÿ”ง Company Rails (Custom) 5) ๐Ÿ”ง Microservices (Custom) ? What type of memory bank would you like to install? > Rails Web - MVC/Turbo/Stimulus Rails API - API-only patterns Background Jobs - ActiveJob/Sidekiq Company Rails (Custom) Microservices (Custom) 

Or run the task directly:

rake memory_bank:init

๐Ÿ“ Project Structure

After initialization, youโ€™ll see:

your-rails-app/ โ”œโ”€ .memory_bank/ # AI memory & docs system โ”‚ โ””โ”€ developmentGuide.md # Copied from selected guide โ”œโ”€ .specs/ # Feature specs (empty initially) โ”œโ”€ .cursorrules # Optional IDE rules (from guide) โ””โ”€ config/memory_bank.yml # Memory Bank configuration 

You can expand .memory_bank/ with more docs as your project grows.


๐Ÿง  Creating Memory Bank Files

Initialize the full docs suite:

rake memory_bank:initialize

This creates:

  • projectBrief.md โ€“ foundation and goals
  • productContext.md โ€“ product vision & UX
  • activeContext.md โ€“ current focus & decisions
  • systemPatterns.md โ€“ architecture & patterns
  • techContext.md โ€“ stack & tooling
  • progress.md โ€“ status, milestones, known issues

๐Ÿ“‹ SPEC-Driven Feature Development

Generate a new SPEC:

rake memory_bank:spec:new FEATURE="export-memory-bank-to-json"

This produces:

.specs/ โ””โ”€ export-memory-bank-to-json/ โ”œโ”€ requirements.md # user stories & acceptance criteria โ”œโ”€ design.md # architecture & component design โ””โ”€ tasks.md # actionable tasks & checklist 

Workflow

  1. Requirements โ€“ capture stories and acceptance criteria
  2. Design โ€“ choose patterns, boundaries, data flow
  3. Tasks โ€“ break down implementation; track progress

๐Ÿง  Memory Bank System

Core Components

  • Project Brief โ€“ scope and success criteria
  • Product Context โ€“ UX goals and problem framing
  • Active Context โ€“ what changed; whatโ€™s next
  • System Patterns โ€“ shared decisions & tradeoffs
  • Tech Context โ€“ runtime, deps, CI/CD, linting
  • Progress โ€“ done/blocked/backlog transparency

Benefits

  • Consistent context for AI agents & humans
  • Durable knowledge retention and onboarding
  • Fewer regressions; clearer decisions trail

๐Ÿ”ง Custom Development Guides

Point the engine to your guide folder and manage entries:

rails memory_bank:configure

Youโ€™ll be prompted for a directory (can be outside the repo):

~/custom-dev-guides/ โ”œโ”€ company-rails/ โ”‚ โ”œโ”€ developmentGuide.md โ”‚ โ””โ”€ .cursorrules # optional โ”œโ”€ microservices/ โ”‚ โ”œโ”€ developmentGuide.md โ”‚ โ””โ”€ .cursorrules # optional โ””โ”€ legacy-ruby/ โ”œโ”€ developmentGuide.md โ””โ”€ .cursorrules # optional 

Required files

  • developmentGuide.md โ€“ your standards & practices
  • .cursorrules (optional) โ€“ IDE/agent hints

You can also set the folder in config/memory_bank.yml:

memory_bank: guides_path: "~/custom-dev-guides" default_guide: "company-rails"

๐Ÿ”ง Development (for contributors to the gem)

Prerequisites

  • Ruby 3.1+
  • Rails 7.0+
  • Bundler

Local setup

git clone https://github.com/your-org/memory_bank_rails.git cd memory_bank_rails bundle install # run specs bundle exec rspec # lint bundle exec rubocop # run in a dummy Rails app (engine test) bin/rails app:template LOCATION=spec/dummy/template.rb

Common scripts

  • rspec โ€“ run test suite
  • rubocop โ€“ lint/fix
  • rake build โ€“ build gem
  • rake release โ€“ release to RubyGems (maintainers)

๐Ÿงช Testing in Your App

If you track process quality in CI:

# Verify docs exist rake memory_bank:check # Generate coverage report for tasks completeness (optional) rake memory_bank:report

๐Ÿค Contributing

  1. Fork
  2. Create a feature branch
  3. Add tests
  4. Ensure rspec and rubocop pass
  5. Open a PR

๐Ÿ“„ License

MIT. See LICENSE.


๐Ÿ’ฌ Support

  • Issues: GitHub Issues
  • Discussions: GitHub Discussions

๐Ÿ™ Acknowledgments

Inspired by community work on AI agent memory systems, SPEC-driven workflows, and IDE collaboration patterns. Thanks to the Rails and broader AI developer communities for pushing the craft forward.


Appendix: Example developmentGuide.md (Company Rails)

# Company Rails Development Guide ## Overview This guide documents our Rails standards and best practices. ## Coding Standards - Prefer service objects and form objects for complex flows - Strong Parameters; avoid mass assignment in models - RuboCop + Standard enforcement in CI ## Architecture Patterns - CQRS for complex read models - Background jobs for non-HTTP work - Clear boundaries for external integrations ## Best Practices - RSpec + FactoryBot + Faker - System specs for critical user flows - Conventional commits and trunk-based development