This document provides context and guidelines for AI assistants working on the Track project. For complete contributing guidelines, see CONTRIBUTING.md.
Track is a command-line task management tool written in Rust that helps developers manage todos, links, and notes directly from the terminal. It features:
- CLI Interface: Fast, intuitive command-line operations
- Web UI: Browser-based interface with real-time updates
- Database: SQLite for persistent storage
- Shell Integration: Completions for bash/zsh/fish
- Language: Rust (stable)
- CLI Framework:
clapfor argument parsing - Database:
rusqlitefor SQLite operations - Web Framework:
axumfor HTTP server - Frontend: HTMX + Vanilla JavaScript (no frameworks)
- Real-time: Server-Sent Events (SSE) for live updates
track/
├── src/
│ ├── main.rs # Binary entry (uses lib crate)
│ ├── lib.rs # Library exports
│ ├── cli/ # Clap definitions + CommandHandler
│ ├── db/ # SQLite + row_mapping helpers
│ ├── models/ # Domain types (TaskStatus, TodoStatus, …)
│ ├── services/ # Task/Todo/Link/Repo/Worktree services
│ ├── use_cases/ # CompleteTodo, CreateTodayTask workflows
│ ├── utils/ # TrackError, Result
│ └── webui/ # Axum server, SSE, templates
├── templates/ # HTMX HTML (base.html, partials/)
├── static/ # Static assets
├── tests/ # Integration tests
└── CONTRIBUTING.md
See PROJECT_STRUCTURE.md for architecture details.
Before making any changes, always:
- Format code:
cargo fmt - Run linter:
cargo clippy -- -D warnings - Run tests:
cargo test - Build project:
cargo build
All changes must pass:
- ✅
cargo fmt(no formatting issues) - ✅
cargo clippy -- -D warnings(no warnings) - ✅
cargo test(all tests passing)
use crate::TrackError;
fn operation() -> Result<T, TrackError> {
let result = fallible_operation()?;
Ok(result)
}// Use parameterized queries
conn.execute(
"INSERT INTO todos (description) VALUES (?1)",
params![description],
)?;// Commands are in src/commands/
pub fn handle_command(args: &Args) -> Result<()> {
// Implementation
}Place tests in the same file:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_feature() {
// Arrange, Act, Assert
}
}Place in tests/ directory for end-to-end workflows.
# Test CLI commands
cargo run -- todo add "Test task"
cargo run -- todo list
# Test WebUI
cargo run -- webui
# Open http://localhost:3000When working on the WebUI:
- Backend routes: Edit
src/webui/routes.rs - Templates: Edit files in
templates/ - Styling: Modify CSS in
templates/base.html - Real-time updates: SSE state in
src/webui/state.rs
Restart the server after changes:
cargo run -- webuiFollow Rust conventions:
snake_casefor functions, variables, modulesPascalCasefor types and traitsSCREAMING_SNAKE_CASEfor constants
See CONTRIBUTING.md for complete style guide.
<type>: <short summary>
<detailed description>
Types: feat, fix, docs, style, refactor, test, chore
Example:
feat: add priority field to todos
Added priority field (1-5) to todo items with database migration.
Updated CLI commands and WebUI to support priority filtering.
Checklist:
- Read relevant code before modifying
- Run
cargo fmt - Run
cargo clippy -- -D warnings(must pass) - Run
cargo test(all tests pass) - Add tests for new features
- Update documentation if needed
- Follow commit message format
- Verify manual testing for UI changes
- Always read files before editing: Never propose changes to code you haven't read
- Follow existing patterns: Check similar code in the codebase for consistency
- Keep it simple: Avoid over-engineering, only make necessary changes
- Test thoroughly: Both automated tests and manual verification
- Security: Prevent SQL injection, XSS, and other vulnerabilities
- Review CONTRIBUTING.md for detailed guidelines
- Check existing code for patterns and examples
- Look at recent commits for style reference
- Test changes locally before submitting
# Build and test
cargo build
cargo test
cargo fmt
cargo clippy -- -D warnings
# Run CLI
cargo run -- <command>
# Run WebUI
cargo run -- webui
# Run specific test
cargo test test_name
# View test output
cargo test -- --nocaptureFor complete details, see CONTRIBUTING.md.