Examples
Real-world examples of Agent Commits showing different scenarios and levels of complexity.
Simple Bug Fix
Fixing a null pointer exception with proper error handling
[agent] fix: Resolve null pointer in user lookup Intent: Fix crash when looking up deleted users Plan: - Add null check before accessing user properties - Return appropriate error response for missing users - Add test case for deleted user scenario Changes: - src/services/user.ts: Added null check in getUserById - src/services/user.test.ts: Added test for deleted user lookup Verified: All tests passing including new edge case test
New Feature
Adding CSV export functionality to a reports system
[agent] feat: Add CSV export for reports Intent: User needs to export monthly reports as CSV files for accounting Plan: - Create CSV serialization utility - Add export endpoint to reports API - Include all report fields with proper escaping - Add download button to reports UI Changes: - src/utils/csv.ts: New CSV serialization with proper escaping - src/api/reports.ts: Added GET /reports/:id/export endpoint - src/components/ReportView.tsx: Added export button - src/utils/csv.test.ts: Unit tests for CSV edge cases Verified: Manual export test successful, unit tests passing Limitations: - Large reports (>100k rows) may timeout; pagination not implemented - Unicode characters preserved but not tested extensively
Refactoring
Modernizing async code from callbacks to async/await
[agent] refactor: Migrate from callbacks to async/await Intent: Modernize the data layer to use async/await instead of callbacks Plan: - Convert callback-based functions to return Promises - Update callers to use async/await syntax - Maintain backward compatibility during transition - Remove deprecated callback signatures Changes: - src/data/database.ts: Converted all methods to async - src/data/cache.ts: Converted to async with Promise wrapper - src/services/*.ts: Updated all database callers - src/types/database.d.ts: Updated type definitions Verified: All existing tests passing, no runtime errors in dev Context: The codebase mixed callbacks and promises inconsistently. This refactor standardizes on async/await throughout the data layer. Alternatives: - Could promisify incrementally, but creates inconsistent patterns - Could use a library like Bluebird, but native promises sufficient
API Integration
Integrating a third-party payment provider
[agent] feat: Integrate Stripe payment processing Intent: Replace legacy payment system with Stripe for card processing Plan: - Add Stripe SDK and configure API keys - Create payment service abstraction layer - Implement checkout flow with Payment Intents - Add webhook handler for payment events - Update order status based on payment state Changes: - src/services/payment.ts: New Stripe payment service - src/api/webhooks/stripe.ts: Webhook handler for payment events - src/api/checkout.ts: Updated checkout to use Payment Intents - src/config/stripe.ts: Stripe configuration and key management - src/types/payment.d.ts: Payment type definitions - package.json: Added stripe dependency Verified: Test mode transactions successful, webhook events processed Context: The legacy payment provider is being deprecated. Stripe provides better developer experience and broader payment method support. Limitations: - Only card payments implemented; Apple/Google Pay planned for phase 2 - Subscription billing not yet supported - Refunds must be processed manually via Stripe dashboard References: - https://stripe.com/docs/payments/payment-intents - Internal ticket: PAY-1234
Performance Optimization
Adding caching to reduce database load
[agent] perf: Add Redis caching for user sessions Intent: Reduce database load by caching frequently accessed user data Plan: - Set up Redis connection with connection pooling - Add cache layer for user session lookups - Implement cache invalidation on user updates - Add cache hit/miss metrics Changes: - src/cache/redis.ts: Redis client setup with pooling - src/services/session.ts: Added caching to session lookups - src/services/user.ts: Cache invalidation on user updates - src/middleware/metrics.ts: Added cache performance metrics - docker-compose.yml: Added Redis service for local dev Verified: Load tests show 70% reduction in DB queries, cache hit rate ~85% Limitations: - Cache TTL set to 15 minutes; stale data possible within window - No cache warming on startup; first requests will be slower
Security Fix
Addressing a SQL injection vulnerability
[agent] fix: Prevent SQL injection in search endpoint Intent: Address security vulnerability in product search Plan: - Replace string concatenation with parameterized queries - Add input validation for search terms - Add SQL injection test cases - Review other endpoints for similar issues Changes: - src/api/search.ts: Converted to parameterized queries - src/utils/validation.ts: Added sanitizeSearchTerm function - src/api/search.test.ts: Added SQL injection test cases - src/api/products.ts: Fixed similar issue in product filters Verified: All SQL injection test cases pass, manual testing confirms fix Context: Security scan identified SQL injection risk in search endpoint. The vulnerability allowed arbitrary SQL execution via crafted search terms. References: - OWASP SQL Injection Prevention Cheat Sheet - Internal security ticket: SEC-789
Documentation Update
Updating API documentation for new endpoints
[agent] docs: Update API documentation for v2 endpoints Intent: Document the new v2 API endpoints added last sprint Plan: - Add OpenAPI specs for new endpoints - Update README with v2 migration guide - Add code examples for common use cases Changes: - docs/api/openapi.yaml: Added v2 endpoint specifications - docs/README.md: Added v2 migration section - docs/examples/v2-migration.md: New migration guide with examples Verified: OpenAPI spec validates, examples tested against dev server
Test Coverage
Adding missing test coverage for edge cases
[agent] test: Add edge case tests for form validation Intent: Improve test coverage for form validation utilities Plan: - Identify untested edge cases from coverage report - Add tests for empty inputs, special characters, max lengths - Add tests for international characters and RTL text - Ensure all validation error messages are tested Changes: - src/utils/validation.test.ts: Added 23 new test cases - src/components/Form.test.tsx: Added edge case tests for form submission - jest.config.js: Updated coverage thresholds Verified: Coverage increased from 67% to 94% for validation module Context: Code coverage audit identified validation as undertested area. These tests cover edge cases that caused production issues previously.
Key Patterns
- Intent clarity: Each example starts with a clear statement of what was requested, not just what was done.
- Plan traceability: The plan steps map directly to the changes made, allowing reviewers to verify completeness.
- Honest verification: The verified field accurately reflects what testing was actually performed.
- Limitations acknowledged: Complex changes include known limitations and edge cases not handled.
- Context when needed: Background information is provided when it helps understand the "why" behind decisions.