{"id":47605756,"url":"https://github.com/crisnahine/rails-ai-context","last_synced_at":"2026-04-07T19:01:09.517Z","repository":{"id":345240551,"uuid":"1184985376","full_name":"crisnahine/rails-ai-context","owner":"crisnahine","description":"Auto-introspect your Rails app and expose it to AI assistants. 38 tools, zero config, works with Claude, Cursor, Copilot, and any MCP client.","archived":false,"fork":false,"pushed_at":"2026-04-05T14:08:03.000Z","size":7686,"stargazers_count":106,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-04-05T16:08:46.396Z","etag":null,"topics":["ai","ai-coding","claude","copilot","cursor","developer-tools","introspection","llm","mcp","model-context-protocol","opencode","rails","rails-ai","rails-tools","ruby","ruby-gem"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/rails-ai-context","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crisnahine.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"crisnahine","custom":"https://github.com/sponsors/crisnahine"}},"created_at":"2026-03-18T05:54:18.000Z","updated_at":"2026-04-05T14:08:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/crisnahine/rails-ai-context","commit_stats":null,"previous_names":["crisnahine/rails-ai-context"],"tags_count":69,"template":false,"template_full_name":null,"purl":"pkg:github/crisnahine/rails-ai-context","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisnahine%2Frails-ai-context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisnahine%2Frails-ai-context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisnahine%2Frails-ai-context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisnahine%2Frails-ai-context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crisnahine","download_url":"https://codeload.github.com/crisnahine/rails-ai-context/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisnahine%2Frails-ai-context/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31509946,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai-coding","claude","copilot","cursor","developer-tools","introspection","llm","mcp","model-context-protocol","opencode","rails","rails-ai","rails-tools","ruby","ruby-gem"],"created_at":"2026-04-01T19:19:26.674Z","updated_at":"2026-04-07T19:01:09.505Z","avatar_url":"https://github.com/crisnahine.png","language":"Ruby","funding_links":["https://github.com/sponsors/crisnahine"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# rails-ai-context\n\n**Your AI is guessing your Rails app. Every guess costs you time.**\n\n\n\u003ca href=\"https://claude.ai/claude-code\"\u003e\u003cimg src=\"https://img.shields.io/badge/Claude_Code-ee8b4a?style=for-the-badge\u0026logo=anthropic\u0026logoColor=white\" alt=\"Claude Code\"\u003e\u003c/a\u003e\n\u003ca href=\"https://cursor.com\"\u003e\u003cimg src=\"https://img.shields.io/badge/Cursor-000000?style=for-the-badge\u0026logo=cursor\u0026logoColor=white\" alt=\"Cursor\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/features/copilot\"\u003e\u003cimg src=\"https://img.shields.io/badge/GitHub_Copilot-000000?style=for-the-badge\u0026logo=githubcopilot\u0026logoColor=white\" alt=\"GitHub Copilot\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencode.ai\"\u003e\u003cimg src=\"https://img.shields.io/badge/OpenCode-4285F4?style=for-the-badge\u0026logoColor=white\" alt=\"OpenCode\"\u003e\u003c/a\u003e\n\u003ca href=\"#-cli--works-everywhere\"\u003e\u003cimg src=\"https://img.shields.io/badge/Any_Terminal-4EAA25?style=for-the-badge\u0026logo=gnubash\u0026logoColor=white\" alt=\"Any Terminal\"\u003e\u003c/a\u003e\n\n\n\n[![Gem Version](https://img.shields.io/gem/v/rails-ai-context?color=brightgreen)](https://rubygems.org/gems/rails-ai-context)\n[![Downloads](https://img.shields.io/gem/dt/rails-ai-context?color=blue)](https://rubygems.org/gems/rails-ai-context)\n[![CI](https://github.com/crisnahine/rails-ai-context/actions/workflows/ci.yml/badge.svg)](https://github.com/crisnahine/rails-ai-context/actions)\n[![MCP Registry](https://img.shields.io/badge/MCP_Registry-listed-green)](https://registry.modelcontextprotocol.io)\n\u003cbr\u003e\n[![Ruby](https://img.shields.io/badge/Ruby-3.2%20%7C%203.3%20%7C%203.4-CC342D)](https://github.com/crisnahine/rails-ai-context)\n[![Rails](https://img.shields.io/badge/Rails-7.1%20%7C%207.2%20%7C%208.0-CC0000)](https://github.com/crisnahine/rails-ai-context)\n[![Tests](https://img.shields.io/badge/Tests-1813%20passing-brightgreen)](https://github.com/crisnahine/rails-ai-context/actions)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n\u003c/div\u003e\n\n\n\n## The problem\n\nYou've seen it. Your AI:\n\n- **Writes a migration for a column that already exists** — didn't check the schema\n- **Creates a method that duplicates one in a concern** — didn't know it was there\n- **Uses the wrong association name** — `user.posts` when it's `user.articles`\n- **Generates tests that don't match your patterns** — factories when you use fixtures, or the reverse\n- **Adds a gem you already have** — or calls an API from one you don't\n- **Misses `before_action` filters from parent controllers** — then wonders why auth fails\n- **Invents a method** that isn't in your codebase — then you spend 10 minutes finding out\n\nYou catch it. You fix it. You re-prompt. It breaks something else.\n\n**The real cost of AI coding isn't the tokens — it's the correction loop.** Every guess is a round-trip: you catch it, you fix it, you re-prompt, and something adjacent breaks. This gem kills the guessing at its source.\n\n\u003cbr\u003e\n\n## Two commands. Problem gone.\n\n```bash\ngem \"rails-ai-context\", group: :development\nrails generate rails_ai_context:install\n```\n\n### Or standalone — no Gemfile needed\n\n```bash\ngem install rails-ai-context\ncd your-rails-app\nrails-ai-context init     # interactive setup\nrails-ai-context serve    # start MCP server\n```\n\n\u003cdiv align=\"center\"\u003e\n\n![Install demo](demo/demo.gif)\n\n\u003c/div\u003e\n\nNow your AI doesn't guess — it **asks your app directly.** 38 tools and 5 resource templates that query your schema, models, routes, controllers, views, and conventions on demand. Model introspection uses Prism AST parsing — every result carries a `[VERIFIED]` or `[INFERRED]` confidence tag so AI knows what's ground truth and what needs runtime checking.\n\n\u003cbr\u003e\n\n## See the difference\n\n\u003cdiv align=\"center\"\u003e\n\n![Trace demo](demo/demo-trace.gif)\n\n\u003c/div\u003e\n\nOne call returns: definition + source code + every caller grouped by type + tests. **Replaces 4-5 sequential file reads.**\n\n\u003cbr\u003e\n\n## What stops being wrong\n\nReal scenarios where AI goes sideways — and what it does instead with ground truth:\n\n| You ask AI to... | Without — AI guesses | With — AI verifies first |\n|:-----|:-----|:-----|\n| Add a `subscription_tier` column to users | Writes the migration, duplicates an existing column | Reads live schema, spots `subscription_status` already exists, asks before migrating |\n| Call `user.posts` in a controller | Uses the guess; runtime `NoMethodError` | Resolves the actual association (`user.articles`) from the model |\n| Write tests for a new model | Scaffolds with FactoryBot | Detects your fixture-based suite and matches it |\n| Fix a failing create action | Misses inherited `before_action :authenticate_user!` | Returns parent-controller filters inline with the action source |\n| Build a dashboard page | Invents Tailwind classes from memory | Returns your actual button/card/alert patterns, copy-paste ready |\n| Trace where `can_cook?` is used | Reads 6 files sequentially, still misses callers | Single call: definition + source + every caller + tests |\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eVerify it on your own app\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr\u003e\n\nRun these before and after installing to see what changes in *your* codebase:\n\n```bash\n# Schema: does AI know what columns exist?\nrails 'ai:tool[schema]' table=users\n\n# Trace: find every caller of a method across the codebase\nrails 'ai:tool[search_code]' pattern=your_method match_type=trace\n\n# Model: associations, scopes, callbacks, concerns — all resolved\nrails 'ai:tool[model_details]' model=User\n\n# Controllers: action source + inherited filters + strong params in one shot\nrails 'ai:tool[controllers]' controller=UsersController action=create\n```\n\nCompare what AI outputs with and without these tools wired in. The difference is measured in *corrections avoided*, not bytes saved.\n\n\u003c/details\u003e\n\n\u003cbr\u003e\n\n## Three ways to use it\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd width=\"33%\"\u003e\n\n### MCP Server (stdio)\n\nAI calls tools directly via the protocol. Auto-discovered through `.mcp.json`.\n\n```\nrails ai:serve\n```\n\n```\n→ rails_search_code(pattern: \"can_cook?\", match_type: \"trace\")\n→ rails_get_schema(table: \"users\")\n→ rails_analyze_feature(feature: \"billing\")\n```\n\n\u003c/td\u003e\n\u003ctd width=\"33%\"\u003e\n\n### MCP Server (HTTP)\n\nMount inside your Rails app — inherits routing, auth, and middleware.\n\n```ruby\n# config/routes.rb\nmount RailsAiContext::Engine, at: \"/mcp\"\n```\n\nNative Rails controller transport. No separate process needed.\n\n\u003c/td\u003e\n\u003ctd width=\"33%\"\u003e\n\n### CLI\n\nSame 38 tools, no server needed. Works in any terminal, any AI tool.\n\n```bash\nrails 'ai:tool[search_code]' pattern=\"can_cook?\" match_type=trace\nrails 'ai:tool[schema]' table=users\nrails 'ai:tool[analyze_feature]' feature=billing\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n\u003e **[Full Guide →](docs/GUIDE.md)** — every command, every parameter, every configuration option.\n\n\u003cbr\u003e\n\n## Real-world examples\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\"Add a subscription field to users\"\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr\u003e\n\n```bash\n# Step 1: Check what exists\nrails 'ai:tool[schema]' table=users\n# → 20 columns, types, indexes, encrypted hints, defaults\n\n# Step 2: Understand the model\nrails 'ai:tool[model_details]' model=User\n# → associations, validations, scopes, enums, callbacks, Devise modules\n\n# Step 3: See the full feature\nrails 'ai:tool[analyze_feature]' feature=subscription\n# → models + controllers + routes + services + jobs + views + tests in one shot\n```\n\nAI writes a correct migration, model change, and controller update on the **first attempt**.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\"Fix the broken cook creation flow\"\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr\u003e\n\n```bash\n# Trace what happens\nrails 'ai:tool[controllers]' controller=CooksController action=create\n# → source code + inherited filters + strong params + render map + side effects\n\n# Check the routes\nrails 'ai:tool[routes]' controller=cooks\n# → code-ready helpers (cook_path(@record)) + required params\n\n# Validate after fixing\nrails 'ai:tool[validate]' files=app/controllers/cooks_controller.rb level=rails\n# → syntax + semantics + Brakeman security scan\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\"Build a new dashboard view\"\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr\u003e\n\n```bash\n# Check existing view patterns\nrails 'ai:tool[view]' controller=dashboard\n# → templates with ivars, Turbo frames, Stimulus controllers, partial locals\n\n# See existing components + usage examples\nrails 'ai:tool[component_catalog]' detail=standard\n# → ViewComponent/Phlex props, slots, previews, sidecar assets\n\n# Get Stimulus data-attributes\nrails 'ai:tool[stimulus]' controller=chart\n# → correct HTML with dashes (not underscores) + reverse view lookup\n```\n\n\u003c/details\u003e\n\n\u003cbr\u003e\n\n## 38 Tools\n\nEvery tool is **read-only** and returns data verified against your actual app — not guesses, not training data.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eSearch \u0026 Trace\u003c/strong\u003e\u003c/summary\u003e\n\n| Tool | What it does |\n|:-----|:------------|\n| `search_code` | Trace: definition + source + callers + tests. Also: definition, call, class filters |\n| `get_edit_context` | Method-aware code extraction with class context |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eUnderstand\u003c/strong\u003e\u003c/summary\u003e\n\n| Tool | What it does |\n|:-----|:------------|\n| `analyze_feature` | Full-stack: models + controllers + routes + services + jobs + views + tests |\n| `get_context` | Composite: schema + model + controller + routes + views in one call |\n| `onboard` | Narrative app walkthrough (quick/standard/full) |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eSchema \u0026 Models\u003c/strong\u003e\u003c/summary\u003e\n\n| Tool | What it does |\n|:-----|:------------|\n| `get_schema` | Columns with indexed/unique/encrypted/default hints |\n| `get_model_details` | AST-parsed associations, validations, scopes, enums, macros — each result tagged `[VERIFIED]` or `[INFERRED]` |\n| `get_callbacks` | Callbacks in Rails execution order with source |\n| `get_concern` | Concern methods + source + which models include it |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eControllers \u0026 Routes\u003c/strong\u003e\u003c/summary\u003e\n\n| Tool | What it does |\n|:-----|:------------|\n| `get_controllers` | Actions + inherited filters + render map + strong params |\n| `get_routes` | Code-ready helpers (`cook_path(@record)`) + required params |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eViews \u0026 Frontend\u003c/strong\u003e\u003c/summary\u003e\n\n| Tool | What it does |\n|:-----|:------------|\n| `get_view` | Templates with ivars, Turbo wiring, Stimulus refs, partial locals |\n| `get_stimulus` | HTML data-attributes (dashes!) + targets + values + actions |\n| `get_partial_interface` | What locals to pass + what methods are called on them |\n| `get_turbo_map` | Broadcast → subscription wiring + mismatch warnings |\n| `get_frontend_stack` | React/Vue/Svelte/Angular, Hotwire, TypeScript, package manager |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eTesting \u0026 Quality\u003c/strong\u003e\u003c/summary\u003e\n\n| Tool | What it does |\n|:-----|:------------|\n| `get_test_info` | Fixtures + relationships + test template matching your patterns |\n| `generate_test` | Test scaffolding matching your project's patterns |\n| `validate` | Syntax + semantic + Brakeman security in one call |\n| `security_scan` | Brakeman static analysis — SQL injection, XSS, mass assignment |\n| `performance_check` | N+1 risks, missing indexes, counter_cache, eager load candidates |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eApp Config \u0026 Services\u003c/strong\u003e\u003c/summary\u003e\n\n| Tool | What it does |\n|:-----|:------------|\n| `get_conventions` | Auth checks, flash messages, create action template, test patterns |\n| `get_config` | Database, auth framework, assets, cache, queue, Action Cable |\n| `get_gems` | Notable gems with versions, categories, config file locations |\n| `get_env` | Environment variables + credentials keys (not values) |\n| `get_helper_methods` | App + framework helpers with view cross-references |\n| `get_service_pattern` | Interface, dependencies, side effects, callers |\n| `get_job_pattern` | Queue, retries, guard clauses, broadcasts, schedules |\n| `get_component_catalog` | ViewComponent/Phlex: props, slots, previews, sidecar assets |\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eData \u0026 Debugging\u003c/strong\u003e\u003c/summary\u003e\n\n| Tool | What it does |\n|:-----|:------------|\n| `dependency_graph` | Model/service dependency graph in Mermaid or text format |\n| `migration_advisor` | Migration code generation with reversibility + affected models |\n| `search_docs` | Bundled topic index with weighted keyword search |\n| `query` | Safe read-only SQL with timeout, row limit, column redaction |\n| `read_logs` | Reverse file tail with level filtering and sensitive data redaction |\n| `diagnose` | One-call error diagnosis with classification + context + git + logs |\n| `review_changes` | PR/commit review with per-file context + warnings |\n| `runtime_info` | Live DB pool, table sizes, pending migrations, cache stats, queue depth |\n| `session_context` | Session-aware context tracking across tool calls |\n\n\u003c/details\u003e\n\n\u003e **[Full parameter docs →](docs/GUIDE.md)**\n\n\u003cbr\u003e\n\n## Live Resources (VFS)\n\nAI clients can also read structured data through **resource templates** — `rails-ai-context://` URIs that introspect fresh on every request. Zero stale data.\n\n| Resource Template | What it returns |\n|:------------------|:---------------|\n| `rails-ai-context://controllers/{name}` | Actions, inherited filters, strong params |\n| `rails-ai-context://controllers/{name}/{action}` | Action source code with applicable filters |\n| `rails-ai-context://views/{path}` | View template content (path traversal protected) |\n| `rails-ai-context://routes/{controller}` | Live route map filtered by controller |\n| `rails://models/{name}` | Per-model details: associations, validations, schema |\n\nPlus 9 static resources (schema, routes, conventions, gems, controllers, config, tests, migrations, engines) that AI clients read directly.\n\n\u003cbr\u003e\n\n## Anti-Hallucination Protocol\n\nEvery generated context file ships with **6 rules that force AI verification** before writing code. The protocol targets the exact cognitive failures that produce confident-wrong code: statistical priors overriding observed facts, pattern completion beating verification, stale context lies.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eThe 6 rules (shown to AI in every CLAUDE.md / .cursor/rules / .github/instructions)\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr\u003e\n\n1. **Verify before you write.** Never reference a column, association, route, helper, method, class, partial, or gem not verified in THIS project via a tool call in THIS turn. Never invent names that \"sound right.\"\n2. **Mark every assumption.** If proceeding without verification, prefix with `[ASSUMPTION]`. Silent assumptions forbidden. \"I'd need to check X first\" is a preferred answer.\n3. **Training data describes average Rails. This app isn't average.** When something feels \"obviously\" standard Rails, query anyway. Check `rails_get_conventions` + `rails_get_gems` BEFORE scaffolding.\n4. **Check the inheritance chain before every edit.** Inherited `before_action` filters, concerns, includes, STI parents. Inheritance is never flat.\n5. **Empty tool output is information, not permission.** \"0 callers found\" signals investigation, not license to proceed on guesses.\n6. **Stale context lies. Re-query after writes.** Earlier tool output may be wrong after edits.\n\nEnabled by default. Disable with `config.anti_hallucination_rules = false` if you prefer your own rules.\n\n\u003c/details\u003e\n\n\u003cbr\u003e\n\n## How it works\n\n```\n┌─────────────────────────────────────────────────────────┐\n│  Your Rails App                                          │\n│  models + schema + routes + controllers + views + jobs   │\n└────────────────────────┬────────────────────────────────┘\n                         │ introspects (31 introspectors)\n                         ▼\n┌─────────────────────────────────────────────────────────┐\n│  rails-ai-context                                        │\n│  Prism AST parsing. Cached. Confidence-tagged results.    │\n│  VFS: rails-ai-context:// URIs introspected fresh.        │\n└────────┬──────────────────┬──────────────┬──────────────┘\n         │                  │              │\n         ▼                  ▼              ▼\n┌──────────────────┐ ┌────────────┐ ┌────────────────────┐\n│  Static Files     │ │  MCP Server │ │  CLI Tools          │\n│  CLAUDE.md        │ │  38 tools   │ │  Same 38 tools      │\n│  .cursor/rules/   │ │  5 templates│ │  No server needed   │\n│  .github/instr... │ │  stdio/HTTP │ │  rails 'ai:tool[X]' │\n└──────────────────┘ └────────────┘ └────────────────────┘\n```\n\n\u003cbr\u003e\n\n## Install\n\n**Option A — In Gemfile:**\n\n```bash\ngem \"rails-ai-context\", group: :development\nrails generate rails_ai_context:install\n```\n\n**Option B — Standalone (no Gemfile entry needed):**\n\n```bash\ngem install rails-ai-context\ncd your-rails-app\nrails-ai-context init\n```\n\nBoth paths ask which AI tools you use and whether you want MCP or CLI mode. `.mcp.json` is auto-detected by Claude Code and Cursor.\n\n\u003cbr\u003e\n\n## Commands\n\n| In-Gemfile | Standalone | What it does |\n|:-----------|:-----------|:------------|\n| `rails ai:context` | `rails-ai-context context` | Generate context files |\n| `rails 'ai:tool[NAME]'` | `rails-ai-context tool NAME` | Run any of the 38 tools |\n| `rails ai:tool` | `rails-ai-context tool --list` | List all available tools |\n| `rails ai:serve` | `rails-ai-context serve` | Start MCP server (stdio) |\n| `rails ai:doctor` | `rails-ai-context doctor` | Diagnostics + AI readiness score |\n| `rails ai:watch` | `rails-ai-context watch` | Auto-regenerate on file changes |\n\n\u003cbr\u003e\n\n## Configuration\n\n```ruby\n# config/initializers/rails_ai_context.rb\nif defined?(RailsAiContext)\n  RailsAiContext.configure do |config|\n    config.ai_tools   = %i[claude cursor] # Which AI tools to generate for\n    config.tool_mode  = :mcp              # :mcp (default) or :cli\n    config.preset     = :full             # :full (31 introspectors) or :standard (17)\n  end\nend\n```\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eAll configuration options\u003c/strong\u003e\u003c/summary\u003e\n\n\u003cbr\u003e\n\n| Option | Default | Description |\n|:-------|:--------|:------------|\n| `preset` | `:full` | `:full` (31 introspectors) or `:standard` (17) |\n| `context_mode` | `:compact` | `:compact` (150 lines) or `:full` |\n| `generate_root_files` | `true` | Set `false` for split rules only |\n| `anti_hallucination_rules` | `true` | Embed 6-rule verification protocol in generated context files |\n| `cache_ttl` | `60` | Cache TTL in seconds |\n| `max_tool_response_chars` | `200_000` | Safety cap for tool responses |\n| `live_reload` | `:auto` | `:auto`, `true`, or `false` |\n| `custom_tools` | `[]` | Additional MCP tool classes |\n| `skip_tools` | `[]` | Built-in tools to exclude |\n| `excluded_models` | `[]` | Models to skip during introspection |\n\n\u003c/details\u003e\n\n\u003cbr\u003e\n\n## Observability\n\nEvery MCP tool call and resource read fires an `ActiveSupport::Notifications` event. Subscribe with standard Rails patterns:\n\n```ruby\nActiveSupport::Notifications.subscribe(\"rails_ai_context.tools.call\") do |event|\n  Rails.logger.info \"[MCP] #{event.payload[:method]} — #{event.duration}ms\"\nend\n```\n\nEvents: `rails_ai_context.tools.call`, `rails_ai_context.resources.read`, and more. All 38 tools declare `output_schema` in the MCP protocol, so clients know the response format before calling.\n\n\u003cbr\u003e\n\n## Requirements\n\n- **Ruby** \u003e= 3.2 \u0026nbsp;\u0026nbsp; **Rails** \u003e= 7.1\n- **Optional:** `brakeman` for security scanning, `listen` for watch mode, `ripgrep` for fast search\n\n\u003cbr\u003e\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n## About\n\nBuilt by a Rails developer with 10+ years of production experience.\u003cbr\u003e\n1813 tests. 38 tools. 5 resource templates. 31 introspectors. Standalone or in-Gemfile.\u003cbr\u003e\nMIT licensed. [Contributions welcome.](CONTRIBUTING.md)\n\n\u003cbr\u003e\n\nIf this gem saves you time, consider [sponsoring the project](https://github.com/sponsors/crisnahine).\n\n\u003cbr\u003e\n\n[![MIT License](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrisnahine%2Frails-ai-context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrisnahine%2Frails-ai-context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrisnahine%2Frails-ai-context/lists"}