agentsclimarketplace

Api response optimization

Skill secondsky/claude-skills/plugins/api-response-optimization/skills/api-response-optimization

Production-ready skills for Claude Code CLI - Cloudflare, React, Tailwind v4, and AI integrations

Install
npx -y skills add secondsky/claude-skills --skill api-response-optimization

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Optimizes API performance through payload reduction, caching strategies, and compression techniques. Use when improving API response times, reducing bandwidth usage, or implementing efficient caching.

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

2.0 KB, as published. Nobody here has run it

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

MetricTarget
Response time<100ms (from 500ms)
Payload size<50KB (from 500KB)
Server CPU<30% (from 80%)

Optimization Checklist

  • Remove sensitive/unnecessary fields from responses
  • Implement sparse fieldsets
  • Add ETag/Last-Modified headers
  • Enable gzip/brotli compression
  • Use pagination for collections
  • Eager load to prevent N+1 queries
  • Monitor with APM tools

Best Practices

  • Cache immutable resources aggressively
  • Use short TTL for frequently changing data
  • Invalidate cache on writes
  • Compress responses >1KB
  • Profile before optimizing

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.