Skip to content

Ultimate Guide to Optimizing Development Workflow with Bun, Biome, TurboRepo, Husky, PM2, and GitHub Actions

Optimizing your development workflow is essential for speed, efficiency, and automation. This guide covers Bun, Biome, TurboRepo, Husky, PM2, and GitHub Actions, helping you:

  • Speed up dependency management with Bun
  • Optimize linting and formatting with Biome
  • Improve monorepo performance with TurboRepo
  • Automate Git hooks using Husky
  • Optimize production processes using PM2 with Bun
  • Enhance CI/CD performance using GitHub Actions

1. Using Bun for Faster Dependency Management

Bun is a modern alternative to Node.js that provides a fast runtime, package manager, and test runner.

1.1 Install Bun

sh
curl -fsSL https://bun.sh/install | bash

or using Homebrew (Mac):

sh
brew install oven-sh/bun/bun

1.2 Set Bun as Default Package Manager

Modify package.json:

json
{
  "packageManager": "bun@latest"
}

1.3 Install Dependencies with Bun

sh
bun install
  • 10x faster than npm and yarn
  • Uses bun.lockb for deterministic installs

2. Using Biome for Fast Linting and Formatting

Biome is an all-in-one tool that replaces ESLint & Prettier.

2.1 Install Biome

sh
bun add -D @biomejs/biome

2.2 Lint and Format Code

sh
biome check .
biome format . --write

2.3 Ignore Folders in Biome

Create a .biomeignore file:

node_modules
dist
coverage

3. Using TurboRepo to Optimize Monorepos

TurboRepo speeds up monorepos using caching and parallel execution.

3.1 Install TurboRepo

sh
bun add -D turbo

3.2 Configure turbo.json to Use Bun

json
{
  "$schema": "https://turbo.build/schema.json",
  "packageManager": "bun",
  "pipeline": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": ["dist/**"]
    }
  }
}

3.3 Run Turbo Commands with Bun

Modify package.json:

json
{
  "scripts": {
    "build": "bun run turbo run build"
  }
}

Run with:

sh
bun run build

4. Automate Git Hooks Using Husky

Instead of manually setting up Git hooks, Husky automates them.

4.1 Install Husky

sh
bun add -D husky
bunx husky-init && bun install

4.2 Add Git Hooks

Pre-commit: Format and Lint Code

sh
npx husky add .husky/pre-commit "bun biome format . --write && bun biome check ."

Commit Message: Enforce Conventional Commits

sh
npx husky add .husky/commit-msg "bun run commitlint --edit $1"

5. Optimizing Production with PM2 and Bun

PM2 is a process manager for Node.js and Bun apps.

5.1 Install PM2

sh
bun add -g pm2

5.2 Start an App with PM2 Using Bun

sh
pm2 start "bun run start" --name my-app

5.3 Auto-Restart on Failure

sh
pm2 start "bun run start" --name my-app --watch

5.4 Save and Auto-Start PM2 on System Boot

sh
pm2 save
pm2 startup

6. GitHub Actions: Automating CI/CD with Caching

6.1 Configure GitHub Actions (ci.yml)

yaml
name: CI

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Setup Bun
        uses: oven-sh/setup-bun@v1
        with:
          bun-version: latest

      - name: Cache Bun Dependencies
        uses: actions/cache@v3
        with:
          path: ~/.bun/install/cache
          key: ${{ runner.os }}-bun-${{ hashFiles('bun.lockb') }}
          restore-keys: |
            ${{ runner.os }}-bun-

      - name: Install Dependencies
        run: bun install --frozen-lockfile

      - name: Run Build
        run: bun run build
  • Caches dependencies for faster builds
  • Ensures clean and reproducible installs

7. Full Optimization Workflow Summary

OptimizationTool UsedBenefit
Fast Dependency ManagementBun10x faster installs, runtime speedup
Linting & FormattingBiomeReplaces ESLint & Prettier, faster performance
Monorepo OptimizationTurboRepoCaching, parallel execution
Git Hooks AutomationHuskyEnforces pre-commit rules and commit conventions
Process ManagementPM2Ensures Bun applications restart on failure
CI/CD AutomationGitHub ActionsCached dependencies, automated builds

8. Next Steps

  • Migrate your projects to Bun, Biome, TurboRepo, and PM2
  • Set up Husky for pre-commit checks
  • Optimize CI/CD with GitHub Actions

By implementing this fully optimized workflow, you’ll have:

  • Blazing-fast builds
  • Automated code quality enforcement
  • Optimized monorepos and caching
  • Seamless CI/CD with minimal downtime

Your development process will be leaner, faster, and more efficient than ever! 🚀