rails-ai-context

45 MCP tools that give AI agents live access to your Rails schema, models, routes & conventions.

View the Project on GitHub crisnahine/rails-ai-context

CLI Reference

All commands available from the terminal.

Quickstart · Tools Reference · Standalone · Configuration


Two CLI interfaces

Context Command prefix Example
In-Gemfile (Rake) rails ai: rails 'ai:tool[schema]' table=users
Standalone (Thor) rails-ai-context rails-ai-context tool schema --table users

Both provide the same 45 tools and functionality.


Commands

serve

Start the MCP server.

rails ai:serve                                        # stdio (default)
rails-ai-context serve                                # stdio (default)
rails-ai-context serve --transport http --port 6029   # HTTP transport
Option Default Description
--transport stdio stdio or http
--port 6029 HTTP listen port
--no-boot off Skip booting the app; answer from source alone

tool

Run any of the 45 MCP tools from the terminal.

# Rake syntax
rails 'ai:tool[schema]' table=users detail=full
rails 'ai:tool[search_code]' pattern="publishable?" match_type=trace
rails 'ai:tool[model_details]' model=User

# Thor syntax
rails-ai-context tool schema --table users --detail full
rails-ai-context tool search_code --pattern "publishable?" --match-type trace
rails-ai-context tool model_details --model User
Option Description
--list List all available tools
--json Output as JSON
--no-boot Skip booting the app; answer from source alone

The static tier and --no-boot

Every command that reads the app takes --no-boot: tool, serve, context, inspect, facts, preset, watch and init. It skips the boot and answers from source alone, which is what you want on a repo you have just cloned, on an app whose boot is broken, and in CI where booting costs more than the answer.

The same tier is entered automatically when a boot fails, so you get an answer either way. Answers that need a running app are marked [UNAVAILABLE: ...] rather than guessed, and everything else is tagged [STATIC] instead of [VERIFIED]. docs/COMPATIBILITY.md lists which of the 40 introspectors answer in which tier.

doctor is the exception: diagnosing the boot is its job, so it refuses --no-boot and still exits 1 when the app cannot start.

rails-ai-context tool models --no-boot        # no boot, no database, no Gemfile
rails-ai-context context --no-boot            # writes CLAUDE.md from source

Tool name resolution

All of these resolve to the same tool:

rails 'ai:tool[schema]'
rails 'ai:tool[get_schema]'
rails 'ai:tool[rails_get_schema]'

Resolution order: exact match → rails_ prefix → rails_get_ prefix → get_ prefix.

context

Generate static context files.

rails ai:context              # All configured formats
rails ai:context:claude       # Claude only
rails ai:context:cursor       # Cursor only
rails ai:context:copilot      # Copilot only
rails ai:context:opencode     # OpenCode only
rails ai:context:json         # JSON export

rails-ai-context context                # All
rails-ai-context context --format claude # Specific format
Option Default Description
--format all configured claude, cursor, copilot, opencode, codex, json, all

doctor

Run the diagnostic checks and report an AI readiness score.

rails ai:doctor
rails-ai-context doctor
rails-ai-context doctor --strict   # exit 1 when any check fails (CI gate)
rails ai:doctor STRICT=1           # rake equivalent

Checks include: schema existence, pending migrations, model files, routes, MCP config validity, introspector health, ripgrep availability, Prism gem, Brakeman gem, listen gem, gitignore security, auto_mount security, schema size, view count, and more.

watch

Watch for file changes and auto-regenerate context files.

rails ai:watch
rails-ai-context watch

Requires the listen gem. Watches app/, config/, db/, lib/tasks/.

init (standalone only)

Interactive setup for standalone mode.

rails-ai-context init

Asks which AI tools to configure and whether to use MCP or CLI mode. Creates .rails-ai-context.yml and MCP config files.

version

rails-ai-context version

inspect

Print introspection summary as JSON.

rails-ai-context inspect

Rake tasks (in-Gemfile only)

Task Description
rails ai:context Generate context for all configured formats
rails ai:context:claude Generate Claude context
rails ai:context:cursor Generate Cursor context
rails ai:context:copilot Generate Copilot context
rails ai:context:opencode Generate OpenCode context
rails ai:context:json Generate JSON export
rails ai:serve Start MCP server (stdio)
rails ai:tool List tools or run a tool
rails ai:doctor Run diagnostics
rails ai:watch Watch mode
rails ai:setup Interactive setup (alternative to generator)

Tool argument syntax

Rake format

rails 'ai:tool[tool_name]' key=value key2=value2

Thor format

rails-ai-context tool tool_name --key value --key2 value2

JSON output

Add --json for machine-readable output:

rails-ai-context tool schema --table users --json

Common workflows

Quick schema check

rails 'ai:tool[schema]' table=users

Trace a method

rails 'ai:tool[search_code]' pattern="process_payment" match_type=trace

Full feature analysis

rails 'ai:tool[analyze_feature]' feature=billing

Check AI readiness

rails ai:doctor

Regenerate after changes

rails ai:context

← Security · Standalone Mode →

Back to Home