## BACKLOG WORKFLOW INSTRUCTIONS
This project uses Backlog.md MCP for all task and project management.
**CRITICAL RESOURCE**: Read `backlog://workflow/overview` to understand when and how to use Backlog for this project.
- **First time working here?** Read the overview resource IMMEDIATELY to learn the workflow
- **Already familiar?** You should have the overview cached ("## Backlog.md Overview (MCP)")
- **When to read it**: BEFORE creating tasks, or when you're unsure whether to track work
The overview resource contains:
- Decision framework for when to create tasks
- Search-first workflow to avoid duplicates
- Links to detailed guides for task creation, execution, and completion
- MCP tools reference
You MUST read the overview resource to understand the complete workflow. The information is NOT summarized here.
## Commands
### Development
- `bun i` - Install dependencies
- `bun test` - Run all tests
- `bun run build` - Build the CLI tool
- `bun run cli` - Use the CLI tool directly
### Testing & Quality
- `CLAUDECODE=1 bun test` - Run all tests with failures-only output (RECOMMENDED - full output is too long for Claude)
- `bun test ` - Run specific test file
- `bun test src/**/*.test.ts` - Unit tests only
- `bun test src/mcp/**/*.test.ts` - MCP tests only
- `bun test --watch` - Run tests in watch mode
- `bunx tsc --noEmit` - Type-check code
- `bun run check .` - Run all Biome checks (format + lint)
**Development Strategy**: Test specific files during development, run full suite before commits.
**Important**: Always use `CLAUDECODE=1` when running full test suite - the default verbose output exceeds Claude's consumption limits.
### Performance Benchmarking
- `bun run benchmark` - Run performance benchmark on all test files
- Runs each test file individually and measures execution time
- Groups results by test prefix (mcp-, cli-, board-, etc.)
- Generates `test-benchmark-report.json` with detailed timing data
- Shows top 10 slowest tests and performance breakdown by category
### Pre-Commit Validation (REQUIRED)
**Claude MUST verify all pass before committing:**
```bash
bunx tsc --noEmit # TypeScript compilation
bun run check . # Lint/format
CLAUDECODE=1 bun test --timeout 180000 # Full test suite (failures-only output)
```
### Configuration
- `bun run cli config list` - View all configuration values
- `bun run cli config get ` - Get specific value (e.g. defaultEditor)
- `bun run cli config set ` - Set with validation
## Core Structure
- **CLI Tool**: Built with Bun and TypeScript as a global npm package (`npm i -g backlog.md`)
- **Source Code**: Located in `/src` directory with modular TypeScript structure
- **Task Management**: Uses markdown files in `backlog/` directory structure
- **Git Workflow**: Task IDs referenced in commits and PRs (`TASK-123 - Title`)
- **Branching**: Use feature branches when working on tasks (e.g. `tasks/task-123-feature-name`)
## Code Standards
- **Runtime**: Bun with TypeScript 5
- **Formatting**: Biome with tab indentation and double quotes
- **Linting**: Biome recommended rules
- **Testing**: Bun's built-in test runner
- **Pre-commit**: Husky + lint-staged automatically runs Biome checks before commits
The pre-commit hook automatically runs `biome check --write` on staged files to ensure code quality. If linting errors are found, the commit will be blocked until fixed.
## Architecture Guidelines
- **Separation of Concerns**: CLI logic and utility functions are kept separate to avoid side effects during testing
- **Utility Functions**: Reusable utility functions (like ID generators) are placed in `src/utils/` directory
- **No Side Effects on Import**: Modules should not execute CLI code when imported by other modules or tests
- **Branching**: Use feature branches when working on tasks (e.g. `tasks/task-123-feature-name`)
- **Committing**: Use the following format: `TASK-123 - Title of the task`
- **Github CLI**: Use `gh` whenever possible for PRs and issues
## MCP Architecture Principles
- **MCP is a Pure Protocol Wrapper**: Protocol translation ONLY - no business logic, no feature extensions
- **CLI Feature Parity**: MCP = strict subset of CLI capabilities
- **Core API Usage**: All operations MUST use Core APIs (never direct filesystem/git)
- **Shared Utilities**: Reuse exact same utilities as CLI (`src/utils/task-builders.ts`)
- **🔒 Local Development Only**: stdio transport only (see [/backlog/docs/mcp/README.md](backlog/docs/mcp/README.md))
**Violations to Avoid**:
- Custom business logic in MCP handlers
- Direct filesystem or git operations
- Features beyond CLI capabilities
See MCP implementation in `/src/mcp/` for development details.
## CLI Multi-line Input (description/plan/notes)
The CLI preserves input literally; `\n` sequences in normal quotes are not converted. Use one of the following when you need real newlines:
- **Bash/Zsh (ANSI‑C quoting)**:
- `backlog task edit 42 --notes $'Line1\nLine2'`
- `backlog task edit 42 --plan $'1. A\n2. B'`
- **POSIX (printf)**:
- `backlog task edit 42 --desc "$(printf 'Line1\nLine2')"`
- **PowerShell (backtick)**:
- `backlog task edit 42 --desc "Line1\`nLine2"`
*Note: `"...\n..."` passes literal backslash+n, not newline*
## Using Bun
Default to using Bun instead of Node.js:
- Use `bun ` instead of `node ` or `ts-node `
- Use `bun test` instead of `jest` or `vitest`
- Use `bun build ` instead of `webpack` or `esbuild`
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
- Use `bun run