Shared repository instructions for Codex, Claude Code, Gemini CLI, Cursor, Copilot, and other coding agents. Keep this file concise and current; model-specific wrapper files (CLAUDE.md, GEMINI.md) import this file instead of duplicating project facts.
varvis-download is a Node.js CLI for downloading BAM/BAI/VCF files from the Varvis genomics API. It handles authentication, filtering, archived-file restoration, ranged downloads with samtools/tabix/bgzip, and proxy configuration.
Primary stack:
- Node.js >= 22.22.2, npm >= 10
- CommonJS (
.cjs) for runtime code; ES modules (.mjs) for scripts;package.jsonis"type": "module" - TypeScript only for type-checking (
tsc --noEmit); no transpile step - Jest 30 for unit tests, Jest with
--runInBandfor integration tests - ESLint 10 (flat config) with prettier, jsdoc, unicorn, security, no-secrets plugins
- VitePress for the docs site under
docs/ - husky + lint-staged for pre-commit hooks
undicifor HTTP,winstonfor logging,yargsfor CLI parsing
- Read
README.md, this file, and the files directly related to the task. - Run
git status --shortbefore editing. Do not overwrite uncommitted user work. - Prefer
rg(ripgrep) andrg --filesfor search. - Use
npm; do not introducepnpm,yarn, orbunlockfiles. - Keep changes scoped. Do not modernise unrelated code while fixing a docs change or a single feature.
Use the scripts in package.json as the primary interface:
- Install:
npm ci(ornpm installif updating deps) - Lint:
npm run lint - Lint + fix:
npm run lint:fix - Format:
npm run format - Format check:
npx prettier --check . - Type-check:
npm run type-check - Unit tests:
npm test - Unit tests + coverage:
npm test -- --coverage - Integration tests (needs
VARVIS_PLAYGROUND_USER/VARVIS_PLAYGROUND_PASS):npm run test:integration - Architecture budget check (line limits, lockfile sanity):
npm run architecture:check - Docs dev server:
npm run docs:dev - Docs build:
npm run docs:build
There is no single npm run check aggregate yet. The local CI-equivalent gate is:
npm run lint && npx prettier --check . && npm run type-check && npm test && npm run architecture:check- Entry point:
varvis-download.cjs— CLI parsing, top-level orchestration. Treat as legacy oversized file (1051 LOC); split when touched. - Domain modules:
js/*.cjs— each module owns one concern (auth, fetch, range, archive, filter, prompts, restoration state, tool checks, URLs, files, logging, config, arrays, API client). - Tests mirror module structure under
tests/unit/andtests/integration/. - Test helpers live in
tests/helpers/(testUtils.js,fixtures.js,mockFactories.js). tests/setup.jsruns before every Jest worker and cleans${os.tmpdir()}/varvis-download-testsafter the suite.- Docs source lives in
docs/; generated API reference underdocs/api/. Generator script:docs/scripts/docs-generator.cjs(also legacy oversized). - Do not couple CLI argv parsing to domain modules — pass plain config objects.
- Do not invent new external tool dependencies beyond
samtools,tabix,bgzipwithout discussion.
- Follow existing CommonJS patterns in neighbouring files.
require()+module.exports, not ESMimport/export, injs/andvarvis-download.cjs. - Maintain small files: keep all source and test files under 600 lines. The architecture budget script warns at 500 and blocks new files at 600. Existing oversized files are listed in
scripts/check-architecture-budget.mjsasKNOWN_OVERSIZED_FILES; if your change touches one, split it as part of the work. - Use
node:protocol for built-in module imports (require('node:fs'), notrequire('fs')). Enforced byunicorn/prefer-node-protocol. - Filenames are
camelCase.cjs(enforced). Exceptions are listed ineslint.config.js(unicorn/filename-case). - JSDoc is required on exported functions, classes, and methods in
js/**/*.cjsand root*.cjs. Tests anddocs/scripts/are exempt. - Never commit secrets, real credentials, or raw Varvis API payloads. Use redacted fixtures.
- Keep comments sparse. Prefer readable code over explanatory comments. The exception is a non-obvious why (workaround, hidden constraint, surprising invariant).
- Verify before completion: never claim a task is done without running the relevant Jest tests.
- For behaviour changes, add or update focused unit tests near the changed module.
- For multi-module flows, add an integration test under
tests/integration/. - E2E download tests live under
tests/integration/e2e/and need playground credentials; they only run onmainPRs. - Coverage thresholds are enforced by Jest config (currently 60/50/60/60 global).
- Run
npm test -- --testPathPatterns=<name>(Jest 30 renamed--testPathPattern→--testPathPatterns) for focused runs. - For docs-only changes, run at least
npx prettier --checkon the touched Markdown files.
Follow a "Think-Plan-Act-Verify" cycle:
- Think & Research: explore the codebase and requirements before proposing changes.
- Plan: for non-trivial changes, write a short plan first. Break complex tasks into small, verifiable steps.
- Act: implement incrementally. Maintain modularity. Favour deterministic code over clever abstractions.
- Refactor as you go: if a task touches an oversized file (> 600 lines or in
KNOWN_OVERSIZED_FILES), prioritise splitting it as part of the work. - Verify: run
npm run lint,npm run type-check,npm test,npm run architecture:checkbefore claiming done.
- Use Superpowers Skills when they match the task. Start sessions by loading
superpowers:using-superpowers. - Default to feature branches and PRs for substantial work. Direct commits to
mainare acceptable for small docs, fixes, or instruction updates after the local gate has passed. - Commits use short conventional-ish prefixes:
feat:,fix:,docs:,chore:,test:,refactor:,ci:. - Keep agent manifests short. Put durable project facts in
AGENTS.md; put tool-specific loading notes only inCLAUDE.mdorGEMINI.md.
- Never run
git push --forcetomainorgit reset --hardagainst uncommitted work without explicit instruction. - Never bypass hooks (
--no-verify,--no-gpg-sign) unless explicitly asked. - Never delete a failing test to make CI green. Fix the underlying issue or report it.
- Never weaken the JSDoc, security, or no-secrets ESLint rules to silence a violation; refactor the code instead.
- Never add new external CLI tool dependencies (beyond samtools/tabix/bgzip) without discussion.
- Ask first before deleting files outside the task scope, before changing CI workflows, or before introducing a new top-level dependency.
- Codex reads
AGENTS.mdas its project instruction manifest directly. - Claude Code reads
CLAUDE.md; this repo'sCLAUDE.mdimportsAGENTS.mdvia@AGENTS.md. - Gemini CLI reads
GEMINI.md; this repo'sGEMINI.mdimportsAGENTS.mdvia@AGENTS.md. - Cursor and GitHub Copilot read
AGENTS.mdnatively. - If a model appears to ignore these instructions, ask it to refresh or show its loaded project memory before editing files.