3.1 KiB
3.1 KiB
Agent Guidelines for Light Chat
This document outlines the rules and principles for AI agents (or developers) working on the light_chat codebase.
Core Principles
- Simplicity - Keep the codebase simple and easy to understand
- Modularity - Separate concerns; each module has a single responsibility
- Reusability - Abstract common functionality for multiple use cases
- Test Coverage - All functions and components must have unit tests
Git Practices
Commit Standards
- Write clear, descriptive commit messages (imperative mood: "Add feature" not "Added feature")
- Use conventional commits format:
feat:,fix:,docs:,test:,refactor:,chore: - Make atomic commits - each commit should represent a single logical change
- Reference issue numbers in commit messages when applicable
Branch Strategy
- Use
mainas the stable branch - Create feature branches:
feature/descriptionorfeat/description - Use bugfix branches:
fix/description - Delete branches after merging to keep repository clean
Pull Requests
- Keep PRs small and focused
- Include a clear description of changes and rationale
- Ensure all tests pass before requesting review
- Request code review for all changes (unless trivial)
- Address review feedback promptly
Before Committing
- Run tests locally to verify functionality
- Check for unnecessary files (node_modules, build artifacts, env files)
- Verify no secrets or sensitive data are committed
- Rebase/squash commits if needed for clean history
Code History
- Avoid force pushes to shared branches
- Regularly pull latest changes from main to avoid conflicts
- Use
git statusto verify what you're committing
Coding Standards
Function Design
- Before creating a new function, check if a similar one exists that can be extended
- Abstract shared logic into utility functions
- Keep functions focused on a single task
Component Architecture
- Components should be small and composable
- Separate UI from business logic
- Use custom hooks for shared stateful logic
Testing Requirements
- Every new component needs test coverage
- Mock external dependencies (API calls, storage, etc.)
- Test both success and error cases
- Use descriptive test names
API Communication Pattern
The LLM API integration should be minimal:
- Simple GET/POST requests
- Extract "content" from responses
- Handle errors gracefully
- Allow custom endpoint configuration
State Management
- Use React hooks (useState, useContext) for simplicity
- Session data should be persistable
- Maintain connection state (connected/disconnected)
File Structure
src/
components/ # Reusable UI components
hooks/ # Custom React hooks
utils/ # Utility functions and API clients
services/ # Business logic and API services
stores/ # State management (if needed)
tests/ # Unit tests
Workflow for New Features
- Identify existing similar functionality
- Abstract common patterns if applicable
- Implement with test-driven development
- Write tests first, then code
- Keep it simple - avoid over-engineering