Michael Okafor
@michael_okafor • 1 months ago
Have a coding agent plan before coding: assumptions, commit-sized steps with tests, a de-risking order, open questions and what's out of scope.
featurecontextconstraints{{feature}}{{context}}{{constraints}}feature: Let users import contacts from a CSV file (up to 50,000 rows), map CSV columns to contact fields, preview the first rows, then run the import and see a summary of created, updated and skipped rows. context: Rails 8, Postgres, Solid Queue for background jobs, Hotwire/Turbo for UI, Active Storage configured with S3. Contact model: account_id, email (unique per account), name, phone, company, tags (array). constraints: Must not block web requests. Existing contacts must never be overwritten silently. Ship behind a Flipper feature flag.
ContactImport model and migration (status, mapping JSON, counts, error report) + Flipper flag | model, migration, flipper initializer | model spec for state transitions | ~80 |CsvPreview service | service spec with fixture CSVs (BOM, quoted commas, empty lines) | ~120 |ContactImportJob: stream rows, validate, batch insert_all of 1,000 rows, skip existing | job, ContactRowBuilder | job spec with a 5k-row fixture; counts match | ~140 |upsert_all with a fixed column list | job, form checkbox | spec: without opt-in nothing is changed, with it the mapped fields update | ~60 |