Dev Diary Command
Documents development decisions, architectural choices, and technical rationale as structured diary entries. Creates a searchable record of why things were built the way they are. Invaluable for future developers and your future self.
Command
/diary
Description
Creates a structured development diary entry documenting what was done, why, what alternatives were considered, and what trade-offs were made. Maintains a chronological log that explains the "why" behind technical decisions -- the most valuable form of documentation that is almost never written.
Behavior
Arguments
$ARGUMENTS-- Topic or summary of what to document (e.g., "chose Redis over Memcached for session store")
Steps
-
Analyze the current session context:
- What was changed? (git diff)
- What was the goal?
- What decisions were made?
-
Generate the diary entry with these sections:
- Date and context
- Decision or change summary
- Alternatives considered
- Trade-offs and rationale
- Future implications
-
Append to diary file at
.claude/dev-diary.md
Entry Template
--- ## 2025-03-25: Chose Redis for Session Storage ### Context Migrating from JWT-based auth to session-based auth. Needed a fast, distributed session store that works across multiple app server instances. ### Decision Using Redis (via ioredis) as the session store backend. ### Alternatives Considered | Option | Pros | Cons | |--------|------|------| | Redis | Fast, TTL support, pub/sub for invalidation | Extra infrastructure | | PostgreSQL | Already have it, ACID compliance | Slower for high-frequency reads | | Memcached | Simple, fast | No persistence, no data types | | In-memory | Zero overhead | Lost on restart, not distributed | ### Rationale - Sub-millisecond reads for session validation on every request - Built-in TTL for automatic session expiration - Already running Redis for caching, no new infrastructure - Pub/sub channel enables real-time session invalidation across instances ### Trade-offs - Sessions are lost if Redis restarts (mitigated by Redis persistence config) - Additional memory usage (~500 bytes per session) - Need to monitor Redis connection pool in production ### Future Implications - Can reuse this Redis instance for rate limiting and real-time features - If we need ACID guarantees for sessions, will need to add PostgreSQL fallback - Redis Cluster needed if we exceed single-instance memory ### Related Files - `src/config/redis.ts` -- Redis connection config - `src/middleware/session.ts` -- Session middleware setup - `src/services/sessionStore.ts` -- Session CRUD operations
Output Format
The formatted diary entry is appended to .claude/dev-diary.md and displayed in the response.
Examples
# Document a technology choice /diary chose Redis over Memcached for session storage # Document an architecture decision /diary decided to use event sourcing for order processing # Document a trade-off /diary chose server-side rendering over static generation for product pages # Document a debugging lesson /diary learned that Prisma connection pool needs explicit sizing in serverless
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Git Commit Message Generator
Generates well-structured conventional commit messages by analyzing staged changes. Follows Conventional Commits spec with scope detection.
React Component Scaffolder
Scaffolds a complete React component with TypeScript types, Tailwind styles, Storybook stories, and unit tests. Follows project conventions automatically.
CI/CD Pipeline Generator
Generates GitHub Actions workflows for CI/CD including linting, testing, building, and deploying. Detects project stack automatically.