Class: RailsAiContext::Serializers::ClaudeRulesSerializer

Inherits:
Object
  • Object
show all
Includes:
StackOverviewHelper, ToolGuideHelper
Defined in:
lib/rails_ai_context/serializers/claude_rules_serializer.rb

Overview

Generates .claude/rules/ files for Claude Code auto-discovery. These provide quick-reference lists without bloating CLAUDE.md.

Constant Summary

Constants included from ToolGuideHelper

ToolGuideHelper::TOOL_ROWS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ToolGuideHelper

#build_tools_table, #render_tools_guide, #render_tools_guide_compact, #tool_call, #tool_count, #tool_mode, #tools_anti_hallucination_section, #tools_antipatterns_section, #tools_detail_guidance, #tools_header, #tools_intro, #tools_name_list, #tools_power_tool_section, #tools_rules_section, #tools_table, #tools_workflow_section

Methods included from StackOverviewHelper

#arch_labels_hash, #detect_before_actions, #detect_job_files, #detect_service_files, #full_preset_stack_lines, #model_extras_line, #notable_gems_list, #pattern_labels_hash, #project_root, #render_compact_controllers_list, #scope_names, #write_rule_files

Constructor Details

#initialize(context) ⇒ ClaudeRulesSerializer

Returns a new instance of ClaudeRulesSerializer.



13
14
15
# File 'lib/rails_ai_context/serializers/claude_rules_serializer.rb', line 13

def initialize(context)
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



11
12
13
# File 'lib/rails_ai_context/serializers/claude_rules_serializer.rb', line 11

def context
  @context
end

Instance Method Details

#call(output_dir) ⇒ Hash

Returns { written: [paths], skipped: [paths] }.

Parameters:

  • output_dir (String)

    Rails root path

Returns:

  • (Hash)

    { written: [paths], skipped: [paths] }



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rails_ai_context/serializers/claude_rules_serializer.rb', line 19

def call(output_dir)
  rules_dir = File.join(output_dir, ".claude", "rules")

  files = {
    File.join(rules_dir, "rails-context.md") => render_context_overview,
    File.join(rules_dir, "rails-schema.md") => render_schema_reference,
    File.join(rules_dir, "rails-models.md") => render_models_reference,
    File.join(rules_dir, "rails-mcp-tools.md") => render_mcp_tools_reference,
    File.join(rules_dir, "rails-components.md") => render_components_reference
  }

  write_rule_files(files)
end