Sitemap

Member-only story

Building an AI Code Review Bot in Rails: Sidekiq + OpenAI API

7 min readApr 16, 2026

--

Press enter or click to view image in full size
a small friendly robot sitting at a desk, reviewing a glowing code terminal screen.
a small friendly robot sitting at a desk, reviewing a glowing code terminal screen.

A practical walkthrough for wiring up async AI-powered code reviews inside your existing Rails stack, without going full microservice.

· What we’re actually building
· Setting up the dependencies
· The Sidekiq job
· Triggering the job
· Managing token limits
· Error handling and retries
· What the reviews actually look like
A note on cost
· Posting the review back to GitHub
· Testing the job
· Where to take this next
· Final thoughts
· Enjoyed this?

What we’re actually building

The basic flow is:

  • A webhook hits your Rails app when a PR is opened or updated
  • A Sidekiq job is enqueued to process it in the background
  • The job fetches the diff, sends it to the OpenAI API
  • The review gets stored and optionally posted back as a PR comment

We’re not doing anything crazy with embeddings or vector databases here. Just a clean, synchronous…

--

--