rails-ai-context 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4aecabdd89f6a8bb9cb32189de791a98ebe632e3dcdb7406c4ae334eda9cb71
4
- data.tar.gz: 546be87729c99383fd4eed6cb94df487f106fac6035e7a683902bf764694297b
3
+ metadata.gz: 7aa2c43d22465356700ded7ac615f4d38ba24e1bee512658dc1ec43196935e9c
4
+ data.tar.gz: f718d8e2c3b790294e212c557216cd2babd99459fea3a5f1245f9ad09329e52d
5
5
  SHA512:
6
- metadata.gz: cf2ebe640b6dcf2d98b48dac91efb7fde81804f26d3f2b71e4f6ee59de23ed10d15e4e8b0ae5a4fe6ffc5dff2d4fb6904a99e269153da9a54909050b23d7c123
7
- data.tar.gz: 9f62a8d2e6a9e73fad88bf5bbf86881976f80aa687cee579b2116d26c3d3719d4bbb82e4226d6193531efe6299abeff8272eee82190fe4703efd8e427865e133
6
+ metadata.gz: c4c9d908941193ffd7cda89bc8a5da67a9531ffd09e723382eebc39c7ac77a06faa3958bf4048f550d0d3a5883edf9f8a67a2b62c65130847589db53d954fe5d
7
+ data.tar.gz: 38a1f37c770eff7680ed3b0acb43627a5ba36b8168eafbf087907d8e5445103ec4cc06b4cb08103e48baf772c710d6333278759789f3bcc44e7b745787cc9b11
data/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.7.1] - 2026-03-19
9
+
10
+ ### Added
11
+
12
+ - **Full MCP tool reference in all context files** — every generated file (CLAUDE.md, .cursorrules, .windsurfrules, copilot-instructions.md) now includes complete tool documentation with parameters, detail levels, pagination examples, and usage workflow. Dedicated `rails-mcp-tools` split rule files added for Claude, Cursor, Windsurf, and Copilot.
13
+
14
+ ### Fixed
15
+
16
+ - **Schema version parsing** — versions with underscores (e.g. `2024_01_15_123456`) were truncated to the first digit group. Now captures the full version string.
17
+ - **Documentation** — updated README (detail levels, pagination, generated file tree, config options), SECURITY.md (supported versions), CONTRIBUTING.md (project structure), gemspec (post-install message), demo_script.sh (all 17 generated files).
18
+
8
19
  ## [0.7.0] - 2026-03-19
9
20
 
10
21
  ### Added
data/CONTRIBUTING.md CHANGED
@@ -18,12 +18,12 @@ The test suite uses [Combustion](https://github.com/pat/combustion) to boot a mi
18
18
 
19
19
  ```
20
20
  lib/rails_ai_context/
21
- ├── introspectors/ # One class per data source (schema, models, routes, etc.)
22
- ├── tools/ # MCP tool definitions (one per introspector)
23
- ├── serializers/ # Output formatters (markdown, JSON, context files)
21
+ ├── introspectors/ # 27 introspectors (schema, models, routes, etc.)
22
+ ├── tools/ # 9 MCP tools with detail levels and pagination
23
+ ├── serializers/ # Per-assistant formatters (claude, cursor, windsurf, copilot, JSON)
24
24
  ├── server.rb # MCP server setup (stdio + HTTP)
25
25
  ├── engine.rb # Rails Engine for auto-integration
26
- └── configuration.rb # User-facing config options
26
+ └── configuration.rb # User-facing config (presets, context_mode, limits)
27
27
  ```
28
28
 
29
29
  ## Adding a New Introspector
data/README.md CHANGED
@@ -61,13 +61,26 @@ rails generate rails_ai_context:install
61
61
  rails ai:context
62
62
  ```
63
63
 
64
- This creates:
65
- - `CLAUDE.md` — for Claude Code (with behavioral rules)
66
- - `.cursorrules` — for Cursor (compact rules format)
67
- - `.windsurfrules` — for Windsurf (compact rules format)
68
- - `.github/copilot-instructions.md` — for GitHub Copilot (task-oriented)
64
+ This creates context files **and** split rule files for each AI assistant:
69
65
 
70
- Each file is tailored to the AI assistant's preferred format. **Commit these files.** Your entire team gets smarter AI assistance.
66
+ ```
67
+ CLAUDE.md # ≤150 lines (compact mode)
68
+ .claude/rules/rails-schema.md # Auto-loaded by Claude Code
69
+ .claude/rules/rails-models.md # Auto-loaded by Claude Code
70
+ .cursorrules # Legacy format (compact)
71
+ .cursor/rules/rails-project.mdc # Always-on project overview
72
+ .cursor/rules/rails-models.mdc # Auto-attaches in app/models/
73
+ .cursor/rules/rails-controllers.mdc # Auto-attaches in app/controllers/
74
+ .windsurfrules # ≤5,800 chars (within 6K limit)
75
+ .windsurf/rules/rails-context.md # New rules format
76
+ .github/copilot-instructions.md # ≤500 lines (compact mode)
77
+ .github/instructions/rails-models.instructions.md # applyTo: app/models/
78
+ .github/instructions/rails-controllers.instructions.md # applyTo: app/controllers/
79
+ ```
80
+
81
+ Each file is tailored to the AI assistant's preferred format and respects its size limits. **Commit these files.** Your entire team gets smarter AI assistance.
82
+
83
+ > **Context modes:** The default `:compact` mode generates small, focused files that point to MCP tools for details. Use `rails ai:context:full` to dump everything into the files instead (good for small apps).
71
84
 
72
85
  ### 3. MCP Server
73
86
 
@@ -182,6 +195,29 @@ The gem exposes 9 tools via MCP that AI clients can call:
182
195
 
183
196
  All tools are **read-only** — they never modify your application or database.
184
197
 
198
+ ### Detail Levels & Pagination
199
+
200
+ Tools support a `detail` parameter so AI assistants can start with an overview, then drill into specifics — critical for apps with hundreds of models or tables:
201
+
202
+ | Detail Level | What it returns | Default limit |
203
+ |-------------|-----------------|---------------|
204
+ | `summary` | Names + counts (e.g. "users — 12 columns, 3 indexes") | 50 |
205
+ | `standard` | Names + key details (e.g. column names and types) | 15 |
206
+ | `full` | Everything including indexes, FKs, constraints | 5 |
207
+
208
+ ```
209
+ # AI calls summary first to understand the landscape
210
+ rails_get_schema(detail: "summary")
211
+
212
+ # Then drills into a specific table
213
+ rails_get_schema(table: "users")
214
+
215
+ # Pagination for large schemas
216
+ rails_get_schema(detail: "summary", limit: 20, offset: 40)
217
+ ```
218
+
219
+ Schema and routes tools also support `limit` and `offset` for pagination. A configurable safety net (`max_tool_response_chars`, default 120K) truncates oversized responses with hints to use filters.
220
+
185
221
  ## MCP Resources
186
222
 
187
223
  In addition to tools, the gem registers MCP resources that AI clients can read directly:
@@ -239,13 +275,24 @@ In addition to tools, the gem registers MCP resources that AI clients can read d
239
275
  # config/initializers/rails_ai_context.rb
240
276
  RailsAiContext.configure do |config|
241
277
  # Introspector presets:
242
- # :standard — 8 core introspectors (default, fast)
278
+ # :standard — 9 core introspectors (default, fast)
243
279
  # :full — all 26 introspectors (thorough)
244
280
  config.preset = :standard
245
281
 
246
282
  # Or cherry-pick on top of a preset:
247
283
  # config.introspectors += %i[views turbo auth api]
248
284
 
285
+ # Context mode for generated files (CLAUDE.md, .cursorrules, etc.)
286
+ # :compact — smart, ≤150 lines, references MCP tools (default)
287
+ # :full — dumps everything into context files (good for small apps)
288
+ # config.context_mode = :compact
289
+
290
+ # Max lines for CLAUDE.md in compact mode
291
+ # config.claude_max_lines = 150
292
+
293
+ # Max response size for MCP tool results (safety net for large apps)
294
+ # config.max_tool_response_chars = 120_000
295
+
249
296
  # Exclude internal models from introspection
250
297
  config.excluded_models += %w[AdminUser InternalAuditLog]
251
298
 
@@ -289,13 +336,13 @@ This gives AI assistants context about your frontend JavaScript alongside your b
289
336
 
290
337
  ## Supported AI Assistants
291
338
 
292
- | AI Assistant | Context File | Format | Command |
293
- |--------------|-------------|--------|---------|
294
- | Claude Code | `CLAUDE.md` | Verbose + behavioral rules | `rails ai:context:claude` |
295
- | Cursor | `.cursorrules` | Compact imperative rules | `rails ai:context:cursor` |
296
- | Windsurf | `.windsurfrules` | Compact imperative rules | `rails ai:context:windsurf` |
297
- | GitHub Copilot | `.github/copilot-instructions.md` | Task-oriented GFM | `rails ai:context:copilot` |
298
- | JSON (generic) | `.ai-context.json` | Structured JSON | `rails ai:context:json` |
339
+ | AI Assistant | Main File | Split Rules | Command |
340
+ |--------------|-----------|------------|---------|
341
+ | Claude Code | `CLAUDE.md` | `.claude/rules/*.md` | `rails ai:context:claude` |
342
+ | Cursor | `.cursorrules` | `.cursor/rules/*.mdc` | `rails ai:context:cursor` |
343
+ | Windsurf | `.windsurfrules` | `.windsurf/rules/*.md` | `rails ai:context:windsurf` |
344
+ | GitHub Copilot | `.github/copilot-instructions.md` | `.github/instructions/*.instructions.md` | `rails ai:context:copilot` |
345
+ | JSON (generic) | `.ai-context.json` | | `rails ai:context:json` |
299
346
 
300
347
  ---
301
348
 
@@ -321,11 +368,12 @@ Introspectors that target frontend concerns (views, Turbo, Stimulus, assets) are
321
368
 
322
369
  | Command | Description |
323
370
  |---------|-------------|
324
- | `rails ai:context` | Generate all context files (skips unchanged) |
325
- | `rails ai:context:claude` | Generate CLAUDE.md only |
326
- | `rails ai:context:cursor` | Generate .cursorrules only |
327
- | `rails ai:context:windsurf` | Generate .windsurfrules only |
328
- | `rails ai:context:copilot` | Generate .github/copilot-instructions.md only |
371
+ | `rails ai:context` | Generate all context files + split rules (skips unchanged) |
372
+ | `rails ai:context:full` | Generate all files in full mode (dumps everything) |
373
+ | `rails ai:context:claude` | Generate CLAUDE.md + .claude/rules/ |
374
+ | `rails ai:context:cursor` | Generate .cursorrules + .cursor/rules/ |
375
+ | `rails ai:context:windsurf` | Generate .windsurfrules + .windsurf/rules/ |
376
+ | `rails ai:context:copilot` | Generate copilot-instructions.md + .github/instructions/ |
329
377
  | `rails ai:context:json` | Generate .ai-context.json only |
330
378
  | `rails ai:serve` | Start MCP server (stdio, for Claude Code) |
331
379
  | `rails ai:serve_http` | Start MCP server (HTTP, for remote clients) |
@@ -333,6 +381,8 @@ Introspectors that target frontend concerns (views, Turbo, Stimulus, assets) are
333
381
  | `rails ai:doctor` | Run diagnostics and report AI readiness score |
334
382
  | `rails ai:watch` | Watch for changes and auto-regenerate context files |
335
383
 
384
+ > You can also override context mode via environment variable: `CONTEXT_MODE=full rails ai:context`
385
+
336
386
  > **zsh users:** The bracket syntax `rails ai:context_for[claude]` requires quoting in zsh (`rails 'ai:context_for[claude]'`). The named tasks above (`rails ai:context:claude`) work without quoting in any shell.
337
387
 
338
388
  ---
data/SECURITY.md CHANGED
@@ -4,8 +4,9 @@
4
4
 
5
5
  | Version | Supported |
6
6
  |---------|--------------------|
7
- | 0.5.x | :white_check_mark: |
8
- | < 0.5 | :x: |
7
+ | 0.7.x | :white_check_mark: |
8
+ | 0.6.x | :white_check_mark: |
9
+ | < 0.6 | :x: |
9
10
 
10
11
  ## Reporting a Vulnerability
11
12
 
data/demo_script.sh CHANGED
@@ -8,7 +8,7 @@ echo 'Fetching gem metadata from https://rubygems.org...'
8
8
  sleep 0.3
9
9
  echo 'Resolving dependencies...'
10
10
  sleep 0.3
11
- echo 'Installing rails-ai-context 0.6.0'
11
+ echo 'Installing rails-ai-context 0.7.0'
12
12
  echo ''
13
13
  sleep 1
14
14
 
@@ -46,12 +46,28 @@ printf '\033[1;36m$\033[0m rails ai:context\n'
46
46
  echo ''
47
47
  sleep 0.2
48
48
  echo ' ✅ CLAUDE.md'
49
- sleep 0.15
49
+ sleep 0.1
50
+ echo ' ✅ .claude/rules/rails-schema.md'
51
+ sleep 0.1
52
+ echo ' ✅ .claude/rules/rails-models.md'
53
+ sleep 0.1
50
54
  echo ' ✅ .cursorrules'
51
- sleep 0.15
55
+ sleep 0.1
56
+ echo ' ✅ .cursor/rules/rails-project.mdc'
57
+ sleep 0.1
58
+ echo ' ✅ .cursor/rules/rails-models.mdc'
59
+ sleep 0.1
60
+ echo ' ✅ .cursor/rules/rails-controllers.mdc'
61
+ sleep 0.1
52
62
  echo ' ✅ .windsurfrules'
53
- sleep 0.15
63
+ sleep 0.1
64
+ echo ' ✅ .windsurf/rules/rails-context.md'
65
+ sleep 0.1
54
66
  echo ' ✅ .github/copilot-instructions.md'
67
+ sleep 0.1
68
+ echo ' ✅ .github/instructions/rails-models.instructions.md'
69
+ sleep 0.1
70
+ echo ' ✅ .github/instructions/rails-controllers.instructions.md'
55
71
  echo ''
56
72
  sleep 0.3
57
73
  printf ' \033[1;32mDone! Your AI assistants now understand your Rails app.\033[0m\n'
@@ -100,8 +100,8 @@ module RailsAiContext
100
100
  def current_schema_version
101
101
  if File.exist?(schema_file_path)
102
102
  content = File.read(schema_file_path)
103
- match = content.match(/version:\s*(\d+)_?\d*/)
104
- match ? match[1] : nil
103
+ match = content.match(/version:\s*([\d_]+)/)
104
+ match ? match[1].delete("_") : nil
105
105
  end
106
106
  end
107
107
 
@@ -22,7 +22,8 @@ module RailsAiContext
22
22
 
23
23
  files = {
24
24
  "rails-schema.md" => render_schema_reference,
25
- "rails-models.md" => render_models_reference
25
+ "rails-models.md" => render_models_reference,
26
+ "rails-mcp-tools.md" => render_mcp_tools_reference
26
27
  }
27
28
 
28
29
  files.each do |filename, content|
@@ -92,6 +93,55 @@ module RailsAiContext
92
93
 
93
94
  lines.join("\n")
94
95
  end
96
+
97
+ def render_mcp_tools_reference # rubocop:disable Metrics/MethodLength
98
+ lines = [
99
+ "# MCP Tool Reference",
100
+ "",
101
+ "All introspection tools support a `detail` parameter:",
102
+ "- `summary` — names + counts (default limit: 50)",
103
+ "- `standard` — names + key details (default limit: 15, this is the default)",
104
+ "- `full` — everything including indexes, FKs (default limit: 5)",
105
+ "",
106
+ "## rails_get_schema",
107
+ "Params: `table`, `detail`, `limit`, `offset`, `format`",
108
+ "- `rails_get_schema(detail:\"summary\")` — all tables with column counts",
109
+ "- `rails_get_schema(table:\"users\")` — full detail for one table",
110
+ "- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` — paginate",
111
+ "",
112
+ "## rails_get_model_details",
113
+ "Params: `model`, `detail`",
114
+ "- `rails_get_model_details(detail:\"summary\")` — list all model names",
115
+ "- `rails_get_model_details(model:\"User\")` — associations, validations, scopes, enums, callbacks",
116
+ "- `rails_get_model_details(detail:\"full\")` — all models with full association lists",
117
+ "",
118
+ "## rails_get_routes",
119
+ "Params: `controller`, `detail`, `limit`, `offset`",
120
+ "- `rails_get_routes(detail:\"summary\")` — route counts per controller",
121
+ "- `rails_get_routes(controller:\"users\")` — routes for one controller",
122
+ "- `rails_get_routes(detail:\"full\", limit:50)` — full table with route names",
123
+ "",
124
+ "## rails_get_controllers",
125
+ "Params: `controller`, `detail`",
126
+ "- `rails_get_controllers(detail:\"summary\")` — names + action counts",
127
+ "- `rails_get_controllers(controller:\"UsersController\")` — actions, filters, strong params",
128
+ "",
129
+ "## Other tools (no detail param)",
130
+ "- `rails_get_config` — cache store, session, timezone, middleware, initializers",
131
+ "- `rails_get_test_info` — test framework, factories/fixtures, CI config, coverage",
132
+ "- `rails_get_gems` — notable gems categorized by function",
133
+ "- `rails_get_conventions` — architecture patterns, directory structure",
134
+ "- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)` — codebase search",
135
+ "",
136
+ "## Workflow",
137
+ "1. Start with `detail:\"summary\"` to understand the landscape",
138
+ "2. Drill into specifics with filters (`table:`, `model:`, `controller:`)",
139
+ "3. Use `detail:\"full\"` only when you need indexes, FKs, constraints",
140
+ "4. Paginate large results with `limit` and `offset`"
141
+ ]
142
+
143
+ lines.join("\n")
144
+ end
95
145
  end
96
146
  end
97
147
  end
@@ -158,22 +158,50 @@ module RailsAiContext
158
158
  lines
159
159
  end
160
160
 
161
- def render_mcp_guide
161
+ def render_mcp_guide # rubocop:disable Metrics/MethodLength
162
162
  [
163
- "## MCP tools (live introspection)",
163
+ "## MCP Tool Reference",
164
164
  "",
165
- "This project exposes MCP tools. Always use `detail:\"summary\"` first,",
166
- "then drill into specifics with `detail:\"full\"` + a filter.",
165
+ "This project exposes live MCP tools. **Always start with `detail:\"summary\"`**,",
166
+ "then drill into specifics with a filter or `detail:\"full\"`.",
167
167
  "",
168
- "- `rails_get_schema` tables, columns, indexes, foreign keys",
169
- "- `rails_get_model_details` — associations, validations, scopes, enums",
170
- "- `rails_get_routes` HTTP verbs, paths, controller actions",
171
- "- `rails_get_controllers` — actions, filters, strong params",
172
- "- `rails_get_config` cache, session, timezone, middleware",
173
- "- `rails_get_test_info` framework, factories, CI config",
174
- "- `rails_get_gems` categorized gem analysis",
175
- "- `rails_get_conventions` — architecture and design patterns",
176
- "- `rails_search_code` — regex search across the codebase",
168
+ "### Detail levels (schema, routes, models, controllers)",
169
+ "",
170
+ "| Level | Returns | Default limit |",
171
+ "|-------|---------|---------------|",
172
+ "| `summary` | Names + counts | 50 |",
173
+ "| `standard` | Names + key details | 15 (default) |",
174
+ "| `full` | Everything (indexes, FKs, etc.) | 5 |",
175
+ "",
176
+ "### rails_get_schema",
177
+ "Params: `table`, `detail`, `limit`, `offset`, `format`",
178
+ "- `rails_get_schema(detail:\"summary\")` — all tables with column counts",
179
+ "- `rails_get_schema(table:\"users\")` — full detail for one table",
180
+ "- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` — paginate",
181
+ "",
182
+ "### rails_get_model_details",
183
+ "Params: `model`, `detail`",
184
+ "- `rails_get_model_details(detail:\"summary\")` — list all model names",
185
+ "- `rails_get_model_details(model:\"User\")` — associations, validations, scopes, enums, callbacks",
186
+ "- `rails_get_model_details(detail:\"full\")` — all models with full association lists",
187
+ "",
188
+ "### rails_get_routes",
189
+ "Params: `controller`, `detail`, `limit`, `offset`",
190
+ "- `rails_get_routes(detail:\"summary\")` — route counts per controller",
191
+ "- `rails_get_routes(controller:\"users\")` — routes for one controller",
192
+ "- `rails_get_routes(detail:\"full\", limit:50)` — full table with route names",
193
+ "",
194
+ "### rails_get_controllers",
195
+ "Params: `controller`, `detail`",
196
+ "- `rails_get_controllers(detail:\"summary\")` — names + action counts",
197
+ "- `rails_get_controllers(controller:\"UsersController\")` — actions, filters, strong params",
198
+ "",
199
+ "### Other tools (no detail param)",
200
+ "- `rails_get_config` — cache store, session, timezone, middleware, initializers",
201
+ "- `rails_get_test_info` — test framework, factories/fixtures, CI config, coverage",
202
+ "- `rails_get_gems` — notable gems categorized by function (auth, background jobs, etc.)",
203
+ "- `rails_get_conventions` — architecture patterns, directory structure, config files",
204
+ "- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)` — ripgrep search",
177
205
  ""
178
206
  ]
179
207
  end
@@ -20,7 +20,8 @@ module RailsAiContext
20
20
 
21
21
  files = {
22
22
  "rails-models.instructions.md" => render_models_instructions,
23
- "rails-controllers.instructions.md" => render_controllers_instructions
23
+ "rails-controllers.instructions.md" => render_controllers_instructions,
24
+ "rails-mcp-tools.instructions.md" => render_mcp_tools_instructions
24
25
  }
25
26
 
26
27
  files.each do |filename, content|
@@ -89,6 +90,54 @@ module RailsAiContext
89
90
 
90
91
  lines.join("\n")
91
92
  end
93
+
94
+ def render_mcp_tools_instructions # rubocop:disable Metrics/MethodLength
95
+ lines = [
96
+ "---",
97
+ "applyTo: \"**/*\"",
98
+ "---",
99
+ "",
100
+ "# MCP Tool Reference",
101
+ "",
102
+ "This project has MCP tools for live introspection.",
103
+ "**Start with `detail:\"summary\"`, then drill into specifics.**",
104
+ "",
105
+ "## Detail levels (schema, routes, models, controllers)",
106
+ "- `summary` — names + counts (default limit: 50)",
107
+ "- `standard` — names + key details (default limit: 15, this is the default)",
108
+ "- `full` — everything including indexes, FKs (default limit: 5)",
109
+ "",
110
+ "## rails_get_schema",
111
+ "Params: `table`, `detail`, `limit`, `offset`, `format`",
112
+ "- `rails_get_schema(detail:\"summary\")` — all tables with column counts",
113
+ "- `rails_get_schema(table:\"users\")` — full detail for one table",
114
+ "- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` — paginate",
115
+ "",
116
+ "## rails_get_model_details",
117
+ "Params: `model`, `detail`",
118
+ "- `rails_get_model_details(detail:\"summary\")` — list all model names",
119
+ "- `rails_get_model_details(model:\"User\")` — full associations, validations, scopes",
120
+ "",
121
+ "## rails_get_routes",
122
+ "Params: `controller`, `detail`, `limit`, `offset`",
123
+ "- `rails_get_routes(detail:\"summary\")` — route counts per controller",
124
+ "- `rails_get_routes(controller:\"users\")` — routes for one controller",
125
+ "",
126
+ "## rails_get_controllers",
127
+ "Params: `controller`, `detail`",
128
+ "- `rails_get_controllers(detail:\"summary\")` — names + action counts",
129
+ "- `rails_get_controllers(controller:\"UsersController\")` — actions, filters, params",
130
+ "",
131
+ "## Other tools",
132
+ "- `rails_get_config` — cache store, session, timezone, middleware",
133
+ "- `rails_get_test_info` — test framework, factories/fixtures, CI config",
134
+ "- `rails_get_gems` — notable gems categorized by function",
135
+ "- `rails_get_conventions` — architecture patterns, directory structure",
136
+ "- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)` — codebase search"
137
+ ]
138
+
139
+ lines.join("\n")
140
+ end
92
141
  end
93
142
  end
94
143
  end
@@ -81,20 +81,43 @@ module RailsAiContext
81
81
  end
82
82
 
83
83
  # MCP tools
84
- lines << "## MCP tools"
84
+ lines << "## MCP Tool Reference"
85
85
  lines << ""
86
86
  lines << "This project has MCP tools for live introspection."
87
- lines << "Call with `detail:\"summary\"` first, then filter for specifics."
87
+ lines << "**Always start with `detail:\"summary\"`, then drill into specifics.**"
88
88
  lines << ""
89
- lines << "- `rails_get_schema` database tables, columns, indexes, foreign keys"
90
- lines << "- `rails_get_model_details` — associations, validations, scopes, enums"
91
- lines << "- `rails_get_routes` — HTTP verbs, paths, controller actions"
92
- lines << "- `rails_get_controllers` — actions, filters, strong params"
93
- lines << "- `rails_get_config` — cache, session, middleware, timezone"
94
- lines << "- `rails_get_test_info` — test framework, factories, CI"
95
- lines << "- `rails_get_gems` categorized gem analysis"
96
- lines << "- `rails_get_conventions` — architecture patterns"
97
- lines << "- `rails_search_code` — regex search across codebase"
89
+ lines << "### Detail levels (schema, routes, models, controllers)"
90
+ lines << "- `summary` — names + counts (default limit: 50)"
91
+ lines << "- `standard` — names + key details (default limit: 15, this is the default)"
92
+ lines << "- `full` — everything including indexes, FKs (default limit: 5)"
93
+ lines << ""
94
+ lines << "### rails_get_schema"
95
+ lines << "Params: `table`, `detail`, `limit`, `offset`, `format`"
96
+ lines << "- `rails_get_schema(detail:\"summary\")` — all tables with column counts"
97
+ lines << "- `rails_get_schema(table:\"users\")` — full detail for one table"
98
+ lines << "- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` — paginate"
99
+ lines << ""
100
+ lines << "### rails_get_model_details"
101
+ lines << "Params: `model`, `detail`"
102
+ lines << "- `rails_get_model_details(detail:\"summary\")` — list all model names"
103
+ lines << "- `rails_get_model_details(model:\"User\")` — associations, validations, scopes, enums"
104
+ lines << ""
105
+ lines << "### rails_get_routes"
106
+ lines << "Params: `controller`, `detail`, `limit`, `offset`"
107
+ lines << "- `rails_get_routes(detail:\"summary\")` — route counts per controller"
108
+ lines << "- `rails_get_routes(controller:\"users\")` — routes for one controller"
109
+ lines << ""
110
+ lines << "### rails_get_controllers"
111
+ lines << "Params: `controller`, `detail`"
112
+ lines << "- `rails_get_controllers(detail:\"summary\")` — names + action counts"
113
+ lines << "- `rails_get_controllers(controller:\"UsersController\")` — actions, filters, params"
114
+ lines << ""
115
+ lines << "### Other tools"
116
+ lines << "- `rails_get_config` — cache store, session, timezone, middleware"
117
+ lines << "- `rails_get_test_info` — test framework, factories/fixtures, CI config"
118
+ lines << "- `rails_get_gems` — notable gems categorized by function"
119
+ lines << "- `rails_get_conventions` — architecture patterns, directory structure"
120
+ lines << "- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)` — codebase search"
98
121
  lines << ""
99
122
 
100
123
  # Conventions
@@ -24,7 +24,8 @@ module RailsAiContext
24
24
  files = {
25
25
  "rails-project.mdc" => render_project_rule,
26
26
  "rails-models.mdc" => render_models_rule,
27
- "rails-controllers.mdc" => render_controllers_rule
27
+ "rails-controllers.mdc" => render_controllers_rule,
28
+ "rails-mcp-tools.mdc" => render_mcp_tools_rule
28
29
  }
29
30
 
30
31
  files.each do |filename, content|
@@ -85,8 +86,8 @@ module RailsAiContext
85
86
  end
86
87
 
87
88
  lines << ""
88
- lines << "Use MCP tools (rails_get_schema, rails_get_model_details, etc.) for details."
89
- lines << "Call with detail:\"summary\" first, then drill into specifics."
89
+ lines << "MCP tools available see rails-mcp-tools.mdc for full reference."
90
+ lines << "Always call with detail:\"summary\" first, then drill into specifics."
90
91
 
91
92
  lines.join("\n")
92
93
  end
@@ -152,6 +153,52 @@ module RailsAiContext
152
153
 
153
154
  lines.join("\n")
154
155
  end
156
+
157
+ # Always-on MCP tool reference
158
+ def render_mcp_tools_rule # rubocop:disable Metrics/MethodLength
159
+ lines = [
160
+ "---",
161
+ "description: \"MCP tool reference with parameters and examples\"",
162
+ "alwaysApply: true",
163
+ "---",
164
+ "",
165
+ "# MCP Tool Reference",
166
+ "",
167
+ "Detail levels: summary | standard (default) | full",
168
+ "",
169
+ "## rails_get_schema",
170
+ "Params: table, detail, limit, offset, format",
171
+ "- `rails_get_schema(detail:\"summary\")` — all tables with column counts",
172
+ "- `rails_get_schema(table:\"users\")` — full detail for one table",
173
+ "- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` — paginate",
174
+ "",
175
+ "## rails_get_model_details",
176
+ "Params: model, detail",
177
+ "- `rails_get_model_details(detail:\"summary\")` — list model names",
178
+ "- `rails_get_model_details(model:\"User\")` — full detail",
179
+ "",
180
+ "## rails_get_routes",
181
+ "Params: controller, detail, limit, offset",
182
+ "- `rails_get_routes(detail:\"summary\")` — counts per controller",
183
+ "- `rails_get_routes(controller:\"users\")` — one controller",
184
+ "",
185
+ "## rails_get_controllers",
186
+ "Params: controller, detail",
187
+ "- `rails_get_controllers(detail:\"summary\")` — names + action counts",
188
+ "- `rails_get_controllers(controller:\"UsersController\")` — full detail",
189
+ "",
190
+ "## Other tools",
191
+ "- `rails_get_config` — cache, session, middleware",
192
+ "- `rails_get_test_info` — framework, factories, CI",
193
+ "- `rails_get_gems` — categorized gems",
194
+ "- `rails_get_conventions` — architecture patterns",
195
+ "- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)`",
196
+ "",
197
+ "Start with detail:\"summary\", then drill into specifics."
198
+ ]
199
+
200
+ lines.join("\n")
201
+ end
155
202
  end
156
203
  end
157
204
  end
@@ -74,17 +74,38 @@ module RailsAiContext
74
74
  end
75
75
 
76
76
  # MCP tools
77
- lines << "## MCP tools"
78
- lines << "Use detail:\"summary\" first, then drill into specifics."
79
- lines << "- rails_get_schema tables, columns, indexes, foreign keys"
80
- lines << "- rails_get_model_details — associations, validations, scopes"
81
- lines << "- rails_get_routes — HTTP verbs, paths, actions"
82
- lines << "- rails_get_controllers — actions, filters, strong params"
83
- lines << "- rails_get_config cache, session, middleware"
84
- lines << "- rails_get_test_infoframework, factories, CI"
85
- lines << "- rails_get_gemscategorized gem analysis"
86
- lines << "- rails_get_conventionsarchitecture patterns"
87
- lines << "- rails_search_code — regex codebase search"
77
+ lines << "## MCP Tool Reference"
78
+ lines << ""
79
+ lines << "All introspection tools support detail:\"summary\"|\"standard\"|\"full\"."
80
+ lines << "Start with summary, drill into specifics with a filter."
81
+ lines << ""
82
+ lines << "### rails_get_schema"
83
+ lines << "Params: table, detail, limit, offset, format"
84
+ lines << "- `rails_get_schema(detail:\"summary\")`all tables with column counts"
85
+ lines << "- `rails_get_schema(table:\"users\")`full detail for one table"
86
+ lines << "- `rails_get_schema(detail:\"summary\", limit:20, offset:40)` paginate"
87
+ lines << ""
88
+ lines << "### rails_get_model_details"
89
+ lines << "Params: model, detail"
90
+ lines << "- `rails_get_model_details(detail:\"summary\")` — list model names"
91
+ lines << "- `rails_get_model_details(model:\"User\")` — full associations, validations, scopes"
92
+ lines << ""
93
+ lines << "### rails_get_routes"
94
+ lines << "Params: controller, detail, limit, offset"
95
+ lines << "- `rails_get_routes(detail:\"summary\")` — route counts per controller"
96
+ lines << "- `rails_get_routes(controller:\"users\")` — routes for one controller"
97
+ lines << ""
98
+ lines << "### rails_get_controllers"
99
+ lines << "Params: controller, detail"
100
+ lines << "- `rails_get_controllers(detail:\"summary\")` — names + action counts"
101
+ lines << "- `rails_get_controllers(controller:\"UsersController\")` — full detail"
102
+ lines << ""
103
+ lines << "### Other tools"
104
+ lines << "- `rails_get_config` — cache, session, middleware, timezone"
105
+ lines << "- `rails_get_test_info` — framework, factories, CI"
106
+ lines << "- `rails_get_gems` — categorized gem analysis"
107
+ lines << "- `rails_get_conventions` — architecture patterns"
108
+ lines << "- `rails_search_code(pattern:\"regex\", file_type:\"rb\", max_results:20)`"
88
109
  lines << ""
89
110
 
90
111
  # Rules
@@ -21,7 +21,8 @@ module RailsAiContext
21
21
  skipped = []
22
22
 
23
23
  files = {
24
- "rails-context.md" => render_context_rule
24
+ "rails-context.md" => render_context_rule,
25
+ "rails-mcp-tools.md" => render_mcp_tools_rule
25
26
  }
26
27
 
27
28
  files.each do |filename, content|
@@ -47,6 +48,37 @@ module RailsAiContext
47
48
  # Reuse WindsurfSerializer content
48
49
  WindsurfSerializer.new(context).call
49
50
  end
51
+
52
+ def render_mcp_tools_rule # rubocop:disable Metrics/MethodLength
53
+ lines = [
54
+ "# MCP Tool Reference",
55
+ "",
56
+ "Detail levels: summary | standard (default) | full",
57
+ "",
58
+ "## Schema",
59
+ "rails_get_schema(table:\"name\"|detail:\"summary\"|limit:N|offset:N)",
60
+ "",
61
+ "## Models",
62
+ "rails_get_model_details(model:\"Name\"|detail:\"summary\")",
63
+ "",
64
+ "## Routes",
65
+ "rails_get_routes(controller:\"name\"|detail:\"summary\"|limit:N|offset:N)",
66
+ "",
67
+ "## Controllers",
68
+ "rails_get_controllers(controller:\"Name\"|detail:\"summary\")",
69
+ "",
70
+ "## Other",
71
+ "- rails_get_config — cache, session, middleware",
72
+ "- rails_get_test_info — framework, factories, CI",
73
+ "- rails_get_gems — categorized gems",
74
+ "- rails_get_conventions — architecture patterns",
75
+ "- rails_search_code(pattern:\"regex\"|file_type:\"rb\"|max_results:N)",
76
+ "",
77
+ "Start with detail:\"summary\", then drill into specifics."
78
+ ]
79
+
80
+ lines.join("\n")
81
+ end
50
82
  end
51
83
  end
52
84
  end
@@ -71,17 +71,19 @@ module RailsAiContext
71
71
  end
72
72
  end
73
73
 
74
- # MCP tools
75
- lines << "# MCP tools available"
76
- lines << "Use detail:\"summary\" first, then drill into specifics."
77
- lines << "- rails_get_schema — tables, columns, indexes"
78
- lines << "- rails_get_model_details — associations, validations"
79
- lines << "- rails_get_routes — HTTP verbs, paths, actions"
80
- lines << "- rails_get_controllersactions, filters, params"
81
- lines << "- rails_search_coderegex codebase search"
74
+ # MCP tools — compact but complete (character budget is tight)
75
+ lines << "# MCP Tools (detail:\"summary\"|\"standard\"|\"full\")"
76
+ lines << "- rails_get_schema(table:\"name\"|detail:\"summary\"|limit:N|offset:N)"
77
+ lines << "- rails_get_model_details(model:\"Name\"|detail:\"summary\")"
78
+ lines << "- rails_get_routes(controller:\"name\"|detail:\"summary\"|limit:N|offset:N)"
79
+ lines << "- rails_get_controllers(controller:\"Name\"|detail:\"summary\")"
80
+ lines << "- rails_get_configcache, session, middleware"
81
+ lines << "- rails_get_test_infoframework, factories, CI"
82
+ lines << "- rails_get_gems — categorized gems"
83
+ lines << "- rails_get_conventions — architecture patterns"
84
+ lines << "- rails_search_code(pattern:\"regex\"|file_type:\"rb\"|max_results:N)"
85
+ lines << "Start with detail:\"summary\", then drill into specifics."
82
86
  lines << ""
83
-
84
- # Conventions
85
87
  lines << "# Rules"
86
88
  lines << "- Follow existing patterns"
87
89
  lines << "- Check schema via MCP before writing migrations"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsAiContext
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-ai-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - crisnahine
@@ -265,8 +265,8 @@ metadata:
265
265
  post_install_message: |
266
266
  rails-ai-context installed! Quick start:
267
267
  rails generate rails_ai_context:install
268
- rails ai:context # generate all context files
269
- rails ai:context:claude # generate CLAUDE.md only (zsh-friendly)
268
+ rails ai:context # generate context files (compact mode)
269
+ rails ai:context:full # full dump (good for small apps)
270
270
  rails ai:serve # start MCP server for Claude Code / Cursor
271
271
  rdoc_options: []
272
272
  require_paths: