Agentic Node + TypeScript Starter

November 15, 2025 ยท View on GitHub

๐Ÿ“Š Build Status & Quality Metrics

CI/CD Workflows

Main PR CodeQL

Test Coverage & Quality

Lines Coverage Branches Coverage Functions Coverage

Code Quality Metrics

Code Duplication Mutation Score

Meta

License Node Version Package Manager Version

A batteries-included TypeScript starter template with comprehensive testing, code quality automation, and security scanning. Built for modern Node.js development with AI-assisted (agentic) coding workflow.

Note: This template includes example code to demonstrate its capabilities. These example files are clearly marked with header comments and should be removed when starting your project. See Getting Started for details.

๐Ÿค” What is Agentic Development?

"Agentic" in this context refers to AI-assisted development workflow, not AI agent runtime. This template is designed to work seamlessly with AI development tools like Claude Code to enhance your productivity through:

  • ๐Ÿค– AI-powered code generation - Let AI assistants help write boilerplate and tests
  • ๐Ÿ”„ Automated refactoring - AI tools can safely refactor with comprehensive test coverage
  • ๐Ÿ“ Documentation assistance - AI can help maintain docs in sync with code
  • ๐ŸŽฏ Issue-to-implementation workflows - Custom commands for AI-driven development

Important: This is a template repository for starting new projects. No AI agents or chatbots are included - the "agentic" aspect comes from using AI development tools (like Claude) to assist you in building your application faster and with higher quality.

๐Ÿ› ๏ธ Tech Stack

Core: Node.js 22+ โ€ข TypeScript ^5.9.2 (strict) โ€ข pnpm 10.15
Testing: Vitest โ€ข fast-check (property testing) โ€ข 80% coverage minimum
Quality: ESLint 9 โ€ข Prettier โ€ข Husky โ€ข Commitlint
Security: CodeQL โ€ข OSV Scanner โ€ข SBOM โ€ข SLSA attestations
CI/CD: GitHub Actions โ€ข Changesets โ€ข Automated releases

๐Ÿ“– Documentation

Full Documentation โ†’

๐Ÿš€ Quick Start

# Clone and setup
git clone https://github.com/sapientpants/agentic-node-ts-starter.git my-project
cd my-project

# Install dependencies (requires Node.js 22+ and pnpm 10.15)
pnpm install

# Set up configuration (required)
cp .env.example .env
# Edit .env with your configuration
# See docs/CONFIG.md for required environment variables

# Verify everything works
pnpm test
pnpm verify  # Full quality check

# Start developing
pnpm dev     # TypeScript watch mode

Prerequisites: Node.js 22+, pnpm 10.15, GitHub repo (for CI/CD)
Full setup guide: docs/GETTING_STARTED.md

๐Ÿ“š Key Commands

# Development
pnpm dev          # TypeScript watch mode
pnpm build        # Build to dist/
pnpm verify       # Run all quality checks

# Testing (80% coverage required)
pnpm test         # Run tests
pnpm test:watch   # Watch mode
pnpm test:coverage # With coverage report

# Quality
pnpm lint         # Check linting
pnpm lint:fix     # Fix linting issues
pnpm format       # Check formatting
pnpm format:fix   # Fix formatting
pnpm typecheck    # Type check only

# Releases
pnpm changeset    # Create changeset
pnpm sbom         # Generate SBOM

Full command reference: docs/DEVELOPMENT.md

๐Ÿ“Š Code Quality Dashboard

Comprehensive quality metrics tracked automatically on every CI run:

Testing Metrics

MetricCurrentThresholdStatusLocal Command
Line Coverage93.77%โ‰ฅ80%โœ… Passpnpm test:coverage
Branch Coverage84.95%โ‰ฅ80%โœ… Passpnpm test:coverage
Function Coverage100%โ‰ฅ80%โœ… Passpnpm test:coverage
Statement Coverage93.65%โ‰ฅ80%โœ… Passpnpm test:coverage
Mutation ScoreN/Aโ‰ฅ80%โณ Pendingpnpm mutation-test

Code Quality Metrics

MetricCurrentThresholdStatusLocal Command
Code Duplication0%<2%โœ… Passpnpm duplication
Cyclomatic ComplexityMax 10โ‰ค10โœ… Passpnpm lint
Max Function LinesMax 50โ‰ค50โœ… Passpnpm lint
Max Function ParametersMax 4โ‰ค4โœ… Passpnpm lint
Max Nesting DepthMax 3โ‰ค3โœ… Passpnpm lint
Circular Dependencies00โœ… Passpnpm deps:circular
Dead Code00โœ… Passpnpm dead-code

Security Metrics

MetricStatusToolLocal Command
Critical Vulnerabilitiesโœ… 0pnpm auditpnpm audit
High Vulnerabilitiesโœ… 0OSV ScannerCI only
CodeQL Findingsโœ… 0CodeQLCI only
Container Vulnerabilitiesโœ… 0Trivypnpm scan:container

Build & Dependencies

MetricStatusToolLocal Command
TypeScript Compilationโœ… Passtscpnpm typecheck
ESLint Violationsโœ… 0ESLintpnpm lint
Prettier Formattingโœ… PassPrettierpnpm format
Workflow Validationโœ… Passactionlintpnpm lint:workflows

Tools & Analyzers Used

  • Coverage: Vitest with V8 coverage provider
  • Mutation Testing: Stryker Mutator (JavaScript/TypeScript)
  • Duplication: jscpd (Copy/Paste Detector)
  • Complexity: ESLint with complexity rules
  • Circular Deps: madge (dependency graph analyzer)
  • Dead Code: Knip (unused exports, files, dependencies, types)
  • Security: pnpm audit, OSV Scanner, CodeQL, Trivy
  • Type Safety: TypeScript strict mode + type-aware ESLint rules

Note: Metrics are auto-updated on every push to main as part of the build workflow. The quality-metrics.json file is committed automatically after validation completes.

๐ŸŽฏ Quality Standards

This project enforces strict quality standards to ensure maintainability, security, and reliability:

Why These Standards?

80% Coverage Minimum - Ensures comprehensive test coverage without requiring 100% (which can lead to diminishing returns)

Low Complexity Limits - Functions with cyclomatic complexity >10 are harder to understand, test, and maintain

Zero Duplication Target - DRY principle reduces maintenance burden and bugs

No Circular Dependencies - Prevents tight coupling and enables better modularity

No Dead Code - Keeps codebase lean and maintainable

Zero Critical/High Vulnerabilities - Security-first approach protects users and infrastructure

Complexity Rationale

LimitRationale
Cyclomatic Complexity โ‰ค10Industry standard for maintainable code (NIST, IEEE)
Max 50 Lines/FunctionSingle screen view improves comprehension
Max 4 ParametersReduces cognitive load, encourages better abstractions
Max 3 Nesting DepthPrevents deeply nested code that's hard to reason about
Max 15 StatementsForces function decomposition, improves testability
Code Duplication <2%Minimal threshold allowing for small necessary repetition
Mutation Score โ‰ฅ80%Ensures tests actually verify behavior, not just achieve coverage

Test File Exceptions

Test files (tests/**/*.ts) have relaxed limits:

  • Cyclomatic complexity: โ‰ค15 (vs 10)
  • Max lines per function: โ‰ค600 (vs 50) - allows large describe blocks with many test cases

Pre-commit Quality Gates

The pnpm precommit command runs checks in optimized order for fast feedback:

  1. Security (pnpm audit) - Blocks commits with critical vulnerabilities
  2. Formatting (pnpm format) - Fast, easy to fix
  3. YAML/Markdown Linting - Fast file validation
  4. Workflow Validation - Prevents broken GitHub Actions
  5. Type Checking (pnpm typecheck) - Required for type-aware lint rules
  6. Linting (pnpm lint) - Comprehensive quality checks
  7. Structural Analysis - Circular deps, duplication, dead code
  8. Tests with Coverage (pnpm test:coverage) - Slowest check runs last

Mutation testing is excluded from pre-commit due to performance - run it periodically (weekly/monthly).

๐Ÿค– Claude Code Integration

This project includes special configurations for Claude Code:

Custom Commands

  • /analyze-and-fix-github-issue - Complete workflow for fixing GitHub issues
  • /release - Automated release process
  • /update-dependencies - Update dependencies with PR workflow

Git Hooks

  • Prevents bypassing verification with --no-verify flag
  • Ensures all commits pass quality checks

See CLAUDE.md for detailed Claude Code guidance.

๐Ÿ“ Project Structure

.
โ”œโ”€โ”€ .claude/           # Claude Code configurations
โ”‚   โ”œโ”€โ”€ commands/      # Custom slash commands
โ”‚   โ””โ”€โ”€ hooks/         # Git hook scripts
โ”œโ”€โ”€ .github/           # GitHub Actions workflows
โ”œโ”€โ”€ docs/              # Documentation
โ”œโ”€โ”€ src/               # Source code
โ”œโ”€โ”€ tests/             # Test files
โ”‚   โ”œโ”€โ”€ *.spec.ts      # Unit tests
โ”‚   โ””โ”€โ”€ *.property.spec.ts # Property-based tests
โ”œโ”€โ”€ mise.toml          # Tool version management
โ”œโ”€โ”€ package.json       # Dependencies and scripts
โ””โ”€โ”€ tsconfig.json      # TypeScript configuration

๐Ÿ”„ Features

Configuration & Environment

  • ๐Ÿ” Type-safe configuration with Zod validation
  • ๐Ÿ”Œ Configurable logging output - Redirect logs to stderr, files, syslog, or disable entirely (see docs/LOGGING_OUTPUT.md)
  • ๐Ÿ” Environment validation at startup with clear errors
  • ๐Ÿ” Sensitive value masking in error messages
  • ๐Ÿ“ See docs/CONFIG.md for configuration guide

Testing & Quality

  • โœ… Vitest with property-based testing (fast-check)
  • โœ… 80% coverage minimum enforced
  • โœ… Strict TypeScript with type-aware linting
  • โœ… Pre-commit hooks with Husky & lint-staged
  • โœ… Markdown and YAML linting for docs/config consistency

Security & Supply Chain

  • ๐Ÿ”’ CodeQL static analysis
  • ๐Ÿ”’ OSV Scanner for dependencies
  • ๐Ÿ”’ SBOM generation (CycloneDX)
  • ๐Ÿ”’ SLSA attestations for artifacts

Automation

  • ๐Ÿš€ GitHub Actions CI/CD pipeline
  • ๐Ÿš€ Changesets for versioning
  • ๐Ÿš€ Automated releases with changelog
  • ๐Ÿš€ Claude Code integration

โš™๏ธ Required Setup

GitHub Repository Settings

Actions permissions (Settings โ†’ Actions โ†’ General):

  • โœ… Read and write permissions
  • โœ… Allow GitHub Actions to create and approve pull requests

Auto-merge (Settings โ†’ General โ†’ Pull Requests):

  • โœ… Allow auto-merge
  • โœ… Automatically delete head branches

For automated releases, add secrets:

  • RELEASE_TOKEN - GitHub PAT with repo/workflow scopes (triggers publish workflow)
  • NPM_TOKEN - For npm publishing (optional)

๐Ÿ“ฆ Release Distribution Setup

NPM Publishing

To enable npm publishing:

  1. Add NPM_TOKEN secret in repository settings
  2. Remove "private": true from package.json
  3. Use a scoped package name: @yourorg/package-name

Docker Publishing

โš ๏ธ Important: The default Dockerfile includes a healthcheck that expects a web server with a /health endpoint on port 3000. See Docker Configuration Guide for detailed instructions on configuring healthchecks for different application types (web services, CLI tools, workers).

To enable Docker builds:

  1. Set repository variable ENABLE_DOCKER_RELEASE to true
  2. Add secrets for Docker Hub (optional):
    • DOCKERHUB_USERNAME
    • DOCKERHUB_TOKEN
  3. Images are automatically pushed to GitHub Container Registry

๐Ÿ”’ Security Features

  • Dependency Auditing: Critical vulnerability checks on every CI run
  • SBOM Generation: CycloneDX format for supply chain transparency
  • CodeQL Analysis: Static security analysis
  • OSV Scanning: Open Source Vulnerability detection
  • SLSA Provenance: Build attestations
  • Container Attestations: SBOM and provenance for Docker images

๐Ÿ“š Additional Resources

๐Ÿ“„ License

This is a template repository. Feel free to use it for your projects.