---
description: Always use Bun instead of Node/npm, and ensure to use the local installation at ~/.bun/bin/bun
globs: **/*.{ts,js,json,svelte}
---
<rule>
  When using Bun:
  1. Installation and Path:
     - Primary: Use Bun from PATH if available
     - Fallback: $HOME/.bun/bin/bun
     - Always use command path resolution pattern from command-paths.mdc
  2. Package Management:
     - Use Bun instead of Node/npm for all package management
     - Replace npm scripts with Bun equivalents in package.json
     - Use Bun for installing, running, and testing packages
  3. Command Mappings:
     - npm install -> bun install
     - npm run -> bun run
     - node -> bun
  4. CI/CD and Automation:
     - Ensure Bun is used for all CI/CD pipelines
     - Document any exceptions where Node/npm must be used
     - Use build.sh for consistent builds across environments

Never use npm or node commands directly.

metadata:
  priority: high
  version: 1.0
</rule>

examples:
  - input: |
      # Bad: Using absolute path directly
      ~/.bun/bin/bun test
    output: |
      # Good: Try PATH first
      if command -v bun >/dev/null 2>&1; then
          BUN_CMD="bun"
      else
          BUN_CMD="$HOME/.bun/bin/bun"
      fi
      $BUN_CMD test

  - input: |
      # Bad: Using npm commands
      npm install express
    output: |
      # Good: Using Bun with PATH resolution
      if command -v bun >/dev/null 2>&1; then
          BUN_CMD="bun"
      else
          BUN_CMD="$HOME/.bun/bin/bun"
      fi
      $BUN_CMD add express