6.4 KiB
Project Workflow
Guiding Principles
- The Plan is the Source of Truth: All work must be tracked in
plan.md - The Tech Stack is Deliberate: Changes to the tech stack must be documented in
tech-stack.mdbefore implementation - Test-Driven Development: Write unit tests before implementing functionality
- High Code Coverage: Aim for >80% code coverage for all modules
- User Experience First: Every decision should prioritize user experience
- Non-Interactive & CI-Aware: Prefer non-interactive commands. Use
CI=truefor watch-mode tools (tests, linters) to ensure single execution.
Task Workflow
All tasks follow a strict lifecycle:
Standard Task Workflow
-
Select Task: Choose the next available task from
plan.mdin sequential order -
Mark In Progress: Before beginning work, edit
plan.mdand change the task from[ ]to[~] -
Write Failing Tests (Red Phase):
- Create a new test file for the feature or bug fix.
- Write one or more unit tests that clearly define the expected behavior and acceptance criteria for the task.
- CRITICAL: Run the tests and confirm that they fail as expected. This is the "Red" phase of TDD. Do not proceed until you have failing tests.
-
Implement to Pass Tests (Green Phase):
- Write the minimum amount of application code necessary to make the failing tests pass.
- Run the test suite again and confirm that all tests now pass. This is the "Green" phase.
-
Refactor (Optional but Recommended):
- With the safety of passing tests, refactor the implementation code and the test code to improve clarity, remove duplication, and enhance performance without changing the external behavior.
- Rerun tests to ensure they still pass after refactoring.
-
Verify Coverage: Run coverage reports using the project's chosen tools (e.g.,
pytest --cov=app). Target: >80% coverage for new code. -
Document Deviations: If implementation differs from tech stack:
- STOP implementation
- Update
tech-stack.mdwith new design - Add dated note explaining the change
- Resume implementation
-
Record Completion in Plan: Update
plan.md, find the line for the completed task, and update its status from[~]to[x]. Note: Committing code and plan updates is deferred until the entire phase is complete.
Phase Completion Verification and Checkpointing Protocol
Trigger: This protocol is executed immediately after a task is completed that also concludes a phase in plan.md.
-
Announce Protocol Start: Inform the user that the phase is complete and the verification and checkpointing protocol has begun.
-
Ensure Test Coverage for Phase Changes:
- Step 2.1: Determine Phase Scope: Identify files changed since the last phase checkpoint.
- Step 2.2: List Changed Files: Execute
git diff --name-only <previous_checkpoint_sha> HEAD(or since first commit if no previous checkpoint). - Step 2.3: Verify and Create Tests: Ensure all new code has corresponding tests following project conventions.
-
Execute Automated Tests with Proactive Debugging:
- Announce and run the automated test suite (e.g.,
pytestandplaywright test). - If tests fail, debug and fix (maximum two attempts before seeking guidance).
- Announce and run the automated test suite (e.g.,
-
Propose a Detailed, Actionable Manual Verification Plan:
- Analyze
product.md,product-guidelines.md, andplan.mdto define user-facing goals. - Present a step-by-step verification plan with expected outcomes.
- Analyze
-
Await Explicit User Feedback:
- Pause for the user to confirm: "Does this meet your expectations?"
-
Create Phase Checkpoint Commit:
- Stage all code changes and the updated
plan.md. - Perform a single commit for the entire phase with a message like
feat(phase): Complete <Phase Name>.
- Stage all code changes and the updated
-
Attach Consolidated Task Summary using Git Notes:
- Step 7.1: Draft Note Content: Create a detailed summary for all tasks completed in this phase, including verification results.
- Step 7.2: Attach Note: Use
git notes add -m "<summary>" <checkpoint_commit_hash>.
-
Get and Record Phase Checkpoint SHA:
- Obtain the hash of the checkpoint commit and update the phase heading in
plan.mdwith[checkpoint: <sha>].
- Obtain the hash of the checkpoint commit and update the phase heading in
-
Commit Plan Update:
- Stage
plan.mdand commit withconductor(plan): Mark phase '<PHASE NAME>' as complete.
- Stage
-
Announce Completion: Inform the user that the phase is complete and the checkpoint has been created.
Quality Gates
Before marking any task complete, verify:
- All tests pass
- Code coverage meets requirements (>80%)
- Code follows project's code style guidelines
- All public functions/methods are documented
- Type safety is enforced (Pydantic models, type hints)
- No linting or static analysis errors
- Documentation updated if needed
- No security vulnerabilities introduced
Development Commands
Setup
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
npm install
Daily Development
# Start FastAPI server
uvicorn main:app --reload
# Run Backend Tests
pytest
# Run E2E Tests
npx playwright test
Before Committing
# Run all checks
pytest && npx playwright test
Testing Requirements
Unit Testing
- Every module must have corresponding tests in
tests/. - Use
pytestfixtures for database and app setup. - Mock external APIs (Open Food Facts, OpenAI).
Integration Testing
- Test complete API flows using
httpx. - Verify database state after operations.
E2E Testing
- Use Playwright to test critical user journeys (Creating Plans, Adding Foods).
Commit Guidelines
Message Format
<type>(<scope>): <description>
[optional body]
[optional footer]
Types
feat: New featurefix: Bug fixdocs: Documentation onlystyle: Formatting, missing semicolons, etc.refactor: Code change that neither fixes a bug nor adds a featuretest: Adding missing testschore: Maintenance tasks
Definition of Done
A task is complete when:
- All code implemented to specification
- Unit tests written and passing
- Code coverage meets project requirements
- Documentation complete (if applicable)
- Code passes all configured linting and static analysis checks
- Implementation notes recorded for the phase summary
- Phase changes committed and summarized with Git Notes