All guides

$ open guides/claude-code-app-speed-prompt

FreeClaude CodePerformancePrompts

Claude, do not let my app be slow: a 17-point prompt

Copy one prompt into Claude Code before launch. Below, each point in short: why it slows the app, how to check it yourself and a link to the docs.

~6min read

What you'll get

6 sections5 steps1 prompts

How to judge speed

  • 2.5 s

    LCP at most: main content on screen

    web.dev threshold for 75% of page loads

  • 0.8 s

    TTFB at most: first server response

    the good level by web.dev

  • 17

    points in one prompt

    the last one asks for before and after numbers

01Prompt

Copy it whole into Claude Code

Open the project folder, commit the current state and paste the text. The order is the same as in the video.

0117 speed points

prompt 01
I built an app and I do not want it to be slow. First identify the stack and measure the current speed. Then go through the points in order. For each: is there a problem, file and line, the fix. Mark what does not apply as "not applicable". Do not break behavior, run the tests after the changes. Ask me before changing the database schema or adding a service.

1. Images in WebP or AVIF at the right size.
2. A skeleton instead of an empty screen.
3. Debounce search, no request per letter.
4. Remove duplicate API requests.
5. Split long lists into pages.
6. Find N+1 queries and merge them.
7. Indexes for slow queries, prove it with EXPLAIN.
8. Select only the columns you need.
9. Heavy tasks go to a queue.
10. Run independent requests in parallel.
11. Static files through a CDN.
12. Brotli compression.
13. Cache with correct Cache-Control. Never put personal data in a shared cache.
14. Split JavaScript by page.
15. Third-party scripts last, with defer or on interaction.
16. Self-hosted fonts, only the styles in use.
17. Test on a slow phone with a bad network (CPU and network emulation). Give a before and after table: LCP, TTFB, page weight, number of requests. If you did not measure something, say so.

Big project? Ask for measurements and a list of problems first, then fix point by point.

02What people see

Points 1–5: screen and browser requests

  1. 1. Images

    A heavy image fills the connection and the main screen waits. Check: DevTools, Network, Img filter, sort by Size. web.dev

  2. 2. Skeleton

    An empty screen looks broken and a late block shifts the page. A skeleton does not speed data up, it holds the space. Check: slow network in Network, then reload. web.dev

  3. 3. Debounced search

    A request per letter loads the server and an old answer can land over a new one. Check: Network, Fetch/XHR, type a word and count requests. MDN

  4. 4. Duplicate requests

    Two components ask for the same thing, which is extra work for network and server. Check: Network, Fetch/XHR, open the page and look for identical URLs. TanStack Query

  5. 5. Pagination

    A thousand rows at once load the database, the network and the phone. Check: in Network see the list response size and whether the request has a limit. Prisma

03Server

Points 6–10: database and server

  1. 6. N+1 queries

    One query for the list plus one for every row. Check: turn on the SQL log (Prisma 7: log: ["query"]), open a list and count. Prisma

  2. 7. Indexes

    Without an index the database reads the whole table. Check: EXPLAIN ANALYZE before a SELECT on a test database. A Seq Scan that drops almost all rows of a big table is a sign. PostgreSQL

  3. 8. Only needed columns

    Extra fields, above all long text and JSON, travel for nothing. Check: find SELECT * and compare the API response with the screen. Prisma

  4. 9. Queue

    An email, PDF or report inside a request makes people wait. Check: Network, Timing, Waiting for server response on those buttons. BullMQ

  5. 10. In parallel

    Three independent awaits in a row add up. Check: a staircase in Waterfall and adjacent awaits in the code. Promise.all helps. MDN

04Delivery

Points 11–16: how files reach people

Terminal commands. On Windows type curl.exe in Git Bash or PowerShell, with your own URL.

  1. 11. CDN

    A distant server adds delay to every file. Check: curl -I https://site.com/logo.webp, look for Age or your CDN's cache header. web.dev

  2. 12. Brotli

    Uncompressed HTML, CSS and JS take longer. Check: curl -I -H "Accept-Encoding: br" https://site.com, you want content-encoding: br. If absent, check Network, Headers. MDN

  3. 13. Cache

    Without cache the browser downloads files again. Check: files with a hash in the name have cache-control: max-age=31536000, immutable. Keep personal HTML out of shared cache. MDN

  4. 14. JavaScript by page

    The phone parses code of pages nobody opened. Check: DevTools, Command Menu, Show Coverage, reload and see Unused Bytes. web.dev

  5. 15. Third-party scripts

    Chat and analytics compete with your code. Check: block the domain in Network and compare Lighthouse. Load the less important with defer or on click. web.dev

  6. 16. Self-hosted fonts

    Another domain is an extra connection. The gain depends on your server, so compare before and after. Check: Network, Font filter, Domain column. web.dev

05Point 17

Slow phone, bad network, report

A fast laptop and fast Wi-Fi hide the problem. Measure before and after.

0/5 done
  1. Build for production

    Development mode is slower and shows the wrong numbers. Build the app and open it in incognito without extensions.

    npm run build
  2. Slow the phone and network

    Calibrate CPU presets in Settings, Throttling and add your own slow network profile. Chrome DevTools

    DevTools
  3. Run Lighthouse three times

    The Lighthouse tab or lighthouse URL. Results vary, take the middle of three. Guide

    Lighthouse
  4. Save the before

    LCP, TTFB, page weight and number of requests. Keep the same settings for the second run.

    LCPTTFB
  5. Compare the after

    Ask for a table: what was slow, what changed, before and after. Then check on a real phone.

06

Where the prompt is not enough

  • 01

    Claude Code sees code, not always the hosting. Check CDN, Brotli and headers on the live URL.

  • 02

    An index speeds up reads but slows writes and takes space. Add one for a real slow query.

  • 03

    EXPLAIN ANALYZE really runs the query. For UPDATE and DELETE use a test database.

  • 04

    A small project does not need all 17 points. A queue or CDN for one page can be too much.

Sources

  1. 1web.dev: Largest Contentful Paint
  2. 2web.dev: Time to First Byte
  3. 3web.dev: Choose the right image format
  4. 4web.dev: Optimize CLS
  5. 5Prisma: Query optimization
  6. 6PostgreSQL: Using EXPLAIN
  7. 7MDN: HTTP caching
  8. 8web.dev: Code splitting
  9. 9web.dev: Third-party JavaScript
  10. 10Chrome DevTools: Coverage
  11. 11Chrome DevTools: Throttling
  12. 12Chrome: Lighthouse overview

Go deeper

Mastering Claude Code: From Zero to Power User

The Claude Code course covers planned work, checks, skills and subagents on live projects: from setup to your own rules.

$44.90 · one payment, lifetime access

More guides on this topic

All guides

Comments