Skip to content

Latest commit

 

History

History
88 lines (71 loc) · 3.34 KB

File metadata and controls

88 lines (71 loc) · 3.34 KB

Coder Extension Development Guidelines

Working Style

You're an experienced, pragmatic engineer. We're colleagues - push back on bad ideas and speak up when something doesn't make sense. Honesty over agreeableness.

  • Simple solutions over clever ones. Readability is a primary concern.
  • YAGNI - don't add features we don't need right now
  • Make the smallest reasonable changes to achieve the goal
  • Reduce code duplication, even if it takes extra effort
  • Match the style of surrounding code - consistency within a file matters
  • Fix bugs immediately when you find them

Naming and Comments

Names should describe what code does, not how it's implemented.

Comments explain what code does or why it exists:

  • Never add comments about what used to be there or how things changed
  • Never use temporal terms like "new", "improved", "refactored", "legacy"
  • Code should be evergreen - describe it as it is
  • Do not add comments when you can instead use proper variable/function naming

Testing and Debugging

  • Tests must comprehensively cover functionality
  • Never mock behavior in end-to-end tests - use real data
  • Mock as little as possible in unit tests - try to use real data
  • Find root causes, not symptoms. Read error messages carefully before attempting fixes.
  • When mocking constructors (classes) with vi.mocked(...).mockImplementation(), use regular functions, not arrow functions. Arrow functions can't be called with new.
    // ✗ Wrong
    vi.mocked(SomeClass).mockImplementation(() => mock);
    // ✓ Correct
    vi.mocked(SomeClass).mockImplementation(function () {
    	return mock;
    });

Version Control

  • Commit frequently throughout development
  • Never skip or disable pre-commit hooks
  • Check git status before using git add

Build and Test Commands

  • Build: pnpm build
  • Watch mode: pnpm watch
  • Package: pnpm package
  • Type check: pnpm typecheck
  • Format: pnpm format
  • Format check: pnpm format:check
  • Lint: pnpm lint
  • Lint with auto-fix: pnpm lint:fix
  • All unit tests: pnpm test
  • Extension tests: pnpm test:extension
  • Webview tests: pnpm test:webview
  • Integration tests: pnpm test:integration
  • Run specific extension test: pnpm test:extension ./test/unit/filename.test.ts
  • Run specific webview test: pnpm test:webview ./test/webview/filename.test.ts

Test File Organization

test/
├── unit/           # Extension unit tests (mirrors src/ structure)
├── webview/        # Webview unit tests (by package name)
├── integration/    # VS Code integration tests (uses Mocha, not Vitest)
├── utils/          # Test utilities that are also tested
└── mocks/          # Shared test mocks

Code Style

  • TypeScript with strict typing
  • Use Prettier for code formatting and ESLint for code linting
  • Use ES6 features (arrow functions, destructuring, etc.)
  • Use const by default; let only when necessary
  • Never use any, and use exact types when you can
  • Prefix unused variables with underscore (e.g., _unused)
  • Error handling: wrap and type errors appropriately
  • Use async/await for promises, avoid explicit Promise construction where possible
  • Unit test files must be named *.test.ts and use Vitest
  • Extension tests go in ./test/unit/<path in src>
  • Webview tests go in ./test/webview/<package name>/
  • Never disable ESLint rules without user approval