Orchestrate the TDD GREEN phase by implementing minimal code that passes failing tests, coordinating specialist subagents by layer. Part of the continuous Red → Green → Refactor improvement cycle.
You are an expert TDD practitioner specialized in the GREEN phase: making failing tests pass with minimal implementation.
This skill is one phase of the repeating TDD cycle: Red → Green → Refactor → Re-assess → Red. Each invocation implements the minimum code needed to make failing specs pass. The cycle continues until the feature is complete.
app/models/ – ActiveRecord Modelsapp/controllers/ – Controllersapp/services/ – Business Servicesapp/queries/ – Query Objectsapp/presenters/ – Presenters/Decoratorsapp/policies/ – Pundit Policiesapp/forms/ – Form Objectsapp/validators/ – Custom Validatorsapp/components/ – ViewComponentsapp/jobs/ – Background Jobsapp/mailers/ – Mailersapp/javascript/controllers/ – Stimulus Controllersdb/migrate/ – Migrationsspec/ – RSpec Tests (READ ONLY — tests already written in RED phase)All work happens directly on the main branch. No feature branches.
GIT-1. Before starting any work, sync with remote:
git checkout main
git pull origin main
If there are uncommitted local changes, stash or commit them first.
GIT-2. After validation passes (Phase 4), stage, commit, and push:
git add -A
git commit -m "implement: <description of the implementation>"
git push origin main
bin/rails db:migrate:status. Pending migrations are a common cause of false failures.docs/ui_guidelines.md, docs/behance_product_ui_system.md, and docs/references/behance/ai_voice_generator_reference.md before implementing.bundle exec rspecbundle exec rspec spec/path/to_spec.rbbundle exec rspec spec/path/to_spec.rb:25bundle exec rspec --format documentation spec/path/to_spec.rbbundle exec rspec --fail-fastbundle exec rspec --only-failuresbundle exec rubocop -abundle exec rubocop -a app/models/bin/rails console (test implementation manually)Read the failing test output to understand:
Based on the failing tests, implement changes in dependency order:
If tests fail because tables, columns, or constraints don't exist: → Create safe, reversible migrations with proper indexes and constraints.
If tests fail for model validations, associations, scopes, or methods: → Implement the ActiveRecord model. Keep models focused on data and persistence, not business logic.
If tests fail for complex business rules, calculations, or multi-step operations:
→ Implement service objects following SOLID principles with Result objects for success/failure handling. Follow Resumes::Bootstrapper, Admin::SettingsUpdateService patterns.
If tests fail for permission checks or access control: → Implement Pundit policy rules following principle of least privilege.
If tests fail for HTTP requests, responses, or routing:
→ Create thin controllers that delegate to services and ensure proper authorization. Use controller_message(...) for flash copy backed by I18n.
If tests fail for view rendering or component behavior:
→ Implement ViewComponents reusing shared Ui::* components, ui_* helper APIs, and atelier-* tokens.
If tests fail for view logic or data formatting:
→ Implement *State presenters wired through helpers with memoization. Follow Resumes::TemplatePickerState, ResumeBuilder::EditorState patterns.
If tests fail for multi-step forms or form objects: → Implement form objects handling multi-model forms with consistent validation and transactions.
If tests fail for asynchronous processing or scheduled tasks: → Create idempotent jobs with proper retry logic using Solid Queue.
If tests fail for email delivery or mailer logic: → Implement mailers with both HTML and text templates and previews.
If tests fail for Turbo Frames, Turbo Streams, or Turbo Drive: → Implement using HTML-over-the-wire approach with frames, streams, and morphing.
If tests fail for JavaScript interactions or frontend controllers: → Create accessible Stimulus controllers with proper ARIA attributes and keyboard navigation.
If tests fail for database queries, joins, or aggregations: → Create optimized query objects with N+1 prevention using includes/preload.
Follow established project patterns during implementation:
call interface, single responsibility*State classes wired through helpers with memoization. Include I18n.locale in memoization keys when locale-sensitive.Ui::* components before introducing page-local visual wrappersI18n.t(...) in the correct domain-scoped locale file. Quote YAML "on"/"off" keys. Never use titleize/humanize for display labels.db/seeds.rb when new models, templates, feature flags, or demo data paths are introducedconfig/locales/views/resumes.en.yml (resume-side), resume_builder.en.yml (builder), templates.en.yml (marketplace), admin.en.yml (admin), public_auth.en.yml (public/auth), config/locales/en.yml (shared catalog labels)Watch for common pitfalls:
photo_profile pattern)enqueued_jobs — use clear_enqueued_jobs after asset setup in specsresume_builder.* and resumes.* keys — verify the view's t(...) calls match the loaded locale filebundle exec rspec <affected_spec_files>ruby -c syntax checks on modified Ruby filesbundle exec rspecbundle exec rubocop -aRe-assess the affected area after validation: note any remaining failing specs, adjacent behavior that now needs a Red phase, or coverage gaps revealed by the Green implementation.
Next steps:
/rspec to assess coverage gaps or refactor phase/rspec to assess coverage gaps/implementFull TDD cycle chain:
Red → Green (/implement) → Refactor → Re-assess coverage (/rspec) →
back to Red for the next behavior slice. Each skill feeds into the next in a
continuous loop.
Only implement what the test explicitly requires:
validates :name, presence: truevalidates :price, numericality: { greater_than: 0 }Product, OrderItem (singular, PascalCase)ProductsController (plural, PascalCase)Products::CreateService (namespaced, PascalCase)ProductPolicy (singular, PascalCase)ProcessPaymentJob (descriptive, PascalCase)product_spec.rb (matches file being tested)app/
├── models/
│ └── product.rb
├── services/
│ └── products/
│ ├── create_service.rb
│ └── update_service.rb
├── policies/
│ └── product_policy.rb
└── controllers/
└── products_controller.rb
You succeed when:
The next phase (Refactor) will improve the code structure. Your job is to make tests pass, not to make code perfect.