secondsky avatar

Api Response Optimization

Solid fundamentals for making your API responses lighter and faster. You get sparse fieldsets so clients can request only the fields they need, ETag-based caching to avoid sending unchanged data, and compression middleware setup. The performance targets are ambitious but realistic: sub-100ms responses, payloads under 50KB, and significantly reduced CPU usage. The checklist covers the usual suspects like pagination and N+1 prevention. Nothing groundbreaking here, just the standard optimizations you should be doing anyway but probably aren't. Good reference if you're debugging slow endpoints or getting complaints about mobile data usage.

skills.sh installs
434
GitHub stars
248
last updated
Aug 21, 2026

Install

$ npx -y skills add secondsky/claude-skills --skill api-response-optimization --agent claude-code

Installs into .claude/skills of the current project.

Files

API Response Optimization

Reduce payload sizes, implement caching, and enable compression for faster APIs.

Sparse Fieldsets

// Allow clients to select fields: GET /users?fields=id,name,email
app.get('/users', async (req, res) => {
  const fields = req.query.fields?.split(',') || null;
  const users = await User.find({}, fields?.join(' '));
  res.json(users);
});

HTTP Caching Headers

app.get('/products/:id', async (req, res) => {
  const product = await Product.findById(req.params.id);
  const etag = crypto.createHash('md5').update(JSON.stringify(product)).digest('hex');

  if (req.headers['if-none-match'] === etag) {
    return res.status(304).end();
  }

  res.set({
    'Cache-Control': 'public, max-age=3600',
    'ETag': etag
  });
  res.json(product);
});

Response Compression

const compression = require('compression');

app.use(compression({
  filter: (req, res) => {
    if (req.headers['x-no-compression']) return false;
    return compression.filter(req, res);
  },
  level: 6  // Balance between speed and compression
}));

Performance Targets

Sponsors

Details

Repository
github.com/secondsky/claude-skills
Categories
Backend & APIs, Debugging
First seen
Jun 3, 2026

More from secondsky/claude-skills

All 146
1levnikolaevich avatarln-775-api-docs-generatorlevnikolaevich/claude-code-skillsConfigures Swagger/OpenAPI documentation for backend APIs. Use when adding interactive API docs to a project.432skills.sh installs
2aj-geddes avatargraphql-implementationaj-geddes/useful-ai-promptsDesign and implement GraphQL APIs with schema design, resolvers, queries, mutations, subscriptions, and best practices. Use when building GraphQL servers, desig424skills.sh installs
3davila7 avatarbackend-to-frontend-handoff-docsdavila7/claude-code-templatesCreate API handoff documentation for frontend developers. Use when backend work is complete and needs to be documented for frontend integration, or user says 'c413skills.sh installs
4davila7 avatarclinicaltrials-databasedavila7/claude-code-templatesQuery ClinicalTrials.gov via API v2. Search trials by condition, drug, location, status, or phase. Retrieve trial details by NCT ID, export data, for clinical r409skills.sh installs
5umbraco avatarumbraco-auth-providerumbraco/umbraco-cms-backoffice-skillsImplement authentication providers for Umbraco backoffice using official docs399skills.sh installs
6jezweb avatarcloudflare-worker-basejezweb/claude-skillsSet up Cloudflare Workers with Hono routing, Vite plugin, and Static Assets. Prevents 10 errors including export syntax, routing conflicts, Vite 8 nodejs_compat394skills.sh installs