Rails application visualization and annotation tool (github.com)

🤖 AI Summary
Rails Lens is a developer tool/gem that embeds machine-readable schema annotations and generates ERDs for Rails apps, giving every model a precise, up-to-date description of tables, columns, enums, polymorphic/ delegated types, STI hierarchies, routes, and performance notes. By writing structured metadata directly into model files (the example shows a # <rails-lens:schema:begin> block), it makes schema facts explicit so LLMs and static tools don’t hallucinate foreign keys, enum mappings, or index presence. Change tracking is atomic (column changes map to single-line annotation edits), which keeps annotations in sync with migrations and saves time hunting through code history. Technically, Rails Lens supports PostgreSQL, MySQL, and SQLite3 with DB-specific checks (PostGIS, check constraints, generated columns, GIST indexes, storage engines, pragmas), multi-database setups, and extension detection (ClosureTree, StateMachine, vector embeddings, etc.). It detects enums, polymorphic associations, delegated types, and missing indexes, outputs ERDs in Mermaid format, and annotates routes to enable precise controller/route inference. CLI commands include annotate, remove, and erd; it targets Ruby >=3.4 and Rails >=7.2. For the AI/ML community this means faster, more accurate code analysis, better context for model-driven generation (tests, factories, docs), and fewer hallucinations when LLMs reason about database-backed applications.
Loading comments...
loading comments...