robisson/build-like-amazon-agent-skills/operational-code
Claude Code and agent skill by robisson/build-like-amazon-agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Writing code with built-in observability from day one. Structured logging (JSON), metrics emission (latency p50/p99, error rates), alarm-ready code, request tracing, graceful degradation.
Install
npx vskill@latest install robisson/build-like-amazon-agent-skills/operational-codeSKILL.md
The same SKILL.md was published earlier as robisson/build-like-amazon-agent-skills/operational-code.
Operational Code
Overview
Operational code is production code that tells you how it's doing without anyone asking. Every function emits metrics, every request leaves a trace, every error provides context. At Amazon, "it works on my machine" is meaningless—what matters is whether it works in production right now, under load, at 3 AM.
Writing operational code means embedding observability into the implementation from the first line. Not as an afterthought, not as a "hardening sprint" task—from the start. When an alarm fires, operational code gives you the dashboard, the log query, and the trace ID to diagnose the issue in minutes, not hours.
The principle is simple: if you can't observe it, you can't operate it. If you can't operate it, you shouldn't ship it.
When to Use
- Writing any production code (this is not optional)
- Implementing new API endpoints or message handlers
- Adding external service calls or database queries
- Handling errors, retries, or fallback paths
- Implementing feature flags or configuration changes
- Building background jobs, queues, or async workflows
Amazon Context
Amazon operates thousands of services at massive scale. When something goes wrong, the operator (often the developer who wrote the code, on-call at 2 AM) needs to answer three questions in under 5 minutes:
- What is broken? (Metrics and alarms tell you)
- Since when? (Dashboards with time correlation tell you)
- Why? (Structured logs and traces tell you)
Services that don't emit proper telemetry become operational black holes—they break, nobody knows why, and recovery takes hours of guessing. Amazon's operational bar requires that every service ships with dashboards, alarms, and runbooks before launch (enforced through ORR—Operational Readiness Review).
Observability platforms (metrics, tracing, logging) provide the infrastructure. But the instrumentation must live in the code. No external tool can observe what the code doesn't emit.
The Process
1. Structured Logging (JSON)
Every log statement is a JSON object with consistent fields:
Structured logging rules:
- Always JSON — never free-form strings. Machines parse logs, not humans.
- Event name as first argument — dot-separated, hierarchical:
service.component.action - Include identifiers — request_id, order_id, customer_id for correlation
- Include measurements — latency_ms, item_count, retry_attempt for diagnostics
- Log levels are semantic — INFO for business events, WARNING for recoverable issues, ERROR for failures requiring attention
- Never log secrets — no passwords, tokens, full credit card numbers, PII
2. Metrics Emission
Every operation emits latency, count, and error metrics:
Standard metrics for every operation:
| Metric | Type | Dimensions | Alarm Threshold | |
|---|---|---|---|---|
{Operation}.Latency | Timer (p50, p90, p99) | Operation, Region | p99 > 2x baseline | |
{Operation}.Success | Count | Operation, Region | Rate < 99.9% | |
{Operation}.Error | Count | Operation, ErrorType | Rate > 0.1% | |
{Operation}.Throttle | Count | Operation, Region | Any occurrence | |
{Operation}.Fault | Count (5xx) | Operation, Region | Rate > 0.01% | |
{Dependency}.Latency | Timer | Dependency, Operation | p99 > SLA | |
{Dependency}.Error | Count | Dependency, ErrorType | Rate > 1% |
3. Request Tracing
Every request gets a trace ID that propagates across service boundaries:
Tracing rules:
- Every inbound request gets a trace ID (generated or propagated from caller)
- Trace ID appears in every log line (for correlation)
- Trace ID propagates to all downstream calls (HTTP headers, message attributes)
- Subsegments wrap every I/O operation (database, cache, service calls)
- Annotations mark business-relevant data (customer_tier, order_type) for filtering
4. Alarm-Ready Code
Code is written so that alarming is trivial—metrics are already emitted at the right granularity:
Alarm philosophy:
- Alarm on symptoms, not causes — high latency, not high CPU
- Every alarm has a runbook link — the alarm description contains the URL
- Every alarm is actionable — if you can't act on it, it's noise. Remove it.
- Alarms have severity levels — P2 (High) pages on-call, P4 (Low) notifies Slack
- Test your alarms — deliberately inject failures to verify alarms fire
5. Graceful Degradation
Operational code fails gracefully—it never takes down the whole system for a partial failure:
Degradation principles:
- Distinguish critical from non-critical dependencies — document which failures are acceptable
- Always have a fallback — cached data, empty response, default value
- Emit metrics on degradation — you need to know when you're running degraded
- Set aggressive timeouts on non-critical paths — 200ms, not 30 seconds
- Never let a non-critical failure become a critical failure — isolate blast radius
6. Operational Code Template
Every new handler/endpoint follows this template:
Mechanisms Over Good Intentions
| Mechanism | What It Enforces | How | |
|---|---|---|---|
| Metric coverage in PR review | Every code path emits telemetry | Code Review checklist item: "Are metrics and logs adequate?" | |
| Alarm-per-dashboard rule | Every dashboard has corresponding alarms | ORR verifies alarm existence for each metric | |
| Structured log linting | JSON format with required fields | CI linter rejects free-form log.info("something happened") | |
| Trace propagation tests | Trace IDs flow across boundaries | Integration tests assert trace header presence | |
| Operational readiness review | Full observability before launch | Service blocked from prod without passing ORR |
Common Rationalizations
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/operational-code/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/robisson/build-like-amazon-agent-skills/operational-code)