Recipes

Step-by-step solutions for real development tasks.

699 published

Page 1 of 20

Gate on Accessibility with axe-core

Run axe-core in CI so a PR that introduces a WCAG violation is blocked before merge, not found in a yearly audit.

~20 min
testing · accessibility · axe

Announce Dynamic Updates with aria-live Regions

Add an aria-live region so screen readers announce search results and toast notifications without the user moving focus.

~15 min
frontend · accessibility · aria

Alert with Multi-Window Burn Rate

Check the error budget burn rate over both 1h and 5m windows so a fast burn pages immediately and a slow burn notifies within an hour.

~25 min
observability · alerting · slo

Detect Anomalies Against a Rolling Baseline

Compute a 7-day rolling median and alert when the current value exceeds 3 sigma so a gradual regression is caught not just spikes.

~25 min
observability · anomaly · baseline

Rotate API Keys with Overlap and Grace Period

Issue the new key, accept both during a grace period, then revoke the old so clients update without downtime.

~20 min
api · api-key · rotation

Test API Schema Diff for Breaking Changes

Compare the OpenAPI spec before and after a PR so a removed field or narrowed type is flagged as a breaking change.

~25 min
testing · api · schema

Version an API with URL Path Segments

Mount v1 and v2 on separate path prefixes so a breaking change in v2 does not affect v1 clients still in production.

~20 min
api · versioning · routing

Keep an Audit History with a Trigger

Create a trigger that writes the old and new values to an audit table on every update so changes are traceable without app code.

~25 min
database · audit · trigger

Restore the Database to a Point in Time

Use point-in-time recovery to restore to 5 minutes before the bad migration so data loss is minimized.

~30 min
database · backup · pitr

Detect Performance Regression with Benchmark CI

Run benchmarks on every PR and compare against the main branch baseline so a 10 percent slowdown is flagged before merge.

~30 min
testing · benchmark · regression

Isolate Resources with the Bulkhead Pattern

Allocate a fixed thread pool per downstream service so a slow service does not exhaust threads needed by healthy ones.

~20 min
api · bulkhead · isolation

Split Bundles at Route Level for Faster Loads

Configure dynamic imports per route so the initial bundle is 40KB not 400KB and each page loads only its own code.

~20 min
performance · bundling · code-split

Design CDN Cache Keys to Avoid Stale Variants

Include the variant in the cache key so a mobile and desktop response do not collide and serve the wrong layout.

~20 min
performance · cdn · caching

Limit Chaos Experiment Blast Radius

Define a steady-state hypothesis and abort conditions so a chaos experiment auto-stops before it takes down the whole fleet.

~40 min
testing · chaos · resilience

Add a Circuit Breaker with Half-Open State

Trip the breaker after 5 failures, allow one probe in half-open, and close on success so cascading failures are contained.

~25 min
api · circuit-breaker · resilience

Distribute Private Content with CloudFront Signed URLs

Generate a signed URL with a short expiry so a user can download a protected asset without the bucket being public.

~25 min
cloud · cloudfront · signed-url

Audit API Calls with CloudTrail Event History

Query CloudTrail for who created or deleted a resource in a time window so an unauthorized change is attributable.

~20 min
cloud · cloudtrail · audit

Query Logs with CloudWatch Logs Insights

Write a Logs Insights query that filters by error and groups by service so the top error source is visible in seconds.

~20 min
cloud · cloudwatch · logs

Balance the Cluster Autoscaler Across Zones

Configure the autoscaler with balance-similar-node-groups so a zone outage does not leave all pods in one zone.

~20 min
kubernetes · autoscaler · zones

Add a Command Palette with Keyboard Shortcut

Register a Cmd+K shortcut that opens a searchable command palette so power users navigate without touching the mouse.

~25 min
frontend · ux · command-palette

Cancel Duplicate Runs on Concurrent Pushes

Add a concurrency group so a second push to the same branch cancels the in-flight run and frees the runner.

~10 min
ci · optimization · concurrency

Skip CI Jobs on Documentation-Only Changes

Add path filters so jobs that compile or test code are skipped when the diff touches only markdown and docs.

~15 min
ci · optimization · paths

Hot Reload ConfigMap Changes Without Restart

Mount the ConfigMap as a projected volume and watch for changes so the app picks up config updates without a rolling restart.

~25 min
kubernetes · configmap · hot-reload

Size the Connection Pool to Avoid Exhaustion

Set the pool max to twice the CPU cores and add a acquire timeout so a spike does not exhaust connections and queue forever.

~20 min
performance · database · pooling

Pin the Database Connection SSL Certificate

Set sslmode to verify-full and pin the CA so a rogue DB proxy with a valid but different certificate is rejected.

~20 min
database · ssl · pinning

Scan Container Images for Known CVEs

Scan the built image against a vulnerability database so a critical CVE in a base layer blocks the deploy.

~20 min
security · containers · cve

Add Consumer-Driven Contract Tests with Pact

Generate a pact from the consumer's test suite and verify it in the provider pipeline so breaking API changes are caught before deploy.

~35 min
testing · contract · pact

Propagate a Correlation ID Through All Logs

Generate a correlation ID at the edge and attach it to every log line so a single user request is traceable end to end.

~15 min
observability · logging · correlation

Cache CORS Preflight Responses Server-Side

Set Access-Control-Max-Age so OPTIONS preflight responses are cached and do not add a round-trip to every cross-origin request.

~15 min
security · cors · caching

Gate on Coverage Diff Not Absolute Number

Compare coverage against the base branch so a PR that drops coverage by 2 percent fails even if the total is still above 80 percent.

~20 min
testing · coverage · gate

Inline Critical CSS and Async Load the Rest

Extract above-the-fold CSS into a style tag and load the rest asynchronously so the first paint does not wait for the full stylesheet.

~20 min
performance · css · critical

Prevent Overlapping CronJobs with Concurrency Rule

Set concurrencyPolicy to Forbid so a slow cron job does not start a second instance while the first is still running.

~15 min
kubernetes · cronjob · concurrency

Trigger a Cross-Repository Pipeline on Tag

Use a repository dispatch event so tagging a shared library triggers downstream consumers to rebuild and test.

~20 min
ci · monorepo · triggers

Report CSP Violations to a Collector Endpoint

Add a report-uri to the Content-Security-Policy header so browser violations are collected and triaged as security events.

~20 min
security · csp · headers

Prevent CSRF with Double-Submit Cookie

Issue a CSRF token as a cookie and require it as a header so a cross-site form post without the header is rejected.

~20 min
security · csrf · cookies

Expose a Custom Metric for a Business KPI

Instrument the checkout flow to emit a conversion counter so the business KPI is on the same dashboard as latency.

~20 min
observability · metrics · business