Recipes

Step-by-step solutions for real development tasks.

699 published

Page 5 of 20

Generate an SBOM in the Build Pipeline

Produce a Software Bill of Materials on every build so downstream consumers can audit transitive dependencies.

~15 min
ci · security · sbom

Detect Schema Drift Between Environments

Dump the schema from staging and production and diff them so a missing index or column is caught before deploy.

~20 min
database · schema · drift

Sync Secrets from External Secrets Operator

Reference a secret in the external secrets store so Kubernetes pulls and rotates it without the value ever touching Git.

~25 min
kubernetes · secrets · eso

Automate Secret Rotation with a Cron Job

Schedule a rotation job that generates a new secret, updates consumers, and verifies the old one is revoked within one hour.

~30 min
security · secrets · rotation

Set Secure Cookie Attributes Consistently

Add Secure, HttpOnly, SameSite=Strict to every auth cookie so it is not sent over HTTP, not readable by JS, and not included in cross-site requests.

~15 min
security · cookies · attributes

Enable mTLS Across the Service Mesh

Turn on strict mTLS in the mesh so all inter-service traffic is encrypted and a pod on a compromised node cannot sniff calls.

~25 min
kubernetes · mtls · service-mesh

Cache API Responses with a Service Worker Strategy

Use stale-while-revalidate for API calls so the page loads instantly from cache and updates in the background.

~25 min
performance · service-worker · caching

Inject a Sidecar with a Mutating Webhook

Configure a mutating admission webhook so every pod in the namespace gets a proxy sidecar without developers editing specs.

~30 min
kubernetes · sidecar · webhook

Show Skeleton Placeholders During Data Fetch

Render a skeleton that matches the layout so the user sees structure immediately and there is no layout shift when data arrives.

~15 min
frontend · loading · skeleton

Define an SLO Error Budget and Burn Policy

Set a 99.9 percent SLO with a 30-day window so the error budget is explicit and a burn rate triggers a freeze on deploys.

~25 min
observability · slo · error-budget

Review Snapshot Diffs Before Updating

Configure snapshot tests to fail on mismatch and require a reviewed update flag so blind --update-snapshot does not hide regressions.

~20 min
testing · snapshots · review

Cascade Soft Deletes to Child Records

Set deleted_at on the parent and all children in one transaction so a soft delete is consistent without orphaned rows.

~20 min
database · soft-delete · cascade

Add Span Attributes for Log Correlation

Attach the user ID and request ID as span attributes so a trace can be correlated to logs and the user's journey is visible.

~15 min
observability · tracing · correlation

Detect SQL Injection with Parameterized Queries

Replace string concatenation in SQL with parameterized queries so a user input of ' OR 1=1 -- cannot escape the query structure.

~20 min
security · sqli · database

Redrive SQS Dead-Letter Queue Messages

Move messages from the DLQ back to the source queue after fixing the consumer so failed messages are retried not abandoned.

~20 min
cloud · sqs · dlq

Block SSRF with a Fetch Allowlist

Validate every outbound URL against a host allowlist before fetching so a user-supplied URL cannot reach internal metadata endpoints.

~20 min
security · ssrf · allowlist

Model Complex UI State with XState

Replace nested boolean flags with a state machine so impossible states like loading AND error are unrepresentable.

~30 min
frontend · xstate · state-machine

Emit Structured JSON Logs for Parsing

Replace console.log with a JSON logger so logs are machine-parseable and queryable in the aggregation system.

~15 min
observability · logging · json

Scan for Subdomain Takeover Vulnerabilities

Check dangling DNS records that point to unprovisioned cloud services so an attacker cannot claim the CNAME and host content on your subdomain.

~25 min
security · dns · takeover

Monitor with Synthetic Probes from Multiple Regions

Run a synthetic check every minute from three regions so a regional outage is detected before users report it.

~25 min
observability · synthetics · monitoring

Enable Terraform State Locking with S3 and DynamoDB

Configure a DynamoDB lock table so concurrent terraform runs do not corrupt the state file.

~20 min
cloud · terraform · state

Use Builder Pattern for Readable Test Data

Create a builder fluent API for test fixtures so complex objects are constructed with only the fields each test cares about.

~20 min
testing · fixtures · builder

Isolate Test Database per Worker with Transactions

Wrap each test in a transaction that rolls back so parallel workers never see each other's data and tests are order-independent.

~25 min
testing · database · isolation

Verify Test Environment Parity with Production

Compare the test and production dependency versions and config so a bug that only reproduces on a version skew is caught early.

~25 min
testing · parity · environments

Retry Flaky Network Tests with Backoff

Add exponential backoff retry to tests that hit external APIs so transient 503s do not fail the pipeline.

~15 min
testing · retry · network

Distribute a Timeout Budget Across Hops

Subtract each hop's elapsed time from the total budget so the last hop gets the remainder not a fresh full timeout.

~20 min
api · timeout · budget

Pin TLS Certificates for Mobile API Clients

Embed the expected certificate hash so a compromised CA or MITM proxy is rejected even if the chain is technically valid.

~25 min
security · tls · pinning

Stack Toast Notifications with a Queue Limit

Cap the visible toasts at 3 and queue the rest so a burst of 10 notifications does not cover the screen.

~15 min
frontend · ux · toasts

Sample Traces at the Tail for Completeness

Buffer all spans and sample at the end so traces with errors are always kept and healthy traces are sampled by rate.

~25 min
observability · tracing · sampling

Retry Transactions on Deadlock with Jitter

Detect a deadlock error, wait with jitter, and retry the transaction so concurrent operations do not permanently fail.

~20 min
database · deadlock · retry

Tree Shake Unused Exports with Side Effects Flag

Mark the package with sideEffects false so the bundler drops unused exports and the bundle shrinks by 30 percent.

~15 min
performance · bundling · tree-shaking

Migrate from Serial to UUID Primary Keys

Add a UUID column, backfill with generated values, make it the primary key, and drop the serial so offline ID guessing is impossible.

~35 min
database · migration · uuid

Reclaim Bloat with a Targeted Vacuum

Run VACUUM with a threshold on the dead tuple ratio so only bloated tables are vacuumed aggressively, not the whole database.

~20 min
database · vacuum · bloat

Virtual Scroll Large Lists for Constant DOM

Render only the visible window of a 10000-row list so the DOM stays under 100 nodes and scrolling is smooth.

~20 min
performance · frontend · virtualization

Set a Visual Regression Threshold per Component

Configure per-component pixel diff thresholds so minor anti-aliasing differences pass but real layout shifts fail the build.

~25 min
testing · visual · playwright

Access Services Privately with a VPC Endpoint

Create a VPC endpoint so traffic to S3 or DynamoDB stays on the AWS network and never traverses the public internet.

~20 min
cloud · vpc · endpoint