AgentLint 实测验证 100/100基于 1,533 个 TypeScript 开源仓库统计

    TypeScript CLAUDE.md & AGENTS.md 模板

    严格类型约束、秒级 Vitest 单测循环与 ESM/CJS 边界,提炼自 1,533 个真实 TypeScript 开源仓库。

    # TypeScript Project — TypeScript Harness
    
    TypeScript application using pnpm, Vitest, ESLint, and strict compiler checks.
    
    ## Commands
    
    - Install: `pnpm install --frozen-lockfile`
    - Fast single test: `npx vitest run src/path/to/file.test.ts`
    - Full test suite: `pnpm test`
    - Typecheck & lint: `npx tsc --noEmit && pnpm lint`
    - Production build: `pnpm build`
    
    ## Rules
    
    - Don't use `any`, `@ts-ignore`, or `as unknown as` to silence compiler errors. Instead narrow types or parse external inputs with Zod. Because unchecked casts hide runtime null crashes.
    - Don't mix package managers. Instead use `pnpm` exclusively. Because competing lockfiles break CI caching and reproducible builds.
    - Don't run the full E2E suite during unit edits. Instead run the targeted Vitest file command above. Because full E2E takes minutes and stalls iteration.
    - When changing API schemas or shared types, read `docs/api-contracts.md` before editing handlers.
    
    ## Continuity & Safety
    
    - Keep `.env` and `CLAUDE.local.md` in `.gitignore` — never commit secrets or personal machine paths.
    - Update `HANDOFF.md` with verified test commands before ending a multi-step session.

    TypeScript 开源生态中最常采用的工程规则

    基于 4,533 仓库研究中 1,533 个公开 TypeScript 仓库的实测统计:

    react框架

    React for UI

    61.3%940 个仓库
    npm工具链

    npm package manager

    41.8%641 个仓库
    tailwindcss工具链

    Tailwind CSS for styling

    38.8%595 个仓库
    unit-tests测试

    Write unit tests for all changes

    37.6%577 个仓库
    eslint工具链

    ESLint for linting

    36.9%565 个仓库
    error-handling代码规范

    Proper error handling with context

    34.0%521 个仓库
    vitest测试

    Vitest for testing

    32.6%499 个仓库
    nextjs框架

    Next.js framework

    28.6%439 个仓库
    必写验证命令(对应规则 W1 与 W7)
    安装依赖
    pnpm install
    快速单测(秒级迭代)
    npx vitest run src/path/to/unit.test.ts
    全量测试
    pnpm test
    Lint 与静态检查
    pnpm lint && npx tsc --noEmit
    生产构建
    pnpm build
    TypeScript 项目中 AI 代理常见踩坑
    • 01不写明原因禁用时,AI 常悄悄插入 any 或 @ts-ignore 糊弄类型检查。
    • 02混用 npm、yarn 与 pnpm 锁文件会破坏 CI 构建一致性。
    • 03未加 --noEmit 的 tsc 监听命令会让无头代理会话卡死。

    更多实证验证模板