name: rally-dev description: "Rally SAT/AP prep app development skill. Use this skill whenever working on the Rally codebase — adding features, fixing bugs, writing Conductor prompts, reviewing code, or making architectural decisions. Triggers on: any mention of Rally, SAT prep, AP prep, challenge mode, gem economy, Desmos calculator, WorkArea, category rings, subtopic levels, or any file in the rally repo. Also use when the user asks to build a new feature, fix a bug, or review code in the context of the Rally app."
Rally Development Skill
Quick Reference
What is Rally?
A mobile-first SAT & AP prep app where students challenge friends to head-to-head quiz battles. Built with Next.js 14 (App Router), TypeScript, Tailwind CSS, Supabase, hosted on Vercel.
Live site: rallyplaylive.com GitHub: MaloneySandboxAI/rally Owner: Maloney Evaine (maloney@evaine.ai)
Architecture at a Glance
Category System
Categories are defined in lib/categories.ts. Each has an isMath boolean flag that controls timer lengths, calculator type (Desmos vs basic), and other math-specific behavior.
Math: Algebra (#378ADD), Data & Statistics (#F97316), AP Pre Calculus (#EC4899)
Non-math: Reading (#14B8A6), Grammar (#A855F7), AP Bio (#22C55E), APUSH (#F59E0B), AP English (#6366F1)
Game Modes
- Solo Timed — adaptive difficulty, earn gems, speed bonus
- Challenge (H2H) — 4x gem multiplier, shared 15-question pool, link-based invite
- Group Challenge — classroom mode, multiple participants, shared leaderboard
- Untimed Practice — no timer, no gems, full explanations, endless questions
Gem Economy
| Mode | Easy | Medium | Hard | Speed Bonus |
|---|---|---|---|---|
| Solo Timed | 10 | 20 | 40 | 1.5x |
| Challenge | 40 | 80 | 160 | 1.5x |
| Untimed | 0 | 0 | 0 | N/A |
Adaptive Difficulty
Both solo and challenge modes use adaptive difficulty: start easy, bump up on correct answer, drop on wrong. Challenge pools are pre-built (5 easy + 5 medium + 5 hard = 15 questions).
Key Patterns
Adding a New Feature
- Create the component in
components/rally/ - Add any server-side logic to
lib/ - If it needs a new page, create
app/[route]/page.tsx - If it needs Supabase tables, document the schema (but note: sandbox cannot reach Supabase directly — SQL must be run in the Supabase dashboard)
Working with the WorkArea (Bottom Sheet)
The WorkArea is a bottom sheet overlay (z-50) with 3 tabs: Notepad, Calculator, Draw.
- For math categories (
isMath: true), the Calculator tab shows Desmos (graphing + scientific toggle) - For non-math categories, it shows a basic calculator
- The
isVisibleprop triggersresize()on Desmos when the Calculator tab is selected - Located in
components/rally/work-area.tsx
Challenge Flow
- Creator selects category via
challenge-button.tsx getChallengePool()builds a 15-question pool from the selected category- Pool stored as flat
integer[]viapoolToFlat() - Creator must share the link BEFORE playing (enforced in UI)
- Both players draw from the same pool with independent adaptive difficulty
- Winner = more total gems earned (not just correct count)
creator_score = -1sentinel means creator hasn't played yet
State Management
- Auth: Supabase Auth +
auth-gate.tsxwrapper - Gems:
gem-context.tsxReact context - Premium:
premium-context.tsxReact context - Questions:
question-tracker-context.tsxfor tracking answered questions - No Redux — all state is React context + Supabase queries
Styling Conventions
- Dark navy theme: bg
#021f3d, accent#378ADD, text#85B7EB - Mobile-first: design for iPhone, minimize scrolling
- Tailwind utility classes only (no CSS modules)
font-extraboldfor headings,font-boldfor labelsrounded-xlfor cards,rounded-2xlfor containers- Bottom sheets for modal interactions
Development Workflow
How Code Gets Deployed
- Edit files locally or via Cowork/Conductor
- Push to main:
cd ~/Desktop/rally && git add -A && git commit -m "msg" && git push origin main - Vercel auto-deploys in ~30-35 seconds
next.config.mjshasignoreBuildErrors: trueso type errors don't block deploys
Writing Conductor Prompts
When creating prompts for Conductor (AI code agent):
- Be extremely specific about file paths and line numbers
- Include the exact code to add/replace with context lines
- List files to create vs files to modify separately
- Include a testing section with specific steps
- Note any "DO NOT" constraints (e.g., "do not remove existing CalculatorTab")
- Save prompts as
.mdfiles in the rally repo root (e.g.,conductor-desmos-prompt.md)
Sandbox Limitations
- Cannot reach npm registry — cannot install packages
- Cannot reach Supabase directly — cannot run queries or migrations
- CAN edit files, run local commands, and push via git
- For DB changes, provide SQL for the user to run in Supabase dashboard
Common Tasks
Adding a New Category
- Add to
ALL_CATEGORIESarray inlib/categories.ts - Set
isMathflag appropriately - Timer lengths are determined by
isMathinapp/play/page.tsx - Questions must exist in Supabase for the new category ID
Modifying the Landing Page
- Edit
app/page.tsx— self-contained marketing page - Logged-in users auto-redirect to
/home(handled in useEffect) - Uses same Tailwind dark theme as the app
Adding Supabase RLS Policies
- Write the SQL policy
- Document it clearly for the user to run in Supabase dashboard
- Test by describing expected behavior for authenticated vs anonymous users
Working with Push Notifications
lib/push-notifications.ts— subscription managementlib/challenge-notify.ts— sends notifications on challenge completion- Service worker handles delivery
- Push subscriptions stored in Supabase
File Quick-Find
| What you need | Where to look |
|---|---|
| Category definitions | lib/categories.ts |
| Gameplay logic | app/play/page.tsx |
| Challenge CRUD | lib/challenges.ts |
| Group challenges | lib/group-challenges.ts |
| Question fetching | lib/questions.ts |
| H2H records | lib/head-to-head.ts |
| Weekly recap | lib/weekly-recap.ts |
| Gem economy context | lib/gem-context.tsx |
| Premium/subscription | lib/subscription.ts, lib/premium-context.tsx |
| Auth wrapper | components/rally/auth-gate.tsx |
| Home page | app/home/page.tsx |
| Bottom sheet tools | components/rally/work-area.tsx |
| Desmos calculator | components/rally/desmos-calculator.tsx |
| Basic calculator | components/rally/calculator.tsx |
| Challenge creation | components/rally/challenge-button.tsx |
| Results + share | components/rally/results-screen.tsx, challenge-share-card.tsx |
| Navigation | components/rally/bottom-nav.tsx |
| Analytics | lib/posthog-provider.tsx |
| Supabase client | lib/supabase/client.ts |
| Supabase server | lib/supabase/server.ts |
| Answer remediation | scripts/remediate-answers.ts |