Agent

DocsAgentUse Cases

Concrete examples of what the Spectral Agent can do for you.

Use Cases

Here are real scenarios where the agent saves time. Each example shows the kind of prompt you would type — the agent handles the rest.

Refactoring

Rename identifiers, restructure modules, or migrate patterns across your entire codebase without missing a reference.

Rename all `userId` to `accountId` across my entire project, updating
imports and type references. Don't change database column names.

Writing Tests

Generate unit, integration, or e2e tests that follow your project's existing patterns and test framework.

Write Playwright e2e tests for the login flow covering success,
invalid credentials, and locked account scenarios. Use the existing
test helpers from tests/helpers/auth.ts.

Debugging

Describe the symptom and let the agent trace the root cause, explain it, and apply the fix.

My API returns 500 on the /api/orders endpoint. Check the route handler,
find the bug, and fix it. Don't change the response shape.

Code Review

Ask the agent to review changes for security, correctness, and style before you commit or merge.

Review all files changed in the last commit. Flag security issues,
missing error handling, and TypeScript strictness violations.

Documentation

Generate or update documentation that matches your project's conventions and style.

Generate JSDoc comments for every exported function in src/utils/.
Follow the existing style in src/utils/format.ts. Skip
already-documented functions.

Database Queries

Write, explain, and validate database queries against your Prisma or SQL schema.

Write a Prisma query that finds all users who haven't logged in for
30 days, with their last 5 orders. Include order totals and status.

Shell Automation

Automate repetitive file-system and shell tasks that would otherwise require manual scripting.

Find all .tsx files without 'use client' directive in src/app/ and
add it at the top. Skip files that are already server components
by convention.

Multi-file Changes

Add cross-cutting concerns like middleware, logging, or error boundaries across many files at once.

Add rate limiting middleware to all API route handlers in
src/app/api/. Use the pattern from the existing rate limiter in
src/middleware/rate-limit.ts. Don't apply to webhook endpoints.

What Makes a Good Prompt

Tip

Good prompts are specific (which files, which pattern), provide constraints (what not to change), and reference existing examples to follow. See the

prompt quality guide

for more.