This file is the canonical contributor guide for this repository.
If another assistant-specific file exists, it should defer to this document for repo workflow, quality gates, and architecture constraints.
Keep this Electron video app production-ready while preserving:
- clear module boundaries
- deterministic tests
- stable user-facing behavior
- release integrity
Do not optimize for "quickly making tests pass." Optimize for making the codebase more robust.
For any non-trivial change, follow this order:
- Identify the affected feature and expected behavior.
- Define or update acceptance criteria before implementation.
- Add or update tests first for the intended behavior.
- Implement the code change.
- Run the full verification suite.
- Fix code defects if tests fail. Do not weaken assertions unless the product requirement itself changed.
- Prefer small, isolated changes over broad rewrites.
- Preserve behavior unless the task explicitly changes product behavior.
- Do not introduce duplicate business logic across renderer and main.
- Shared normalization/domain logic belongs in
src/shared/. - Main-process business logic belongs in
src/main/services/, not in IPC registration or app bootstrap. - Renderer feature logic belongs in
src/renderer/features/, not inline insrc/index.html. src/preload.jsshould remain a narrow bridge and not gain business logic.
Current intended structure:
src/main/- Electron runtime bootstrapping, IPC registration, services, infra
src/shared/- domain rules, normalization, data-shape helpers shared across layers
src/renderer/- renderer entrypoint and feature utilities
tests/unit/- pure logic and isolated helper tests
tests/integration/- service/integration tests with controlled fakes
tests/e2e/- Electron smoke and workflow checks
When adding new code:
- Put pure data logic in a testable module first.
- Keep side effects at the edges.
- Inject dependencies where practical for testability.
- Favor explicit validation and errors over silent fallback when data is invalid.
Before implementing behavior changes:
- Add unit tests for pure logic.
- Add integration tests for filesystem, IPC, or service coordination.
- Add or extend e2e coverage for critical user flows if the change affects runtime behavior.
- For every user-visible behavior change, add at least one proving test that would fail without the change.
- Treat "what behavior changed?" as a required design question before coding.
Minimum expectation by change type:
- Pure helper/domain change: unit tests
- Main-process service or IPC change: unit + integration tests
- Renderer feature change: utility tests and, if behaviorally important, e2e or smoke coverage
- Release/build/packaging change: verification via packaging smoke and relevant CI updates
Do not chase 100% coverage as a vanity target. Protect confidence instead.
Coverage priorities by layer:
src/shared/**- target very high coverage
- new logic should normally ship with direct unit coverage
- pure modules in
src/main/services/**- target high coverage
- normalization, parsing, validation, section math, FPS selection, ffmpeg filter builders should be directly tested
- orchestration-heavy main-process code
- combine unit coverage with integration coverage
- do not rely on line coverage alone
- renderer runtime glue
- prefer behavior tests and smoke/e2e coverage over brittle implementation-detail tests
Use this rule when changing code:
- if logic moved or behavior changed, coverage for that area should stay the same or improve
- if an agent adds a new branch/edge case, it should usually add a test for that branch
- do not lower confidence in a critical path while keeping the global coverage number flat
- Never "fix" a test by removing meaningful assertions just to get green CI.
- If a test reveals a bug, fix the underlying code.
- Prefer deterministic tests using mocks, fakes, fixtures, and temp directories.
- Avoid live external dependencies in tests.
- Keep tests readable and behavior-focused.
Use npm only in this repo.
Primary commands:
npm run build:stylesnpm run lintnpm run typechecknpm run testnpm run test:e2enpm run package:smokenpm run check
Before finishing a substantive change, run:
npm run check
If npm run check is too slow during iteration, run a narrower loop while developing, but do not mark work complete until the full check passes.
- Start the app with
npm run devornpm start, not rawelectron .- this ensures renderer styles are rebuilt first
- Tailwind output is generated into
src/renderer/styles/main.css - Do not reintroduce Tailwind CDN loading
- Keep the stricter CSP in
src/index.html
- Required env vars must be documented in
.env.example - Validate required env at runtime before using it
- Do not hardcode secrets
- Do not commit
.env
Any change that affects build, packaging, or runtime startup must keep these green:
- lint
- typecheck
- unit/integration tests
- Electron smoke test
- packaging smoke
Update .github/workflows/ci.yml if the required validation steps change.
A non-trivial task is not complete until all of the following are true:
- acceptance criteria were identified or updated
- tests were added or updated for the changed behavior
- implementation matches the tested behavior
- no meaningful assertion was weakened just to get green results
- docs were updated if contributor workflow or product behavior changed
npm run checkpassed
Every final handoff from an agent should clearly state:
- what behavior changed
- what tests were added or updated
- what commands were run
- any residual risk or intentionally untested edge case
When asking an agent to add or change a feature, prefer prompts that explicitly require:
- acceptance criteria first
- tests first or tests alongside the change
- code robustness over test weakening
npm run checkbefore completion- a summary of the exact tests added
Bad prompt shape:
- "add this feature and make the tests pass"
Better prompt shape:
- "define the behavior, add the proving tests first, implement the feature, do not weaken tests, run
npm run check, and report what tests were added"
- Prefer composition over large monoliths.
- Keep files focused.
- Name modules by responsibility.
- Write defensive normalization around persisted project/timeline data.
- Add comments only where the logic is non-obvious.
- Avoid dead code and stale compatibility layers unless intentionally retained.
Update docs when behavior or contributor workflow changes:
docs/production/feature-inventory.mddocs/production/target-architecture.mddocs/production/runbook.md- this file
Default to:
- tests first
- smaller modules
- stricter validation
- shared domain logic
- full
npm run checkbefore completion
- Prefer compact plans and concise summaries unless more depth is requested.
- Cross-platform behavior matters for this app; avoid macOS-only assumptions in filesystem paths, dialogs, and project workflows.