ariadna 1.3.1 → 2.0.0

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.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/ariadna.gemspec +0 -1
  3. data/data/agents/ariadna-codebase-mapper.md +34 -722
  4. data/data/agents/ariadna-debugger.md +44 -1139
  5. data/data/agents/ariadna-executor.md +75 -396
  6. data/data/agents/ariadna-planner.md +78 -1215
  7. data/data/agents/ariadna-roadmapper.md +55 -582
  8. data/data/agents/ariadna-verifier.md +60 -702
  9. data/data/ariadna/templates/config.json +8 -33
  10. data/data/ariadna/workflows/debug.md +28 -0
  11. data/data/ariadna/workflows/execute-phase.md +31 -513
  12. data/data/ariadna/workflows/map-codebase.md +20 -319
  13. data/data/ariadna/workflows/new-milestone.md +20 -365
  14. data/data/ariadna/workflows/new-project.md +19 -880
  15. data/data/ariadna/workflows/plan-phase.md +24 -443
  16. data/data/ariadna/workflows/progress.md +20 -376
  17. data/data/ariadna/workflows/quick.md +19 -221
  18. data/data/ariadna/workflows/roadmap-ops.md +28 -0
  19. data/data/ariadna/workflows/verify-work.md +23 -560
  20. data/data/commands/ariadna/add-phase.md +11 -22
  21. data/data/commands/ariadna/debug.md +11 -143
  22. data/data/commands/ariadna/execute-phase.md +12 -30
  23. data/data/commands/ariadna/insert-phase.md +7 -14
  24. data/data/commands/ariadna/map-codebase.md +16 -49
  25. data/data/commands/ariadna/new-milestone.md +12 -25
  26. data/data/commands/ariadna/new-project.md +22 -26
  27. data/data/commands/ariadna/plan-phase.md +13 -22
  28. data/data/commands/ariadna/progress.md +16 -6
  29. data/data/commands/ariadna/quick.md +9 -11
  30. data/data/commands/ariadna/remove-phase.md +9 -12
  31. data/data/commands/ariadna/verify-work.md +14 -19
  32. data/data/skills/rails-backend/API.md +138 -0
  33. data/data/skills/rails-backend/CONTROLLERS.md +154 -0
  34. data/data/skills/rails-backend/JOBS.md +132 -0
  35. data/data/skills/rails-backend/MODELS.md +213 -0
  36. data/data/skills/rails-backend/SKILL.md +169 -0
  37. data/data/skills/rails-frontend/ASSETS.md +154 -0
  38. data/data/skills/rails-frontend/COMPONENTS.md +253 -0
  39. data/data/skills/rails-frontend/SKILL.md +187 -0
  40. data/data/skills/rails-frontend/VIEWS.md +168 -0
  41. data/data/skills/rails-performance/PROFILING.md +106 -0
  42. data/data/skills/rails-performance/SKILL.md +217 -0
  43. data/data/skills/rails-security/AUDIT.md +118 -0
  44. data/data/skills/rails-security/SKILL.md +422 -0
  45. data/data/skills/rails-testing/FIXTURES.md +78 -0
  46. data/data/skills/rails-testing/SKILL.md +160 -0
  47. data/data/skills/rails-testing/SYSTEM-TESTS.md +73 -0
  48. data/lib/ariadna/installer.rb +11 -15
  49. data/lib/ariadna/tools/cli.rb +0 -12
  50. data/lib/ariadna/tools/config_manager.rb +10 -72
  51. data/lib/ariadna/tools/frontmatter.rb +23 -1
  52. data/lib/ariadna/tools/init.rb +201 -401
  53. data/lib/ariadna/tools/model_profiles.rb +6 -14
  54. data/lib/ariadna/tools/phase_manager.rb +1 -10
  55. data/lib/ariadna/tools/state_manager.rb +170 -451
  56. data/lib/ariadna/tools/template_filler.rb +4 -12
  57. data/lib/ariadna/tools/verification.rb +21 -399
  58. data/lib/ariadna/uninstaller.rb +9 -0
  59. data/lib/ariadna/version.rb +1 -1
  60. metadata +20 -91
  61. data/data/agents/ariadna-backend-executor.md +0 -261
  62. data/data/agents/ariadna-frontend-executor.md +0 -259
  63. data/data/agents/ariadna-integration-checker.md +0 -418
  64. data/data/agents/ariadna-phase-researcher.md +0 -469
  65. data/data/agents/ariadna-plan-checker.md +0 -622
  66. data/data/agents/ariadna-project-researcher.md +0 -618
  67. data/data/agents/ariadna-research-synthesizer.md +0 -236
  68. data/data/agents/ariadna-test-executor.md +0 -266
  69. data/data/ariadna/references/checkpoints.md +0 -772
  70. data/data/ariadna/references/continuation-format.md +0 -249
  71. data/data/ariadna/references/decimal-phase-calculation.md +0 -65
  72. data/data/ariadna/references/git-integration.md +0 -248
  73. data/data/ariadna/references/git-planning-commit.md +0 -38
  74. data/data/ariadna/references/model-profile-resolution.md +0 -32
  75. data/data/ariadna/references/model-profiles.md +0 -73
  76. data/data/ariadna/references/phase-argument-parsing.md +0 -61
  77. data/data/ariadna/references/planning-config.md +0 -194
  78. data/data/ariadna/references/questioning.md +0 -153
  79. data/data/ariadna/references/rails-conventions.md +0 -416
  80. data/data/ariadna/references/tdd.md +0 -267
  81. data/data/ariadna/references/ui-brand.md +0 -160
  82. data/data/ariadna/references/verification-patterns.md +0 -853
  83. data/data/ariadna/templates/codebase/architecture.md +0 -481
  84. data/data/ariadna/templates/codebase/concerns.md +0 -380
  85. data/data/ariadna/templates/codebase/conventions.md +0 -434
  86. data/data/ariadna/templates/codebase/integrations.md +0 -328
  87. data/data/ariadna/templates/codebase/stack.md +0 -189
  88. data/data/ariadna/templates/codebase/structure.md +0 -418
  89. data/data/ariadna/templates/codebase/testing.md +0 -606
  90. data/data/ariadna/templates/context.md +0 -283
  91. data/data/ariadna/templates/continue-here.md +0 -78
  92. data/data/ariadna/templates/debug-subagent-prompt.md +0 -91
  93. data/data/ariadna/templates/phase-prompt.md +0 -609
  94. data/data/ariadna/templates/planner-subagent-prompt.md +0 -117
  95. data/data/ariadna/templates/research-project/ARCHITECTURE.md +0 -439
  96. data/data/ariadna/templates/research-project/FEATURES.md +0 -168
  97. data/data/ariadna/templates/research-project/PITFALLS.md +0 -406
  98. data/data/ariadna/templates/research-project/STACK.md +0 -251
  99. data/data/ariadna/templates/research-project/SUMMARY.md +0 -247
  100. data/data/ariadna/templates/state.md +0 -176
  101. data/data/ariadna/templates/summary-complex.md +0 -59
  102. data/data/ariadna/templates/summary-minimal.md +0 -41
  103. data/data/ariadna/templates/summary-standard.md +0 -48
  104. data/data/ariadna/templates/user-setup.md +0 -310
  105. data/data/ariadna/workflows/add-phase.md +0 -111
  106. data/data/ariadna/workflows/add-todo.md +0 -157
  107. data/data/ariadna/workflows/audit-milestone.md +0 -241
  108. data/data/ariadna/workflows/check-todos.md +0 -176
  109. data/data/ariadna/workflows/complete-milestone.md +0 -644
  110. data/data/ariadna/workflows/diagnose-issues.md +0 -219
  111. data/data/ariadna/workflows/discovery-phase.md +0 -289
  112. data/data/ariadna/workflows/discuss-phase.md +0 -408
  113. data/data/ariadna/workflows/execute-plan.md +0 -448
  114. data/data/ariadna/workflows/help.md +0 -470
  115. data/data/ariadna/workflows/insert-phase.md +0 -129
  116. data/data/ariadna/workflows/list-phase-assumptions.md +0 -178
  117. data/data/ariadna/workflows/pause-work.md +0 -122
  118. data/data/ariadna/workflows/plan-milestone-gaps.md +0 -256
  119. data/data/ariadna/workflows/remove-phase.md +0 -154
  120. data/data/ariadna/workflows/research-phase.md +0 -74
  121. data/data/ariadna/workflows/resume-project.md +0 -306
  122. data/data/ariadna/workflows/set-profile.md +0 -80
  123. data/data/ariadna/workflows/settings.md +0 -145
  124. data/data/ariadna/workflows/transition.md +0 -493
  125. data/data/ariadna/workflows/update.md +0 -212
  126. data/data/ariadna/workflows/verify-phase.md +0 -226
  127. data/data/commands/ariadna/add-todo.md +0 -42
  128. data/data/commands/ariadna/audit-milestone.md +0 -42
  129. data/data/commands/ariadna/check-todos.md +0 -41
  130. data/data/commands/ariadna/complete-milestone.md +0 -136
  131. data/data/commands/ariadna/discuss-phase.md +0 -86
  132. data/data/commands/ariadna/help.md +0 -22
  133. data/data/commands/ariadna/list-phase-assumptions.md +0 -50
  134. data/data/commands/ariadna/pause-work.md +0 -35
  135. data/data/commands/ariadna/plan-milestone-gaps.md +0 -40
  136. data/data/commands/ariadna/reapply-patches.md +0 -110
  137. data/data/commands/ariadna/research-phase.md +0 -187
  138. data/data/commands/ariadna/resume-work.md +0 -40
  139. data/data/commands/ariadna/set-profile.md +0 -34
  140. data/data/commands/ariadna/settings.md +0 -36
  141. data/data/commands/ariadna/update.md +0 -37
  142. data/data/guides/backend.md +0 -3069
  143. data/data/guides/frontend.md +0 -1479
  144. data/data/guides/performance.md +0 -1193
  145. data/data/guides/security.md +0 -1522
  146. data/data/guides/style-guide.md +0 -1091
  147. data/data/guides/testing.md +0 -504
  148. data/data/templates.md +0 -94
@@ -1,117 +0,0 @@
1
- # Planner Subagent Prompt Template
2
-
3
- Template for spawning ariadna-planner agent. The agent contains all planning expertise - this template provides planning context only.
4
-
5
- ---
6
-
7
- ## Template
8
-
9
- ```markdown
10
- <planning_context>
11
-
12
- **Phase:** {phase_number}
13
- **Mode:** {standard | gap_closure}
14
-
15
- **Project State:**
16
- @.ariadna_planning/STATE.md
17
-
18
- **Roadmap:**
19
- @.ariadna_planning/ROADMAP.md
20
-
21
- **Requirements (if exists):**
22
- @.ariadna_planning/REQUIREMENTS.md
23
-
24
- **Phase Context (if exists):**
25
- @.ariadna_planning/phases/{phase_dir}/{phase}-CONTEXT.md
26
-
27
- **Research (if exists):**
28
- @.ariadna_planning/phases/{phase_dir}/{phase}-RESEARCH.md
29
-
30
- **Gap Closure (if --gaps mode):**
31
- @.ariadna_planning/phases/{phase_dir}/{phase}-VERIFICATION.md
32
- @.ariadna_planning/phases/{phase_dir}/{phase}-UAT.md
33
-
34
- </planning_context>
35
-
36
- <downstream_consumer>
37
- Output consumed by /ariadna:execute-phase
38
- Plans must be executable prompts with:
39
- - Frontmatter (wave, depends_on, files_modified, autonomous)
40
- - Tasks in XML format
41
- - Verification criteria
42
- - must_haves for goal-backward verification
43
- </downstream_consumer>
44
-
45
- <quality_gate>
46
- Before returning PLANNING COMPLETE:
47
- - [ ] PLAN.md files created in phase directory
48
- - [ ] Each plan has valid frontmatter
49
- - [ ] Tasks are specific and actionable
50
- - [ ] Dependencies correctly identified
51
- - [ ] Waves assigned for parallel execution
52
- - [ ] must_haves derived from phase goal
53
- </quality_gate>
54
- ```
55
-
56
- ---
57
-
58
- ## Placeholders
59
-
60
- | Placeholder | Source | Example |
61
- |-------------|--------|---------|
62
- | `{phase_number}` | From roadmap/arguments | `5` or `2.1` |
63
- | `{phase_dir}` | Phase directory name | `05-user-profiles` |
64
- | `{phase}` | Phase prefix | `05` |
65
- | `{standard \| gap_closure}` | Mode flag | `standard` |
66
-
67
- ---
68
-
69
- ## Usage
70
-
71
- **From /ariadna:plan-phase (standard mode):**
72
- ```python
73
- Task(
74
- prompt=filled_template,
75
- subagent_type="ariadna-planner",
76
- description="Plan Phase {phase}"
77
- )
78
- ```
79
-
80
- **From /ariadna:plan-phase --gaps (gap closure mode):**
81
- ```python
82
- Task(
83
- prompt=filled_template, # with mode: gap_closure
84
- subagent_type="ariadna-planner",
85
- description="Plan gaps for Phase {phase}"
86
- )
87
- ```
88
-
89
- ---
90
-
91
- ## Continuation
92
-
93
- For checkpoints, spawn fresh agent with:
94
-
95
- ```markdown
96
- <objective>
97
- Continue planning for Phase {phase_number}: {phase_name}
98
- </objective>
99
-
100
- <prior_state>
101
- Phase directory: @.ariadna_planning/phases/{phase_dir}/
102
- Existing plans: @.ariadna_planning/phases/{phase_dir}/*-PLAN.md
103
- </prior_state>
104
-
105
- <checkpoint_response>
106
- **Type:** {checkpoint_type}
107
- **Response:** {user_response}
108
- </checkpoint_response>
109
-
110
- <mode>
111
- Continue: {standard | gap_closure}
112
- </mode>
113
- ```
114
-
115
- ---
116
-
117
- **Note:** Planning methodology, task breakdown, dependency analysis, wave assignment, TDD detection, and goal-backward derivation are baked into the ariadna-planner agent. This template only passes context.
@@ -1,439 +0,0 @@
1
- # Architecture Research Template
2
-
3
- Template for `.ariadna_planning/research/ARCHITECTURE.md` — Rails application architecture discovery for the project.
4
-
5
- <template>
6
-
7
- ```markdown
8
- # Architecture Research
9
-
10
- **Application:** [app name]
11
- **Rails Version:** [version]
12
- **Ruby Version:** [version]
13
- **Researched:** [date]
14
- **Confidence:** [HIGH/MEDIUM/LOW]
15
-
16
- ## Application Overview
17
-
18
- ### MVC + Domain Model Structure
19
-
20
- ```
21
- ┌─────────────────────────────────────────────────────────────┐
22
- │ Request Layer │
23
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
24
- │ │ Routes │ │Middleware │ │ Rack App │ │ Channels │ │
25
- │ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
26
- │ │ │ │ │ │
27
- ├───────┴──────────────┴─────────────┴──────────────┴─────────┤
28
- │ Controller Layer │
29
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
30
- │ │Controllers│ │ Concerns │ │ Filters │ │ Params │ │
31
- │ └────┬─────┘ └──────────┘ └──────────┘ └──────────┘ │
32
- │ │ │
33
- ├───────┴─────────────────────────────────────────────────────┤
34
- │ Domain Layer │
35
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
36
- │ │ Models │ │ Concerns │ │ Callbacks│ │ Validators│ │
37
- │ └────┬─────┘ └──────────┘ └──────────┘ └──────────┘ │
38
- │ │ │
39
- ├───────┴─────────────────────────────────────────────────────┤
40
- │ Presentation Layer │
41
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
42
- │ │ Views │ │ Partials │ │ Helpers │ │Components │ │
43
- │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
44
- ├─────────────────────────────────────────────────────────────┤
45
- │ Background Layer │
46
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
47
- │ │ Jobs │ │ Mailers │ │ Channels │ │
48
- │ └──────────┘ └──────────┘ └──────────┘ │
49
- └─────────────────────────────────────────────────────────────┘
50
- ```
51
-
52
- ### Layer Responsibilities
53
-
54
- | Layer | Responsibility | Discovered Implementation |
55
- |-------|----------------|---------------------------|
56
- | Routes | [URL mapping, constraints, namespacing] | [what this project does] |
57
- | Controllers | [request handling, params, response] | [what this project does] |
58
- | Models | [domain logic, validations, associations] | [what this project does] |
59
- | Views | [presentation, templates, components] | [what this project does] |
60
- | Jobs | [background processing] | [what this project does] |
61
- | Mailers | [email delivery] | [what this project does] |
62
- | Channels | [WebSocket/real-time] | [what this project does] |
63
-
64
- ## Project Structure
65
-
66
- ```
67
- app/
68
- ├── models/ # Domain models and business logic
69
- │ └── concerns/ # [shared model concerns discovered]
70
- ├── controllers/ # Request handling
71
- │ └── concerns/ # [shared controller concerns discovered]
72
- ├── views/ # Templates and partials
73
- │ ├── layouts/ # [layout structure discovered]
74
- │ └── shared/ # [shared partials discovered]
75
- ├── helpers/ # [view helper organization discovered]
76
- ├── jobs/ # [background job organization discovered]
77
- ├── mailers/ # [mailer organization discovered]
78
- ├── channels/ # [Action Cable channels discovered]
79
- ├── components/ # [ViewComponent usage if present]
80
- ├── javascript/ # [JS approach: importmaps/jsbundling/etc.]
81
- ├── assets/ # [asset pipeline approach discovered]
82
- │ └── stylesheets/ # [CSS approach: custom CSS/Tailwind/cssbundling]
83
- config/
84
- ├── routes.rb # [routing organization discovered]
85
- ├── initializers/ # [key initializers discovered]
86
- ├── environments/ # [environment-specific config]
87
- ├── locales/ # [I18n usage discovered]
88
- db/
89
- ├── migrate/ # [migration conventions discovered]
90
- ├── schema.rb # [schema state]
91
- ├── seeds.rb # [seeding approach discovered]
92
- lib/
93
- ├── tasks/ # [rake task organization discovered]
94
- ├── [custom modules]/ # [lib/ usage discovered]
95
- test/ # [test framework: Minitest (default) or spec/ if RSpec]
96
- ├── models/ # [model test patterns discovered]
97
- ├── controllers/ # [controller test patterns discovered]
98
- ├── system/ # [system test approach discovered]
99
- ├── fixtures/ or factories/# [test data approach discovered]
100
- ```
101
-
102
- ### Structure Notes
103
-
104
- - **Namespacing:** [how app/ subdirectories are namespaced, if at all]
105
- - **Engines:** [any Rails engines mounted or extracted]
106
- - **lib/ usage:** [what lives in lib/ vs app/]
107
- - **Autoload paths:** [any custom autoload paths configured]
108
-
109
- ## Architectural Patterns Discovered
110
-
111
- ### Domain Logic Placement
112
-
113
- **Observed approach:** [rich models / service objects / interactors / form objects / other]
114
- **Where business logic lives:** [description of what was found]
115
-
116
- **Example from codebase:**
117
- ```ruby
118
- # [Brief code example showing the project's actual pattern]
119
- ```
120
-
121
- ### Concern Organization
122
-
123
- **Observed approach:** [how concerns are organized]
124
- **Shared concerns:** [concerns used across multiple models/controllers]
125
- **Model-specific concerns:** [concerns scoped to single models]
126
-
127
- **Example from codebase:**
128
- ```ruby
129
- # [Brief code example showing concern usage]
130
- ```
131
-
132
- ### Multi-Tenancy (if applicable)
133
-
134
- **Approach:** [URL path-based / subdomain / database-level / schema-level / none]
135
- **Scoping mechanism:** [how tenant scoping is applied — default_scope, Current attributes, controller filter, etc.]
136
-
137
- **Example from codebase:**
138
- ```ruby
139
- # [Brief code example showing tenant scoping]
140
- ```
141
-
142
- ### Inheritance and Polymorphism
143
-
144
- **STI usage:** [where Single Table Inheritance is used, if at all]
145
- **Polymorphic associations:** [where polymorphic belongs_to is used]
146
- **Delegated types:** [where delegated_type is used, if at all]
147
-
148
- ### Current Attributes
149
-
150
- **Usage:** [how Current attributes are set and used, if at all]
151
- **Attributes tracked:** [user, account, request_id, etc.]
152
-
153
- **Example from codebase:**
154
- ```ruby
155
- # [Brief code example showing Current usage]
156
- ```
157
-
158
- ### Callback Conventions
159
-
160
- **Observed approach:** [heavy callback usage / minimal / specific patterns]
161
- **Common callbacks:** [which lifecycle hooks are used and for what]
162
- **Avoidance patterns:** [any evidence of avoiding callbacks in favor of other approaches]
163
-
164
- ### Authentication and Authorization
165
-
166
- **Authentication:** [Rails authentication generator / has_secure_password / custom / other]
167
- **Authorization:** [Custom (before_action + Current context) / Pundit (if explicitly requested) / other]
168
-
169
- ### Internationalization (I18n)
170
-
171
- **Configuration:**
172
- - Default locale: [discovered from `config.i18n.default_locale`]
173
- - Available locales: [discovered from `config.i18n.available_locales`]
174
- - Fallback chain: [discovered from `config.i18n.fallbacks`]
175
-
176
- **Locale file organization:**
177
- ```
178
- config/locales/
179
- ├── [default locale].yml # [application-wide defaults]
180
- ├── activerecord.[lang].yml # [model and attribute translations]
181
- ├── [feature].[lang].yml # [per-feature locale files if present]
182
- └── [additional locale files discovered]
183
- ```
184
-
185
- **ActiveRecord translations:**
186
- ```yaml
187
- # config/locales/activerecord.[lang].yml
188
- [lang]:
189
- activerecord:
190
- models:
191
- [model]: [translated model name]
192
- attributes:
193
- [model]:
194
- [attribute]: [translated attribute name]
195
- ```
196
-
197
- **Translation approach:**
198
-
199
- | Context | Recommended Approach | What This Project Does |
200
- |---------|---------------------|------------------------|
201
- | Model names | `activerecord.models.*` — automatic lookup by Rails | [discovered approach] |
202
- | Attribute names | `activerecord.attributes.*` — automatic lookup by `form.label`, validations, etc. | [discovered approach] |
203
- | Form labels | `form.label :name` — resolves from `activerecord.attributes` automatically | [discovered approach] |
204
- | Validation messages | `activerecord.errors.models.*` / `errors.messages.*` — automatic lookup | [discovered approach] |
205
- | View text | Lazy lookup `t(".title")` or explicit `t("views.controller.action.title")` | [discovered approach] |
206
- | Enum values | `activerecord.attributes.[model].[enum_attribute]/[value]` | [discovered approach] |
207
- | Flash messages | Controller lazy lookup `t(".success")` or explicit keys | [discovered approach] |
208
- | Mailer subjects | `I18n.t("mailer_name.action_name.subject")` — automatic from mailer class | [discovered approach] |
209
-
210
- **CLDR / base locale data:**
211
- - `rails-i18n` gem: [present/absent — provides date, time, currency, number formats for non-English locales]
212
- - Custom date/time formats: [discovered in locale files or initializers]
213
-
214
- **Example from codebase:**
215
- ```ruby
216
- # [Brief code example showing the project's actual I18n usage pattern]
217
- ```
218
-
219
- ## Data Flow
220
-
221
- ### Standard Request Cycle
222
-
223
- ```
224
- Browser Request
225
-
226
- Router (config/routes.rb) → [routing patterns: resources, nested, concerns]
227
-
228
- Controller#action → [before_action filters, params handling]
229
-
230
- Model (ActiveRecord) → [validations, callbacks, scopes, queries]
231
-
232
- View (ERB/Haml/Slim) → [template rendering, partials, helpers]
233
-
234
- Response (HTML/JSON/Turbo Stream)
235
- ```
236
-
237
- ### Turbo / Hotwire Flow (if applicable)
238
-
239
- ```
240
- Turbo Frame Request
241
-
242
- Controller#action → [responds_to format]
243
-
244
- turbo_stream.update/replace/append
245
-
246
- Partial render → DOM update (no full page reload)
247
- ```
248
-
249
- ### Action Cable Flow (if applicable)
250
-
251
- ```
252
- WebSocket Connection
253
-
254
- Channel#subscribed → [stream_for / stream_from]
255
-
256
- Model change → [broadcast_to / Turbo::StreamsChannel]
257
-
258
- Client receives → DOM update
259
- ```
260
-
261
- ### Key Data Flows
262
-
263
- 1. **[Flow name]:** [description of how data moves through the app]
264
- 2. **[Flow name]:** [description of how data moves through the app]
265
-
266
- ## State and Context Management
267
-
268
- ### Server-Side State
269
-
270
- | Mechanism | Usage Discovered |
271
- |-----------|------------------|
272
- | Session | [what is stored in session, session store backend] |
273
- | Current attributes | [what context is threaded via Current] |
274
- | Flash messages | [how flash is used for notifications] |
275
- | Instance variables | [controller → view data passing patterns] |
276
- | Caching | [what is cached and where — fragment, low-level, etc.] |
277
-
278
- ### Client-Side State
279
-
280
- | Mechanism | Usage Discovered |
281
- |-----------|------------------|
282
- | Turbo Frames | [how Turbo Frames scope page updates] |
283
- | Stimulus controllers | [how Stimulus manages UI state] |
284
- | Data attributes | [how data-* attributes pass server state to JS] |
285
- | Local storage / cookies | [any direct browser storage usage] |
286
-
287
- ## Scaling Considerations
288
-
289
- | Area | Current Approach | Scaling Path |
290
- |------|------------------|--------------|
291
- | Database queries | [indexes, eager loading, query optimization discovered] | [read replicas, sharding, etc.] |
292
- | Caching | [fragment / Russian doll / low-level / HTTP caching discovered] | [Solid Cache, Redis, CDN, cache layers] |
293
- | Background jobs | [job queue backend, job patterns discovered] | [worker scaling, queue prioritization] |
294
- | Connection pooling | [database pool size, Puma threads discovered] | [PgBouncer for PostgreSQL, or SQLite WAL mode for better concurrent reads] |
295
- | Asset delivery | [CDN, asset pipeline, fingerprinting discovered] | [edge caching, compression] |
296
-
297
- ### Database Optimization Patterns
298
-
299
- - **Counter caches:** [where used, if at all]
300
- - **Database indexes:** [indexing strategy discovered]
301
- - **Eager loading:** [includes/preload/eager_load patterns]
302
- - **Query objects or scopes:** [how complex queries are organized]
303
- - **Batch processing:** [find_each, in_batches usage]
304
-
305
- ### Caching Strategy
306
-
307
- - **Fragment caching:** [where and how fragment caching is used]
308
- - **Russian doll caching:** [nested cache keys with touch: true]
309
- - **Low-level caching:** [Rails.cache.fetch usage]
310
- - **HTTP caching:** [stale?, fresh_when, ETags]
311
- - **Cache store:** [Solid Cache, Redis, Memcached, file store, etc.]
312
-
313
- ## Anti-Patterns to Watch For
314
-
315
- ### Anti-Pattern 1: Fat Controllers
316
-
317
- **What it looks like:** [business logic in controller actions]
318
- **Why it is a problem:** [hard to test, violates SRP, logic not reusable]
319
- **This project's approach:** [what was discovered about controller size]
320
-
321
- ### Anti-Pattern 2: N+1 Queries
322
-
323
- **What it looks like:** [loading associations in loops without eager loading]
324
- **Why it is a problem:** [performance degrades linearly with record count]
325
- **This project's approach:** [bullet gem, strict_loading, eager loading conventions]
326
-
327
- ### Anti-Pattern 3: Callback Complexity
328
-
329
- **What it looks like:** [long callback chains, callbacks with side effects]
330
- **Why it is a problem:** [hard to reason about, implicit execution order, test difficulty]
331
- **This project's approach:** [what was discovered about callback usage]
332
-
333
- ### Anti-Pattern 4: God Models
334
-
335
- **What it looks like:** [models with hundreds of methods, too many concerns]
336
- **Why it is a problem:** [hard to maintain, test, and understand]
337
- **This project's approach:** [how large models are structured — concerns, delegation, etc.]
338
-
339
- ### Anti-Pattern 5: Skipping Migrations
340
-
341
- **What it looks like:** [manual DB changes, schema.rb conflicts, missing migrations]
342
- **Why it is a problem:** [irreproducible environments, deployment failures]
343
- **This project's approach:** [migration conventions discovered]
344
-
345
- ## Integration Points
346
-
347
- ### Rails Framework Integrations
348
-
349
- | Integration | Usage Discovered | Notes |
350
- |-------------|------------------|-------|
351
- | Active Storage | [file upload handling] | [service backend: local/S3/GCS/etc.] |
352
- | Action Mailer | [email sending patterns] | [delivery method, previews] |
353
- | Action Cable | [real-time features] | [adapter: Solid Cable (default)/Redis/PostgreSQL/async] |
354
- | Action Text | [rich text editing] | [if Trix editor is used] |
355
- | Active Job | [background job framework] | [queue backend: Solid Queue/Sidekiq/GoodJob/etc.] |
356
-
357
- ### External Service Integrations
358
-
359
- | Service | Integration Pattern | Notes |
360
- |---------|---------------------|-------|
361
- | [service] | [HTTP client, gem, API wrapper] | [error handling, retries, timeouts] |
362
- | [service] | [HTTP client, gem, API wrapper] | [error handling, retries, timeouts] |
363
-
364
- ### Internal Boundaries
365
-
366
- | Boundary | Communication | Notes |
367
- |----------|---------------|-------|
368
- | [Engine / module A ↔ module B] | [API / events / direct calls] | [coupling considerations] |
369
-
370
- ## Sources
371
-
372
- - [Architecture references discovered in codebase]
373
- - [Rails guides or documentation relevant to patterns used]
374
- - [Gems or libraries that shape the architecture]
375
-
376
- ---
377
- *Architecture research for: [app name]*
378
- *Rails: [version] / Ruby: [version]*
379
- *Researched: [date]*
380
- ```
381
-
382
- </template>
383
-
384
- <guidelines>
385
-
386
- **Application Overview:**
387
- - Use ASCII box-drawing diagrams to show Rails layers and their relationships
388
- - Discover which layers the project actively uses — not every app uses Channels or Components
389
- - Map the actual MVC responsibilities as implemented, not the textbook version
390
-
391
- **Project Structure:**
392
- - Start with standard Rails conventions, then note deviations
393
- - Pay attention to how `app/models/concerns/` vs `app/controllers/concerns/` are organized
394
- - Check for engines, custom autoload paths, and non-standard directories under `app/`
395
- - Note the JavaScript approach (importmaps, jsbundling-rails, webpacker legacy, etc.)
396
-
397
- **Architectural Patterns:**
398
- - Discover, do not prescribe — the project may use service objects, interactors, or keep logic in models
399
- - Check for Current attributes usage in `app/models/current.rb`
400
- - Look at concern files to understand how shared behavior is organized
401
- - Note multi-tenancy patterns if the app serves multiple accounts/organizations
402
- - Check for STI (type column), polymorphic associations, and delegated types
403
-
404
- **Data Flow:**
405
- - Trace the full request cycle including middleware and before_action filters
406
- - Document Turbo/Hotwire patterns if present — frame requests, stream broadcasts
407
- - Note Action Cable usage and how real-time updates flow
408
-
409
- **State and Context:**
410
- - Focus on server-side state mechanisms: session, Current, flash, caching
411
- - For client-side, focus on Stimulus controllers and Turbo Frames, not SPA state stores
412
- - Note the session store backend (cookie, Redis, ActiveRecord, etc.)
413
-
414
- **Scaling:**
415
- - Focus on Rails-specific bottlenecks: N+1 queries, missing indexes, cache misses
416
- - Document the caching strategy at each level (HTTP, fragment, low-level)
417
- - Note background job infrastructure and queue backend
418
- - Check connection pool configuration relative to Puma thread count
419
-
420
- **Anti-Patterns:**
421
- - Focus on Rails-specific anti-patterns discovered in the codebase
422
- - Fat controllers, N+1 queries, callback complexity, god models, migration issues
423
- - Note what protective measures exist (bullet gem, strict_loading, rubocop-rails, etc.)
424
-
425
- **Integration Points:**
426
- - Document which Rails framework integrations are active (Active Storage, Action Cable, etc.)
427
- - Note external API integration patterns and HTTP client choices
428
- - Look for engine boundaries and module interfaces
429
-
430
- **Internationalization (I18n):**
431
- - Check `config/application.rb` for `i18n.default_locale`, `i18n.available_locales`, and `i18n.fallbacks`
432
- - Inspect `config/locales/` file organization — per-model, per-feature, or flat structure
433
- - Look for `activerecord.models.*` and `activerecord.attributes.*` keys in locale files — these power automatic lookup for model names, form labels, and validation messages
434
- - Check whether form labels use automatic lookup (`form.label :name`) vs explicit `t()` calls — explicit calls duplicate what Rails provides for free
435
- - Check Gemfile for `rails-i18n` gem — provides CLDR base data (dates, times, currency, numbers) for non-English locales
436
- - Look for validation error message customization under `activerecord.errors.models.*`
437
- - Check for lazy lookup usage in views (`t(".key")`) and controllers
438
-
439
- </guidelines>