tsykvas_rails_template 0.1.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 (79) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +200 -0
  3. data/CODE_OF_CONDUCT.md +10 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +589 -0
  6. data/Rakefile +17 -0
  7. data/lib/generators/tsykvas_rails_template/companions/companions_generator.rb +273 -0
  8. data/lib/generators/tsykvas_rails_template/concept/concept_generator.rb +145 -0
  9. data/lib/generators/tsykvas_rails_template/concept/templates/component/edit.html.slim.tt +5 -0
  10. data/lib/generators/tsykvas_rails_template/concept/templates/component/edit.rb.tt +11 -0
  11. data/lib/generators/tsykvas_rails_template/concept/templates/component/index.html.slim.tt +5 -0
  12. data/lib/generators/tsykvas_rails_template/concept/templates/component/index.rb.tt +11 -0
  13. data/lib/generators/tsykvas_rails_template/concept/templates/component/new.html.slim.tt +5 -0
  14. data/lib/generators/tsykvas_rails_template/concept/templates/component/new.rb.tt +11 -0
  15. data/lib/generators/tsykvas_rails_template/concept/templates/component/show.html.slim.tt +4 -0
  16. data/lib/generators/tsykvas_rails_template/concept/templates/component/show.rb.tt +11 -0
  17. data/lib/generators/tsykvas_rails_template/concept/templates/controller.rb.tt +45 -0
  18. data/lib/generators/tsykvas_rails_template/concept/templates/operation/create.rb.tt +31 -0
  19. data/lib/generators/tsykvas_rails_template/concept/templates/operation/destroy.rb.tt +13 -0
  20. data/lib/generators/tsykvas_rails_template/concept/templates/operation/edit.rb.tt +10 -0
  21. data/lib/generators/tsykvas_rails_template/concept/templates/operation/index.rb.tt +9 -0
  22. data/lib/generators/tsykvas_rails_template/concept/templates/operation/new.rb.tt +10 -0
  23. data/lib/generators/tsykvas_rails_template/concept/templates/operation/show.rb.tt +10 -0
  24. data/lib/generators/tsykvas_rails_template/concept/templates/operation/update.rb.tt +31 -0
  25. data/lib/generators/tsykvas_rails_template/install/bootstrap_installer.rb +225 -0
  26. data/lib/generators/tsykvas_rails_template/install/install_generator.rb +298 -0
  27. data/lib/generators/tsykvas_rails_template/install/templates/.claude/agents/buddy.md +157 -0
  28. data/lib/generators/tsykvas_rails_template/install/templates/.claude/agents/code-reviewer.md +117 -0
  29. data/lib/generators/tsykvas_rails_template/install/templates/.claude/agents/security-reviewer.md +113 -0
  30. data/lib/generators/tsykvas_rails_template/install/templates/.claude/agents/tech-lead.md +150 -0
  31. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/check.md +51 -0
  32. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/code-review.md +60 -0
  33. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/docs-create.md +102 -0
  34. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/pr-review.md +81 -0
  35. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/pushit.md +160 -0
  36. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/refactor.md +132 -0
  37. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/task-sum.md +47 -0
  38. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/tests.md +67 -0
  39. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/tsykvas-claude.md +262 -0
  40. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/update-docs.md +78 -0
  41. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/update-rules.md +102 -0
  42. data/lib/generators/tsykvas_rails_template/install/templates/.claude/commands/update-tests.md +135 -0
  43. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/architecture.md +315 -0
  44. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/authentication.md +96 -0
  45. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/background-jobs.md +135 -0
  46. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/code-style.md +101 -0
  47. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/commands.md +34 -0
  48. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/companions.md +128 -0
  49. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/concepts-refactoring.md +194 -0
  50. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/database.md +135 -0
  51. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/deployment.md +138 -0
  52. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/design-system.md +322 -0
  53. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/documentation.md +89 -0
  54. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/forms.md +174 -0
  55. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/i18n.md +165 -0
  56. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/routing-and-namespaces.md +114 -0
  57. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/security.md +122 -0
  58. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/stimulus-controllers.md +166 -0
  59. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/testing-examples.md +180 -0
  60. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/testing.md +117 -0
  61. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/tsykvas_rails_template.md +280 -0
  62. data/lib/generators/tsykvas_rails_template/install/templates/.claude/docs/ui-components.md +196 -0
  63. data/lib/generators/tsykvas_rails_template/install/templates/CLAUDE.md.tt +81 -0
  64. data/lib/generators/tsykvas_rails_template/install/templates/app/concepts/base/component/base.rb +6 -0
  65. data/lib/generators/tsykvas_rails_template/install/templates/app/concepts/base/operation/base.rb +124 -0
  66. data/lib/generators/tsykvas_rails_template/install/templates/app/concepts/base/operation/result.rb +56 -0
  67. data/lib/generators/tsykvas_rails_template/install/templates/app/concepts/home/component/index.html.slim +49 -0
  68. data/lib/generators/tsykvas_rails_template/install/templates/app/concepts/home/component/index.rb +11 -0
  69. data/lib/generators/tsykvas_rails_template/install/templates/app/concepts/home/operation/index.rb +17 -0
  70. data/lib/generators/tsykvas_rails_template/install/templates/app/controllers/concerns/operations_methods.rb +148 -0
  71. data/lib/generators/tsykvas_rails_template/install/templates/app/controllers/home_controller.rb +10 -0
  72. data/lib/generators/tsykvas_rails_template/install/templates/app/policies/application_policy.rb +33 -0
  73. data/lib/generators/tsykvas_rails_template/install/templates/app/policies/home_policy.rb +8 -0
  74. data/lib/tasks/tsykvas.rake +11 -0
  75. data/lib/tsykvas_rails_template/probe.rb +236 -0
  76. data/lib/tsykvas_rails_template/railtie.rb +13 -0
  77. data/lib/tsykvas_rails_template/version.rb +5 -0
  78. data/lib/tsykvas_rails_template.rb +18 -0
  79. metadata +183 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: af81aed735e8260a376bbce78cfc516ee01f822acd2965632edc280edee0c21d
4
+ data.tar.gz: b974e65b8d5e5b3e3efc7dc1a75548ab7c7da70412199b7dd7d167c919f7fb7b
5
+ SHA512:
6
+ metadata.gz: 8e9919be27dd8bb20d9f30ea6e4a1dd9c0f4262ebd5bb3b99153af43822835501c405fa035dce98c8f3d26d5834efdcc8cc61be75a238842485918642098df1d
7
+ data.tar.gz: ecc78df86e7554142d7f7f572d962678fe41943a2449bcfe2db681afef149ebb76fc914d27c2f327fd6d9cc38fc2f4441cf927068096c0e9818f0941416afbd6
data/CHANGELOG.md ADDED
@@ -0,0 +1,200 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. The format
4
+ loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the
5
+ project follows [SemVer](https://semver.org/).
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Changed (post real-world test 2026-05-08)
10
+
11
+ - **All 20 architecture docs now ship at install** (previously only the 3
12
+ gem-canonical ones). The 17 reference templates moved out of
13
+ `templates/.claude/docs/_generated/` into `templates/.claude/docs/`
14
+ alongside the gem-canonical ones, were scrubbed of all sport-project
15
+ specifics (Company / Property / Run Club Heritage palette / `sport`
16
+ Kamal service / Ukrainian-locale assumptions), and ship verbatim.
17
+ Hosts now have full architecture coverage immediately after
18
+ `bin/rails g tsykvas_rails_template:install` — no `/tsykvas-claude`
19
+ step required to see real instructions.
20
+ - **`/tsykvas-claude` Phase 2b** is now "refresh probe-driven sections in
21
+ pre-shipped docs", not "instantiate from `_generated/` and trim
22
+ aggressively". The shipped depth is intentional and project-agnostic;
23
+ the slash command swaps placeholders for real values without
24
+ regenerating or shortening content.
25
+ - **README expanded.** Quickstart broken into 5 numbered steps with
26
+ per-step "what just happened" annotations + a "Verify it worked"
27
+ checklist (Bootstrap markers visible on home page). Added a full
28
+ Troubleshooting section covering foreman auto-install, dartsass
29
+ silenced flags, broken-initializer recovery, db connection issues,
30
+ zeitwerk failures, and missing-probe diagnostics. Architecture
31
+ references list expanded to all 20 docs with one-line summaries.
32
+
33
+ ### Fixed (post real-world test 2026-05-08)
34
+
35
+ - **`bundle_command` crash in `:companions`.** Replaced with
36
+ `Bundler.with_unbundled_env { run "bundle install" }`. The companions
37
+ generator now actually completes its bundle step.
38
+ - **`uninitialized constant ViewComponent` in `zeitwerk:check`.** Added
39
+ `require "view_component"` to the shipped `Base::Component::Base`. Same
40
+ fix for `Base::Operation::Base` with `require "pundit"`.
41
+ - **Install no longer overwrites an existing `CLAUDE.md`.** Skips with a
42
+ yellow warning suggesting `/tsykvas-claude`. Supports the
43
+ `claude init` → install gem → reinit workflow.
44
+
45
+ ### Changed
46
+
47
+ - **Install scaffolds a `Home` example concept by default** (controller +
48
+ `app/concepts/home/{operation,component}/` + `root "home#index"` route).
49
+ `bin/rails server` after install shows a working welcome page. New
50
+ `--skip-home-example` flag opts out.
51
+ - **Trimmed `.claude/docs/` shipped at install from 13 to 3.** Only the
52
+ gem-canonical docs (`tsykvas_rails_template.md`, `forms.md`,
53
+ `companions.md`) ship by default. The other 10 (architecture, code-style,
54
+ commands, testing, ui-components, stimulus-controllers, concepts-
55
+ refactoring, api-endpoints, modal-refactoring, testing-examples) live
56
+ under `lib/.../install/templates/.claude/docs/_generated/` and get
57
+ instantiated by `/tsykvas-claude` from probe data + actual host
58
+ code. Massive token-economy win for every Claude session in the host
59
+ project.
60
+ - `CLAUDE.md.tt` routing table trimmed to 3 rows (the shipped docs).
61
+ `/tsykvas-claude` adds rows when it generates the corresponding
62
+ host-specific docs.
63
+ - **`/tsykvas-claude` redesigned** with split Phase 2a (CLAUDE.md
64
+ fence integration — preserves user-authored content outside fences) and
65
+ Phase 2b (host-specific doc generation from `_generated/` reference
66
+ templates with probe-driven gating).
67
+
68
+ ### Added
69
+
70
+ - **`tsykvas_rails_template:companions` generator** — adds the recommended
71
+ companion gems used across the author's reference projects (devise,
72
+ omniauth-rails_csrf_protection, simple_form, mini_magick,
73
+ mission_control-jobs gated on solid_queue, rspec-rails, factory_bot_rails,
74
+ faker, shoulda-matchers, webmock, dotenv-rails) and runs their
75
+ `:install` sub-generators. Idempotent on re-runs. Per-group opt-out
76
+ flags (`--skip-auth`, `--skip-forms`, etc.) plus `--skip-bundle` and
77
+ `--skip-post-install`.
78
+ - **No User model generated** — explicit scope decision; run
79
+ `rails g devise User` yourself when the user schema is ready.
80
+ - **MissionControl::Jobs admin-only mount** — auto-injected into
81
+ `config/routes.rb` with a Warden lambda that's robust to a missing
82
+ User model at boot (`req.env["warden"]&.user.respond_to?(:admin?) &&
83
+ user.admin?`). Without `User#admin?` all `/jobs` requests return 404.
84
+ - **`.claude/docs/companions.md`** — per-gem reference shipped with the
85
+ gem; documents what each companion does, the `--skip-X` matrix, and
86
+ the MissionControl::Jobs constraint reasoning.
87
+ - **`.claude/docs/tsykvas_rails_template.md`** — comprehensive 10-section
88
+ gem reference loaded by Claude in any host project. Covers the four
89
+ pillars, all three generators, Probe + fences, `/tsykvas-claude`
90
+ workflow, slash commands + subagents, common gotchas, and a cross-doc
91
+ index. Treated as gem-canonical: `/tsykvas-claude` keeps it
92
+ verbatim.
93
+ - Two new routing-table rows in shipped `CLAUDE.md.tt`:
94
+ `tsykvas_rails_template.md` (big-picture) and `companions.md`.
95
+ - 38 new specs in `spec/generators/companions_generator_spec.rb`
96
+ (175 / 175 total).
97
+
98
+ ### Changed
99
+
100
+ - `:install` generator's `announce_completion` now shows three next
101
+ steps: companions → concept → `/tsykvas-claude`.
102
+ - `/tsykvas-claude` Phase 2 plan includes both new docs with
103
+ explicit handling rules (companions = host examples may be tailored;
104
+ tsykvas_rails_template = strictly verbatim).
105
+ - README's Usage section starts with the companions generator before the
106
+ concept generator; the README absorbed the previous `WORKFLOW.md` and
107
+ `UPGRADING.md` files (now deleted from the project root).
108
+ - `dummy_app` test fixture's Gemfile trimmed to bare essentials so
109
+ companion-generator opt-out tests can verify what's added without
110
+ fixture pollution.
111
+
112
+ ### Removed
113
+
114
+ - Internal helper markdown files at the project root: `ASSESSMENT.md`,
115
+ `TODO.md`, `WORKFLOW.md`, `UPGRADING.md`. Their useful content was
116
+ consolidated into the README; the rest was internal authoring notes
117
+ (assessment scoring, in-progress TODOs) that don't belong in a public
118
+ gem repo.
119
+
120
+ ## [0.1.0] - 2026-05-07
121
+
122
+ Initial public release.
123
+
124
+ ### Added
125
+
126
+ > **Pundit version pin**: `>= 2.3` (no upper bound). Pundit's API has been
127
+ > stable since 2.x; we trust SemVer rather than guessing where future
128
+ > breakage might land. CI exercises whatever resolves at install time.
129
+
130
+ #### Core architecture
131
+
132
+ - `Base::Operation::Base` and `Base::Operation::Result` (plain-Ruby
133
+ alternative to Trailblazer; Pundit-aware via `authorize!` / `policy_scope`
134
+ / `skip_authorize` / `skip_policy_scope`; `notice` / `redirect_path=` /
135
+ `model=` / `run_operation` baked in).
136
+ - `OperationsMethods` controller concern shipping the `endpoint Op, Component`
137
+ DSL (HTML / JS / JSON / `format.any` dispatch with feature-checked Bootstrap
138
+ modal handling).
139
+ - `Base::Component::Base` (ViewComponent) + `app/concepts/<feature>/{operation,component}/`
140
+ layout (autoloaded via `config.autoload_paths`).
141
+
142
+ #### Generators
143
+
144
+ - `rails g tsykvas_rails_template:install` — copies the base classes, patches
145
+ `config/application.rb`, unconditionally wires `Pundit::Authorization` +
146
+ `OperationsMethods` into `ApplicationController` (the `endpoint` DSL uses
147
+ `try(:current_user)`, so it works whether or not Devise is mounted),
148
+ generates `ApplicationPolicy` if missing, scaffolds a Home example concept
149
+ (controller + operation + component + `HomePolicy` + `root "home#index"`),
150
+ drops `.claude/{agents,commands,docs}/` payload + fenced `CLAUDE.md`.
151
+ Idempotent on re-runs.
152
+ - `rails g tsykvas_rails_template:concept Crm::Property` — scaffolds CRUD
153
+ operations (with `NotImplementedError`-raising `_params` to fail loud rather
154
+ than silently save defaults), components, Slim templates, and an optional
155
+ thin controller (`--controller`). Validates the concept name (rejects empty,
156
+ leading `::`/`/`, invalid characters).
157
+ - Opt-out flags: `--skip-application-policy`, `--skip-autoload-paths`,
158
+ `--skip-claude`, `--skip-home-example`, `--keep-sqlite`.
159
+
160
+ #### Probe + Claude tooling
161
+
162
+ - `TsykvasRailsTemplate::Probe` — deterministic Ruby inventory of the host
163
+ Rails app. Detects: Ruby/Rails versions, default git branch, API-only
164
+ configuration, Rails-Engine hosts, template engine (Slim / Haml / ERB),
165
+ auth stack (Devise / OmniAuth / Warden / JWT / BasicAuth / custom
166
+ `current_user`), authorization (Pundit / action_policy / cancancan), API
167
+ v1 presence, Bootstrap presence, test framework, background-job processors
168
+ (SolidQueue / Sidekiq / GoodJob / Delayed Job / Resque / Que),
169
+ multi-database configuration, top-level concept folders, ApplicationController
170
+ includes. Schema-versioned (`SCHEMA_VERSION = 2`).
171
+ - `bundle exec rake tsykvas:probe` — Rake task wrapper that prints the JSON
172
+ inventory. Exposed via `TsykvasRailsTemplate::Railtie`.
173
+ - 4 subagents: `buddy`, `code-reviewer`, `security-reviewer`, `tech-lead`.
174
+ - 12 slash commands: `/check`, `/code-review`, `/pr-review`, `/refactor`,
175
+ `/tests`, `/update-tests`, `/update-docs`, `/update-rules`, `/pushit`,
176
+ `/task-sum`, `/docs-create`, `/tsykvas-claude`.
177
+ - 11 architecture docs under `.claude/docs/`.
178
+ - Fence-based idempotency in `CLAUDE.md` (gem-owned content lives between
179
+ `<!-- tsykvas-template:start v=X section=NAME -->` and
180
+ `<!-- tsykvas-template:end -->` markers; user-edited content outside fences
181
+ is preserved across re-runs of `/tsykvas-claude`).
182
+ - `/tsykvas-claude` workflow: probe-driven inventory, dry-run mode with
183
+ unified diff preview, mandatory verification phase (link integrity, fence
184
+ balance, `bin/rails zeitwerk:check`, probe re-run match) with rollback on
185
+ failure.
186
+
187
+ #### Quality
188
+
189
+ - `Form`-object pattern documented in `.claude/docs/forms.md` with explicit
190
+ promotion criteria (virtual attributes, sub-operation calls during
191
+ assignment, multi-record submits).
192
+ - 128 RSpec examples (probe edge cases, install generator structure +
193
+ idempotency, concept generator validation + scaffold quality).
194
+ - CI matrix: Ruby 3.2 / 3.3 / 3.4 against Rails 7.1 / 7.2 / 8.0 (9 cells,
195
+ `fail-fast: false`).
196
+ - CI smoke job: generates a fresh Rails app, installs the gem from path, runs
197
+ both generators, verifies idempotency, runs `bin/rails zeitwerk:check`.
198
+
199
+ [Unreleased]: https://github.com/tsykvas/tsykvas_rails_template/compare/v0.1.0...HEAD
200
+ [0.1.0]: https://github.com/tsykvas/tsykvas_rails_template/releases/tag/v0.1.0
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ "tsykvas_rails_template" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
+
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
9
+
10
+ If you have any concerns about behaviour within this project, please contact us at ["tsykvasyurii@gmail.com"](mailto:"tsykvasyurii@gmail.com").
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Yurii Tsykvas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.