AI Prompts for Software Developers | Okara
Okara

AI Prompts for Software Developers

Debug code, generate documentation, and architect solutions without exposing proprietary codebases.

Analysis
Stack Trace Explainer
Explain an error and suggest likely fixes.

"Explain the following common Next.js error and suggest 3 likely fixes ranked by probability: 'Error: Hydration failed because the initial UI does not match what was rendered on the server. Warning: Expected server HTML to contain a matching <div> in <div>.' For each fix: explain why it causes the mismatch, show the exact code pattern that triggers it, provide the corrected code, and explain how to prevent it in the future. Also explain how to use React DevTools to debug hydration mismatches systematically."

Analysis
PR Review Summarizer
Summarize a pull request and flag potential risks.

"Create a PR review template that a senior developer can use to quickly summarize and assess any pull request. The template should extract: (1) what the PR does in 2 sentences, (2) files changed categorized by type (logic, UI, config, tests), (3) potential risks flagged by category (breaking changes, performance, security, backwards compatibility), (4) test coverage assessment (what's tested, what's missing), (5) suggested improvements ranked by priority, and (6) a clear verdict (approve, request changes, needs discussion). Demonstrate with a hypothetical PR that adds JWT refresh token rotation to an Express.js API."

Analysis
Legacy Code Explainer
Explain what a complex function does in plain English.

"Create a template for documenting and explaining legacy code that has no comments or documentation. The template should produce: (1) a plain English summary of what the function does, (2) the inputs and outputs with types, (3) side effects (database writes, API calls, state mutations), (4) edge cases and error handling behavior, (5) dependencies and coupling to other modules, (6) potential bugs or code smells identified, and (7) a refactoring recommendation. Demonstrate by explaining this pseudocode: a 50-line function that takes a user object, checks multiple nested conditions about subscription status, trial dates, and feature flags, applies different pricing tiers, writes to a cache, and returns a transformed permissions object."

Analysis
Performance Bottleneck Finder
Identify likely performance bottlenecks in a React component.

"Create a systematic checklist for identifying performance bottlenecks in a React/Next.js application. Cover: unnecessary re-renders (missing memo, unstable references in props, context over-subscription), expensive computations in render path (missing useMemo/useCallback), bundle size issues (unoptimized imports, missing code splitting), network waterfalls (sequential API calls that could be parallel), image optimization gaps, layout thrashing from DOM measurements, and memory leaks from uncleared subscriptions. For each issue, show the problematic code pattern, the fix, and how to measure the improvement using React DevTools Profiler or Chrome Performance tab."

Strategy
URL Shortener System Design
Design a scalable URL shortening service.

"Design a scalable URL shortening service (like bit.ly) that can handle 100 million new URLs per month and 10 billion redirects per month. Cover: functional and non-functional requirements, API design (REST endpoints with request/response examples), database schema (SQL vs NoSQL trade-offs with specific table designs), the URL encoding algorithm (base62 encoding, collision handling, custom alias support), caching strategy (Redis layer with TTL and eviction policy), read/write ratio optimization, horizontal scaling approach (sharding strategy), and a high-level architecture diagram described in text. Include back-of-the-envelope capacity calculations for storage and bandwidth."

Drafting
Docker Development Environment
Set up a containerized local development environment.

"Write a complete Docker Compose setup for a local development environment consisting of a Next.js frontend, a Node.js/Express API server, a PostgreSQL database, and a Redis cache. Include: the docker-compose.yml with proper service dependencies and health checks, individual Dockerfiles for frontend and backend with multi-stage builds (dev and prod targets), volume mounts for hot reloading in development, environment variable management using .env files, a seed script for the database, and a Makefile with common commands (make up, make down, make logs, make db-migrate, make db-seed, make shell-api). Explain each configuration choice."

Drafting
GitHub Actions CI/CD Pipeline
Set up a complete CI/CD pipeline with GitHub Actions.

"Write a complete GitHub Actions CI/CD pipeline for a Next.js application. Include: a lint and type-check job, a unit test job with coverage reporting (fail if below 80%), an integration test job, a build verification job, automatic preview deployments on pull requests with a comment posting the preview URL, production deployment on merge to main, Slack notification on failure, caching for node_modules (using package-lock hash) and Next.js build cache (.next/cache), environment secret management for different stages, and a concurrency group to cancel outdated runs. Provide the complete YAML workflow file with comments explaining each step."

Strategy
Authentication System Design
Design a secure authentication system with JWT and refresh tokens.

"Design a complete authentication system for a web application using JWT access tokens and refresh tokens. Cover: the full token lifecycle (issuance, validation, refresh, revocation), secure storage (httpOnly cookies with SameSite=Strict vs. localStorage trade-offs), access token expiration (15 min) and refresh token rotation with reuse detection, CSRF protection strategy, the login/logout/refresh API endpoints with complete request/response examples, password hashing (bcrypt with cost factor selection), rate limiting on auth endpoints (sliding window), how to detect and handle token theft (refresh token family tracking), and a text-based sequence diagram showing the complete auth flow."

Drafting
Error Handling Architecture
Design a robust error handling system for a full-stack app.

"Design a comprehensive error handling architecture for a full-stack TypeScript application (Next.js frontend, Node.js API). Cover: custom error class hierarchy (AppError base class, ValidationError, AuthError, NotFoundError, RateLimitError), centralized error middleware for Express with proper HTTP status mapping, React error boundary components with fallback UI, user-friendly error messages vs. developer-only logs, structured error logging with correlation IDs for request tracing, Sentry integration for error monitoring with proper context, retry strategies for transient failures (exponential backoff), and graceful degradation patterns. Include complete TypeScript code for the error classes and Express middleware."

Analysis
PostgreSQL Query Optimization
Optimize slow database queries with indexing strategies.

"Write a guide to optimizing slow PostgreSQL queries for a web application. Cover: how to read EXPLAIN ANALYZE output (sequential scan vs index scan, actual vs estimated rows, sort and hash operations), common index types and when to use each (B-tree for equality/range, GIN for arrays/JSONB/full-text, GiST for geometric), composite index column ordering rules, partial indexes for filtered queries, the N+1 query problem with detection and fixes (JOINs, batch loading, DataLoader pattern), connection pooling with PgBouncer configuration, and query plan caching. Include 3 real-world examples of slow queries with their optimized versions showing before/after EXPLAIN output."

Drafting
Regex Pattern Generator
Generate and explain regex patterns for common validation tasks.

"Generate well-tested regex patterns for 8 common validation tasks: email address (RFC 5322 simplified), US phone number (multiple formats), URL with optional protocol, date in ISO 8601 format, strong password (8+ chars, upper, lower, number, special), IPv4 address, credit card number (Visa, Mastercard, Amex), and slug (lowercase alphanumeric with hyphens). For each pattern: provide the regex, explain each part with inline comments, list 5 strings that should match and 5 that should not, note any edge cases or limitations, and provide the TypeScript validation function. End with 3 tips for writing maintainable regex (named groups, verbose mode, when to NOT use regex)."

Communication
Professional README Template
Create a comprehensive README for an open-source project.

"Create a professional README.md template for an open-source TypeScript library published on npm. Include: a concise project description with badges (build status, npm version, license, bundle size), a features list with brief descriptions, quick start installation instructions for npm/yarn/pnpm, a usage section with 3 progressive code examples (basic, intermediate with options, advanced with TypeScript generics), API reference documentation for the 5 main exported functions with parameter tables, configuration options table with defaults, a troubleshooting section with 3 common issues, contributing guidelines summary with link to CONTRIBUTING.md, changelog link, and license section. Use proper Markdown formatting with a clickable table of contents."

Ready to try these prompts?

Start a secure chat on Okara and experience private AI with 20+ open-source models.

Get started for Free