Describe the Data You Need in Plain English and Let Claude Write the Query
Writing complex queries means knowing your schema, remembering join syntax, and getting conditions exactly right. Claude reads your actual database structure and writes queries that work with the tables and relationships you have — not a generic example.
> show me all users who signed up in the last 30 days,
> have verified their email, but haven't created any orders
Claude reads your migrations or schema to find the right tables, columns, and relationships, then writes the query in whatever style your project uses — Eloquent, raw SQL, Knex, Prisma, or any other query builder.
This works for any complexity:
> find the top 10 customers by total order value this year,
> including their name, email, number of orders, and total spent
> get all products that are out of stock but have pending orders,
> grouped by category with a count
> find duplicate email addresses in the users table and show
> which accounts share each email
> calculate the average time between a user signing up and
> making their first purchase, broken down by month
Claude adapts to your project's query style. If you use Eloquent:
// Claude writes this after reading your models
User::where('created_at', '>=', now()->subDays(30))
->whereNotNull('email_verified_at')
->whereDoesntHave('orders')
->get();
If you prefer raw SQL, say so and Claude writes that instead — with proper parameter binding, no string concatenation.
For ad-hoc data exploration, combine this with a database MCP server so Claude can actually run the query and show you the results in real time:
> how many users signed up each day this week? show me the numbers
Claude writes the query, runs it, and shows you the data — all from one English sentence.
Describe the answer you want, not the SQL to get there — Claude knows your schema and writes the query.
via Claude Code
Log in to leave a comment.
Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.
Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.
Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.