AI coding tools are powerful, but they struggle with vague instructions. They go off-track, miss requirements, and need constant hand-holding.BrainGrid is like an AI Tech Lead that brings clarity and structure with a proven workflow to ship reliable software.The workflow is simple, yet powerful:
1
Start with a rough idea
Start with a rough idea, a high level concept, or a problem to solve.
2
Refine it with AI into a detailed specification
Click Refine to refine the rough idea with AI into a detailed specification.
BrainGrid asks clarifying questions to define the scope and uncover edge cases.
Upon completion, the basic prompt is refined into a full technical requirement with feature requests. This can be edited manually, or work with the AI to update the requirement.
In this example, the simple prompt has been expanded to include:
A scheduled weekly email report delivered every Monday at 08:00 UTC to all users with is_admin = true in the profiles table. The report summarises each non-admin user’s checklist completion progress across all countries and flags any user whose most-recent activity (updated_at on user_progress) is more than 7 days old.The feature introduces:
A new Next.js API route (POST /api/admin/weekly-report) that builds and sends the report — callable by a Vercel Cron Job.
A Resend-powered HTML email template.
A new Supabase migration adding a last_active_at column to profiles (updated on every progress toggle).
ALTER TABLE public.profiles ADD COLUMN IF NOT EXISTS last_active_at TIMESTAMPTZ;
last_active_at is set to NOW() whenever a row in user_progress is inserted or updated for that user (via a new trigger set_last_active_at on user_progress).
Existing rows default to NULL (treated as “never active” for inactivity logic).
A Vercel Cron Job defined in vercel.json calls POST /api/admin/weekly-report every Monday at 08:00 UTC.
The route is protected by a CRON_SECRET environment variable. Requests without the header Authorization: Bearer <CRON_SECRET> receive 401 Unauthorized.
The route can also be called manually by a super-admin for testing (same auth header).
Givenvercel.json is deployed with the cron configuration
When Monday 08:00 UTC arrives
Then Vercel automatically calls POST /api/admin/weekly-report with the correct Authorization header (configured via Vercel environment variables)
3
Let your AI coding tool build it reliably
Automatically build the requirement with your AI coding tool.You can feed tasks via the MCP, CLI, or just copy paste them into your AI coding tool.
Claude Code or Cursor
/build REQ-8
BrainGrid and your AI coding tool will build the code required to complete the requirement. Under the hood:
New GitHub branch
Tasks are created
Show Task 1: Install resend dependency and set up service-role Supabase client
Install the `resend` npm package. Create a service-role Supabase client at `src/lib/supabase/service-role.ts` that uses SUPABASE_SERVICE_ROLE_KEY to bypass RLS. Document required env vars: RESEND_API_KEY, CRON_SECRET, REPORT_FROM_EMAIL, SUPABASE_SERVICE_ROLE_KEY.
Show Task 2: Build weekly report HTML email template
Create src/lib/email/weeklyReport.ts with a pure function buildWeeklyReportHtml(employees, period) that returns an HTML string. Must include: header with app name and report period, summary row (total employees, completions, inactive count), employee table sorted alphabetically (Name, Country, Items Completed/Total, Completion %, Last Active, Status badge), footer. Handle empty states: no employees message, no country shows ”—”, inactive employees get ⚠️ badge. Include inline styles only, no external CSS.
Show Task 3: Create POST route handler
Create src/app/api/cron/weekly-report/route.ts with POST handler that:
1 Validates Authorization Bearer CRON_SECRET (401 if invalid)
2 Queries all non-admin employees with completion stats using service-role Supabase client
3 Queries all admins (is_admin=true)
4 Builds HTML email using buildWeeklyReportHtml
5 Sends email to each admin via Resend
6 Returns 200 with sent, employees count. Handle edge cases: no admins (log report_skipped), no employees (send empty-state email), Supabase failure (500), Resend partial failure (log error, continue). Implement structured logging: cron_started, report_sent, report_skipped, cron_error.
Show Task 4: Configure Vercel Cron in vercel.json
Create vercel.json with cron configuration: path “/api/cron/weekly-report”, schedule “0 8 * * 1” (every Monday at 08:00 UTC).
Completes the coding for the tasks.
Updates BrainGrid with the tasks shown as completed.
Commits the code to the Github repository.
Each stage adds structure, so by the time your AI starts coding, it knows exactly what to build and how to verify it’s correct.