Recipes

Step-by-step solutions for real development tasks.

699 published

Page 20 of 20

Add a Health Check Endpoint

Expose a liveness and readiness endpoint that checks critical dependencies with a timeout, so orchestrators can restart or remove unhealthy instances.

~20 min
operations · http · kubernetes

Add Idempotency Keys to a Write Endpoint

Accept an Idempotency-Key header, store the request fingerprint and response, and replay the original result for retries instead of creating duplicates.

~30 min
api-design · reliability · http

Add Pre-commit Hooks for Lint and Tests

Install the pre-commit framework, run lint and fast tests before every commit, and keep hooks reproducible across the team instead of relying on manual discipline.

~20 min
git · quality · automation

Propagate Request IDs Through Logs

Generate or accept a traceable request ID, attach it to every log line and response, and propagate it to downstream calls so one user action can be followed end to end.

~20 min
observability · logging · http

Add a Content Security Policy with Nonces

Ship a restrictive Content Security Policy that blocks inline script injection, uses per-request nonces, and is verified without breaking legitimate assets.

~30 min
security · http · xss

Configure CORS with an Origin Allowlist

Allow only trusted browser origins, handle preflight requests correctly, and avoid the insecure combination of wildcard origins with credentials.

~20 min
security · http · api-design

Recover a Deleted Git Branch

Use the reflog to find the last commit of a deleted local branch and recreate the branch before garbage collection removes the commit.

~10 min
git · recovery · version-control

Undo a Bad Commit with git revert

Undo a commit on a shared branch by creating a new inverse commit, preserving history and avoiding the disruption of a force-push.

~10 min
git · version-control · recovery

Implement Stable Cursor Pagination

Paginate a changing dataset with an encoded cursor instead of offsets, keeping results stable when rows are inserted or deleted between requests.

~30 min
api-design · databases · pagination

Resolve a Merge Conflict Without Losing Work

Inspect both sides of a conflict, choose or combine the intended changes, stage the result, and verify with tests before completing the merge.

~20 min
git · collaboration · version-control

Rotate a Leaked Secret Safely

Revoke a leaked credential, issue a replacement, deploy it through a secret manager, and purge the old value from history where your threat model requires it.

~30 min
security · secrets · git

Set HTTP Cache Headers for Static Assets and HTML

Give fingerprinted assets a long immutable cache while forcing browsers and CDNs to revalidate HTML, preventing stale deployments without sacrificing repeat-visit performance.

~15 min
performance · http · caching

Clean Up Local Commits with Interactive Rebase

Rewrite local commit history using git rebase --interactive to squash, reorder, or edit commits before sharing. Use this when preparing a clean pull request from messy WIP commits.

~10 min
git · workflow · history · version-control

Speed Up Slow Queries with SQL Indexes

Diagnose slow SQL queries using EXPLAIN and add targeted indexes to reduce row scans from millions to dozens. Covers B-tree indexes, composite ordering, and when indexes hurt performance.

~20 min
sql · postgres · performance · indexing

Create a Multi-Stage Dockerfile for Smaller Images

Use multi-stage Docker builds to compile your application in one stage and copy only the runtime artifacts into the final small image. This pattern can reduce image sizes by 10x or more.

~15 min
docker · devops · deployment · typescript · node