.gemini/skills/observability-patterns/SKILL.md
Debugging and monitoring patterns for the distributed offline-first architecture
npx skillsauth add captjay98/gemini-livestockai Observability PatternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
In a system with Offline Clients, Edge Workers (Cloudflare), and AI Agents, "It works on my machine" means nothing.
Every operation must have a traceable ID.
x-request-id (UUID).AppError is thrown, it must include this ID.When logging errors, never log just the message. Log the Context.
// ✅ Correct Logging Pattern
console.error(
JSON.stringify({
level: 'error',
requestId: ctx.requestId,
error: error.name,
code: error.code,
// Critical for debugging offline sync issues:
metadata: {
batchId: data.batchId,
inputs: truncate(JSON.stringify(data), 1000),
},
stack: error.stack,
}),
)
Agents need to know if the system is healthy before attempting complex actions.
/api/health: Basic uptime./api/health/sync: Status of the sync queues./api/health/ai: Status of the LLM/Agent provider connections.The hardest bugs are "Sync Conflicts". Log the Sync Lifecycle:
SYNC_START: Device X, 5 items.SYNC_ITEM: Item A (Create Batch). Result: Success.SYNC_ITEM: Item B (Log Feed). Result: Conflict (Version Mismatch).SYNC_END: Success: 4, Fail: 1.Since much logic happens offline, the client must store a "Telemtry Buffer". When online, flush this buffer to the server. Key Metric: "Time from Action to Sync" (How long are users offline?)
error-handling - The AppError class usagecloudflare-workers - The logging constraints (standard out)data-ai
Input validation patterns with Zod in LivestockAI server functions
testing
Unit testing patterns with Vitest in LivestockAI
tools
Server → Service → Repository pattern for feature organization
data-ai
Server-side rendering and server functions with TanStack Start in LivestockAI