Skip to main content
hooksSource-backedReview first Safety Privacy

SCSS Auto Compiler - Hooks

Automatically compiles SCSS/Sass files to CSS when they are modified.

by JSONbored·added 2025-09-19·
HarnessClaude Code
Trigger:PostToolUse
Review first review before installing

Open the source and read safety notes before installing.

Citation facts

Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.

Safety notes
Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.
Privacy notes
Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.
Author
JSONbored
Claim status
unclaimed
Last verified
2025-09-19

Decision playbook

Review trust signals before you adopt

Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.

Compare context
Selected

0

Current score

78

Baseline

Delta

No baseline selected

No major trust-signal divergence detected in the current selection.

Source and provenance checks

Complete

Confirm ownership and provenance before trusting install instructions.

  • Source link availableRequired

    Open the canonical repository and verify ownership.

    Done
  • Source provenance statusRequired

    Marked as source-backed.

    Done
  • Metadata reviewed

    Registry metadata indicates a reviewed listing.

    Done

Safety and privacy checks

Complete

Validate risk disclosures before installation or API wiring.

  • Safety notes presentRequired

    Review the listed safety guidance before running commands.

    Done
  • Privacy notes presentRequired

    Review data handling notes before connecting accounts or secrets.

    Done
  • Trust level risk gateRequired

    Trust level does not block evaluation.

    Done

Package and install checks

Needs review

Check package metadata and artifact integrity signals.

  • Install payload available

    Install or copy payload is available for review.

    Done
  • Package verification flag

    No package verification flag provided.

    Pending
  • Checksum metadata

    No checksum provided for downloaded artifact.

    Pending

Compare-driven decision checks

Needs review

Use compare context to validate trade-offs before adoption.

  • Compare tray has multiple entries

    Add at least one more entry to compare trust differences.

    Pending
  • Baseline comparison available

    No baseline peer selected yet.

    Pending
  • Diverging trust signals identified

    No major trust-signal divergence found.

    Pending

Setup at a glance

CLI install

Copy-ready — paste the snippet to get started.

Install command

Provided

Config snippet

Provided

Copy snippet

Provided

Prerequisites

None

Platforms

1 listed

Difficulty

0/100

Adoption plan

Balanced adoption plan

Current risk score 16/100. Use staged verification before broader rollout.

Risk 16

Pre-adoption checks

Validate source and review signals before any execution.

  • Confirm source provenanceRequired

    Source URL/provenance metadata is present.

    Done
  • Confirm metadata review state

    Listing has review metadata.

    Done
  • Verify install payload

    Install/config payload exists and can be inspected.

    Done

Security checks

Confirm safety, privacy, and package integrity signals.

  • Review safety notesRequired

    Safety notes are present.

    Done
  • Review privacy notesRequired

    Privacy notes are present.

    Done
  • Verify package integrity metadata

    No package verification/checksum metadata.

    Pending

Rollout

Adopt in controlled steps based on the selected plan.

  • Run in isolated sandbox firstRequired

    Use a constrained sandbox and observe behavior across multiple tasks.

    Pending
  • Roll out graduallyRequired

    Roll out to a small cohort before wider usage.

    Pending
  • Set monitoring and fallback

    Define rollback path and monitor errors after adoption.

    Pending

Evidence readiness

Evidence readiness matrix · balanced

Required evidence gates are covered (5/6 signals complete).

Risk 15

Source provenance

Present

Source repository/provenance is listed.

Required in this preset

Metadata review

Present

Review metadata is present.

Required in this preset

Safety notes

Present

Safety notes are present.

Required in this preset

Privacy notes

Present

Privacy notes are present.

Optional in this preset

Package integrity

Missing

Package integrity metadata is missing.

Optional in this preset

Install payload

Present

Install payload is available.

Required in this preset

Required evidence gates are covered for this preset.

Decision timeline

Decision timeline · balanced

5/6 steps complete with no blocking gaps for this preset.

Risk 14

triage

Confirm source provenanceRequired

Source/provenance metadata is available.

Done

triage

Check metadata review statusRequired

Review metadata is available.

Done

verify

Review safety notesRequired

Safety notes are available.

Done

verify

Review privacy notes

Privacy notes are available.

Done

verify

Validate package integrity metadata

Package integrity metadata is missing.

Pending

rollout

Verify install payload and commandsRequired

Install payload is available.

Done

No required blockers for this timeline preset.

Safety & privacy surface

Safety & privacy surface

1 safety and 1 privacy notes across 2 risk areas. Review closely: credentials & tokens, permissions & scopes.

2 areas
  • SafetyPermissions & scopesRuns automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.
  • PrivacyCredentials & tokensReceives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.

Safety notes

  • Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.

Privacy notes

  • Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.

Schema details

Install type
cli
Reading time
5 min
Difficulty score
0
Troubleshooting
Yes
Breaking changes
No
Runtime and command metadata
Trigger
PostToolUse
Script language
bash
Script body
#!/bin/bash

# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')

if [ -z "$FILE_PATH" ]; then
  exit 0
fi

# Check if this is a SCSS or Sass file
if [[ "$FILE_PATH" == *.scss ]] || [[ "$FILE_PATH" == *.sass ]]; then
    echo "🎨 SCSS Auto-Compiler - Processing stylesheet..."
    echo "📄 File: $FILE_PATH"
    
    # Check if file exists
    if [ ! -f "$FILE_PATH" ]; then
        echo "⚠️ File not found: $FILE_PATH"
        exit 1
    fi
    
    # Determine output CSS file path
    if [[ "$FILE_PATH" == *.scss ]]; then
        CSS_OUTPUT="${FILE_PATH%.scss}.css"
        MAP_OUTPUT="${FILE_PATH%.scss}.css.map"
    else  # .sass file
        CSS_OUTPUT="${FILE_PATH%.sass}.css"
        MAP_OUTPUT="${FILE_PATH%.sass}.css.map"
    fi
    
    echo "📁 Output: $CSS_OUTPUT"
    
    # Check if Sass compiler is available
    if command -v sass >/dev/null 2>&1; then
        SASS_CMD="sass"
    elif command -v npx >/dev/null 2>&1 && npx sass --version >/dev/null 2>&1; then
        SASS_CMD="npx sass"
    elif command -v node-sass >/dev/null 2>&1; then
        SASS_CMD="node-sass"
        echo "ℹ️ Using node-sass (consider upgrading to Dart Sass)"
    else
        echo "⚠️ No Sass compiler found"
        echo "💡 Install options:"
        echo "  • npm install -g sass (Dart Sass - recommended)"
        echo "  • npm install sass (project-local)"
        echo "  • brew install sass/sass/sass (macOS)"
        exit 1
    fi
    
    echo "🔧 Compiling with $SASS_CMD..."
    
    # Compile SCSS/Sass to CSS with source maps
    if [[ "$SASS_CMD" == "node-sass" ]]; then
        # node-sass syntax
        if node-sass "$FILE_PATH" "$CSS_OUTPUT" --source-map true --source-map-contents; then
            echo "✅ SCSS compiled successfully with node-sass"
        else
            echo "❌ SCSS compilation failed"
            exit 1
        fi
    else
        # Dart Sass syntax
        if $SASS_CMD "$FILE_PATH" "$CSS_OUTPUT" --source-map; then
            echo "✅ SCSS compiled successfully"
        else
            echo "❌ SCSS compilation failed"
            exit 1
        fi
    fi
    
    # Check output file size
    if [ -f "$CSS_OUTPUT" ]; then
        CSS_SIZE=$(stat -f%z "$CSS_OUTPUT" 2>/dev/null || stat -c%s "$CSS_OUTPUT" 2>/dev/null || echo "unknown")
        echo "📊 Generated CSS: ${CSS_SIZE} bytes"
        
        # Check for source map
        if [ -f "$MAP_OUTPUT" ]; then
            echo "🗺️ Source map: $MAP_OUTPUT"
        fi
    fi
    
    # Additional analysis
    echo ""
    echo "🔍 SCSS Analysis:"
    
    # Count SCSS features used
    if grep -q '@import\|@use' "$FILE_PATH" 2>/dev/null; then
        IMPORT_COUNT=$(grep -c '@import\|@use' "$FILE_PATH" 2>/dev/null || echo 0)
        echo "  • Imports/Uses: $IMPORT_COUNT"
    fi
    
    if grep -q '@mixin' "$FILE_PATH" 2>/dev/null; then
        MIXIN_COUNT=$(grep -c '@mixin' "$FILE_PATH" 2>/dev/null || echo 0)
        echo "  • Mixins defined: $MIXIN_COUNT"
    fi
    
    if grep -q '@include' "$FILE_PATH" 2>/dev/null; then
        INCLUDE_COUNT=$(grep -c '@include' "$FILE_PATH" 2>/dev/null || echo 0)
        echo "  • Mixin includes: $INCLUDE_COUNT"
    fi
    
    if grep -q '\$[a-zA-Z]' "$FILE_PATH" 2>/dev/null; then
        echo "  • 💡 Variables detected - using SCSS features"
    fi
    
    if grep -q '&' "$FILE_PATH" 2>/dev/null; then
        echo "  • 💡 Nested selectors detected"
    fi
    
    # Check for common issues
    echo ""
    echo "🔍 Code Quality Check:"
    
    if grep -q '!important' "$FILE_PATH" 2>/dev/null; then
        IMPORTANT_COUNT=$(grep -c '!important' "$FILE_PATH" 2>/dev/null || echo 0)
        echo "  • ⚠️ !important usage: $IMPORTANT_COUNT (consider refactoring)"
    fi
    
    if grep -q 'color: #[0-9a-fA-F]\{3,6\}' "$FILE_PATH" 2>/dev/null; then
        echo "  • 💡 Consider using CSS custom properties for colors"
    fi
    
    echo ""
    echo "💡 SCSS Development Tips:"
    echo "  • Use @use instead of @import for better performance"
    echo "  • Organize styles with partials (_filename.scss)"
    echo "  • Use mixins for reusable style patterns"
    echo "  • Leverage SCSS variables for consistent theming"
    echo "  • Use nested selectors sparingly (max 3-4 levels)"
    
    echo ""
    echo "🎯 SCSS compilation complete!"
    
else
    echo "ℹ️ File is not a SCSS/Sass file: $FILE_PATH"
fi

exit 0
Full copyable content
{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/scss-auto-compiler.sh",
      "matchers": [
        "write",
        "edit"
      ]
    }
  }
}

About this resource

Features

  • Automatic SCSS/Sass compilation to CSS including SCSS compilation integration (Dart Sass command execution with SCSS/Sass file compilation, SCSS syntax support with SCSS file format, Sass syntax support with indented Sass syntax, CSS output generation with compiled CSS files), compilation optimization (compilation performance with fast compilation, compilation caching with incremental compilation, compilation optimization with optimized output, compilation efficiency with efficient processing), compilation validation (SCSS syntax validation with syntax checking, SCSS error detection with error reporting, SCSS warning detection with warning messages, SCSS dependency validation with import validation), and compilation reporting (compilation success reporting with success messages, compilation error reporting with detailed errors, compilation statistics with build statistics, compilation performance with performance metrics)
  • Source map generation for debugging including source map generation (source map file generation with .css.map files, source map content embedding with source text inclusion, source map URL generation with sourceMappingURL comments, source map debugging with browser debugging support), source map configuration (source map configuration with sourceMap option, source map include sources with sourceMapIncludeSources, source map path configuration with map path settings, source map format with source map format), source map integration (source map browser integration with DevTools support, source map debugging with source debugging, source map navigation with source navigation, source map accuracy with accurate mappings), and source map reporting (source map generation reporting with generation status, source map file reporting with file paths, source map size reporting with map sizes, source map validation with map validation)
  • Support for both SCSS and Sass syntax including SCSS syntax support (SCSS syntax parsing with SCSS parser, SCSS syntax validation with syntax checking, SCSS syntax features with SCSS features, SCSS syntax compatibility with SCSS compatibility), Sass syntax support (Sass indented syntax parsing with indented parser, Sass syntax validation with syntax checking, Sass syntax features with Sass features, Sass syntax compatibility with Sass compatibility), syntax detection (automatic syntax detection with file extension detection, syntax switching with syntax selection, syntax validation with syntax checking, syntax reporting with syntax reporting), and syntax reporting (SCSS syntax reporting with SCSS status, Sass syntax reporting with Sass status, syntax detection reporting with detection status, syntax compatibility reporting with compatibility status)
  • Customizable output formatting including output formatting (CSS output formatting with formatted CSS, CSS output style with style options, CSS output compression with compressed output, CSS output minification with minified CSS), formatting options (output style configuration with style settings, output compression configuration with compression settings, output indentation configuration with indentation settings, output line breaks configuration with line break settings), formatting customization (custom formatting rules with formatting configuration, formatting presets with style presets, formatting optimization with output optimization, formatting consistency with consistent formatting), and formatting reporting (formatting status reporting with formatting status, formatting options reporting with option status, formatting statistics with formatting metrics, formatting validation with formatting validation)
  • Error reporting and validation including error detection (SCSS compilation error detection with error identification, SCSS syntax error detection with syntax errors, SCSS import error detection with import errors, SCSS dependency error detection with dependency errors), error reporting (compilation error reporting with detailed errors, error message formatting with formatted messages, error location reporting with error locations, error context reporting with error context), error validation (error validation with error checking, error severity assessment with severity levels, error categorization with error types, error resolution suggestions with resolution tips), and error handling (error handling with graceful handling, error recovery with recovery strategies, error logging with error logs, error notification with error notifications)
  • Watch mode compatibility including watch mode integration (file watching with file system watching, change detection with change monitoring, automatic compilation with auto-compilation, watch mode compatibility with watch tools), watch mode optimization (incremental compilation with incremental builds, change detection optimization with optimized detection, compilation performance with performance optimization, watch mode efficiency with efficient watching), watch mode configuration (watch mode settings with watch configuration, watch patterns with file patterns, watch exclusions with exclusion patterns, watch options with watch options), and watch mode reporting (watch mode status reporting with watch status, watch mode statistics with watch metrics, watch mode performance with performance metrics, watch mode validation with watch validation)
  • SCSS analysis and code quality checking including SCSS analysis (SCSS feature detection with feature analysis, SCSS import analysis with import tracking, SCSS mixin analysis with mixin tracking, SCSS variable analysis with variable tracking), code quality checks (code quality analysis with quality metrics, code quality recommendations with quality suggestions, code quality warnings with quality warnings, code quality best practices with best practices), SCSS statistics (SCSS file statistics with file metrics, SCSS feature statistics with feature counts, SCSS complexity analysis with complexity metrics, SCSS dependency analysis with dependency tracking), and SCSS reporting (SCSS analysis reporting with analysis results, SCSS quality reporting with quality metrics, SCSS statistics reporting with statistics, SCSS recommendations with improvement suggestions)
  • Development workflow integration including continuous compilation (real-time SCSS compilation on file changes, immediate CSS generation on SCSS updates, automatic compilation on file modifications, seamless SCSS integration with development workflow), workflow automation (automated SCSS compilation without manual intervention, compilation automation with automatic compilation, CSS generation automation with automatic generation), and workflow optimization (SCSS change detection with change tracking, incremental compilation with optimization, SCSS code consistency maintenance with consistency checks)

Use Cases

  • Compile SCSS files to CSS automatically automatically detecting SCSS file changes, running Dart Sass compilation, and generating CSS output files
  • Generate source maps for easier debugging automatically generating .css.map files, embedding source text in source maps, and enabling browser DevTools debugging
  • Maintain CSS output in sync with SCSS changes automatically compiling SCSS on file modifications, detecting changes, and updating CSS files
  • Streamline SCSS development workflow automatically integrating SCSS compilation into development workflows without manual compilation steps
  • Validate SCSS syntax and catch errors automatically detecting SCSS syntax errors, reporting compilation errors, and providing error context
  • Development workflow integration seamlessly integrating SCSS compilation into development workflows without manual compilation checking or CSS generation

Installation

  1. Create hooks directory: mkdir -p .claude/hooks
  2. Create hook file: touch .claude/hooks/scss-auto-compiler.sh
  3. Make executable: chmod +x .claude/hooks/scss-auto-compiler.sh
  4. Add configuration from Hook Configuration section above to .claude/settings.json or ~/.claude/settings.json
  5. Alternative: Use the interactive /hooks command in Claude Code

Config paths

  • Local (not committed): .claude/settings.local.json
  • User settings (global): ~/.claude/settings.json
  • Project-wide (committed): .claude/settings.json

Requirements

  • Claude Code CLI installed
  • Project directory initialized
  • Bash shell available
  • Dart Sass installed (npm install -g sass or npm install sass, recommended)
  • Node.js and npm (for npx sass fallback, optional)
  • jq (optional, for JSON parsing)

Hook Configuration

{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/scss-auto-compiler.sh",
      "matchers": ["write", "edit"]
    }
  }
}

Hook Script

#!/bin/bash

# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')

if [ -z "$FILE_PATH" ]; then
  exit 0
fi

# Check if this is a SCSS or Sass file
if [[ "$FILE_PATH" == *.scss ]] || [[ "$FILE_PATH" == *.sass ]]; then
    echo "🎨 SCSS Auto-Compiler - Processing stylesheet..."
    echo "📄 File: $FILE_PATH"

    # Check if file exists
    if [ ! -f "$FILE_PATH" ]; then
        echo "⚠️ File not found: $FILE_PATH"
        exit 1
    fi

    # Determine output CSS file path
    if [[ "$FILE_PATH" == *.scss ]]; then
        CSS_OUTPUT="${FILE_PATH%.scss}.css"
        MAP_OUTPUT="${FILE_PATH%.scss}.css.map"
    else  # .sass file
        CSS_OUTPUT="${FILE_PATH%.sass}.css"
        MAP_OUTPUT="${FILE_PATH%.sass}.css.map"
    fi

    echo "📁 Output: $CSS_OUTPUT"

    # Check if Sass compiler is available
    if command -v sass >/dev/null 2>&1; then
        SASS_CMD="sass"
    elif command -v npx >/dev/null 2>&1 && npx sass --version >/dev/null 2>&1; then
        SASS_CMD="npx sass"
    elif command -v node-sass >/dev/null 2>&1; then
        SASS_CMD="node-sass"
        echo "ℹ️ Using node-sass (consider upgrading to Dart Sass)"
    else
        echo "⚠️ No Sass compiler found"
        echo "💡 Install options:"
        echo "  • npm install -g sass (Dart Sass - recommended)"
        echo "  • npm install sass (project-local)"
        echo "  • brew install sass/sass/sass (macOS)"
        exit 1
    fi

    echo "🔧 Compiling with $SASS_CMD..."

    # Compile SCSS/Sass to CSS with source maps
    if [[ "$SASS_CMD" == "node-sass" ]]; then
        # node-sass syntax
        if node-sass "$FILE_PATH" "$CSS_OUTPUT" --source-map true --source-map-contents; then
            echo "✅ SCSS compiled successfully with node-sass"
        else
            echo "❌ SCSS compilation failed"
            exit 1
        fi
    else
        # Dart Sass syntax
        if $SASS_CMD "$FILE_PATH" "$CSS_OUTPUT" --source-map; then
            echo "✅ SCSS compiled successfully"
        else
            echo "❌ SCSS compilation failed"
            exit 1
        fi
    fi

    # Check output file size
    if [ -f "$CSS_OUTPUT" ]; then
        CSS_SIZE=$(stat -f%z "$CSS_OUTPUT" 2>/dev/null || stat -c%s "$CSS_OUTPUT" 2>/dev/null || echo "unknown")
        echo "📊 Generated CSS: ${CSS_SIZE} bytes"

        # Check for source map
        if [ -f "$MAP_OUTPUT" ]; then
            echo "🗺️ Source map: $MAP_OUTPUT"
        fi
    fi

    # Additional analysis
    echo ""
    echo "🔍 SCSS Analysis:"

    # Count SCSS features used
    if grep -q '@import\|@use' "$FILE_PATH" 2>/dev/null; then
        IMPORT_COUNT=$(grep -c '@import\|@use' "$FILE_PATH" 2>/dev/null || echo 0)
        echo "  • Imports/Uses: $IMPORT_COUNT"
    fi

    if grep -q '@mixin' "$FILE_PATH" 2>/dev/null; then
        MIXIN_COUNT=$(grep -c '@mixin' "$FILE_PATH" 2>/dev/null || echo 0)
        echo "  • Mixins defined: $MIXIN_COUNT"
    fi

    if grep -q '@include' "$FILE_PATH" 2>/dev/null; then
        INCLUDE_COUNT=$(grep -c '@include' "$FILE_PATH" 2>/dev/null || echo 0)
        echo "  • Mixin includes: $INCLUDE_COUNT"
    fi

    if grep -q '\$[a-zA-Z]' "$FILE_PATH" 2>/dev/null; then
        echo "  • 💡 Variables detected - using SCSS features"
    fi

    if grep -q '&' "$FILE_PATH" 2>/dev/null; then
        echo "  • 💡 Nested selectors detected"
    fi

    # Check for common issues
    echo ""
    echo "🔍 Code Quality Check:"

    if grep -q '!important' "$FILE_PATH" 2>/dev/null; then
        IMPORTANT_COUNT=$(grep -c '!important' "$FILE_PATH" 2>/dev/null || echo 0)
        echo "  • ⚠️ !important usage: $IMPORTANT_COUNT (consider refactoring)"
    fi

    if grep -q 'color: #[0-9a-fA-F]\{3,6\}' "$FILE_PATH" 2>/dev/null; then
        echo "  • 💡 Consider using CSS custom properties for colors"
    fi

    echo ""
    echo "💡 SCSS Development Tips:"
    echo "  • Use @use instead of @import for better performance"
    echo "  • Organize styles with partials (_filename.scss)"
    echo "  • Use mixins for reusable style patterns"
    echo "  • Leverage SCSS variables for consistent theming"
    echo "  • Use nested selectors sparingly (max 3-4 levels)"

    echo ""
    echo "🎯 SCSS compilation complete!"

else
    echo "ℹ️ File is not a SCSS/Sass file: $FILE_PATH"
fi

exit 0

Examples

SCSS Auto Compiler Hook Script

Complete hook script that compiles SCSS/Sass files to CSS with source maps

#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
  exit 0
fi
if [[ "$FILE_PATH" == *.scss ]] || [[ "$FILE_PATH" == *.sass ]]; then
  if command -v sass >/dev/null 2>&1 || (command -v npx >/dev/null 2>&1 && npx sass --version >/dev/null 2>&1); then
    if [[ "$FILE_PATH" == *.scss ]]; then
      CSS_OUTPUT="${FILE_PATH%.scss}.css"
    else
      CSS_OUTPUT="${FILE_PATH%.sass}.css"
    fi
    SASS_CMD="sass"
    if ! command -v sass >/dev/null 2>&1; then
      SASS_CMD="npx sass"
    fi
    echo "🎨 Compiling SCSS..."
    if $SASS_CMD "$FILE_PATH" "$CSS_OUTPUT" --source-map; then
      echo "✅ SCSS compiled successfully"
    else
      echo "❌ SCSS compilation failed"
      exit 1
    fi
  fi
fi
exit 0

Hook Configuration

Complete hook configuration for .claude/settings.json to enable SCSS auto compilation

{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/scss-auto-compiler.sh",
      "matchers": ["write", "edit"]
    }
  }
}

SCSS Compilation with Partial Detection

Enhanced hook script that skips SCSS partials (files starting with _) and compiles with compressed output

#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [[ "$FILE_PATH" == *.scss ]]; then
  if [[ "$(basename "$FILE_PATH")" == _* ]]; then
    echo "ℹ️ Skipping partial: $FILE_PATH"
    exit 0
  fi
  CSS_OUTPUT="${FILE_PATH%.scss}.css"
  if command -v sass >/dev/null 2>&1; then
    sass "$FILE_PATH" "$CSS_OUTPUT" --source-map --style=compressed
  elif command -v npx >/dev/null 2>&1; then
    npx sass "$FILE_PATH" "$CSS_OUTPUT" --source-map --style=compressed
  fi
fi
exit 0

SCSS Compilation with Source Map Details

Enhanced hook script with source map include sources and source map size reporting

#!/bin/bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [[ "$FILE_PATH" == *.scss ]]; then
  CSS_OUTPUT="${FILE_PATH%.scss}.css"
  MAP_OUTPUT="${FILE_PATH%.scss}.css.map"
  if command -v sass >/dev/null 2>&1; then
    sass "$FILE_PATH" "$CSS_OUTPUT" --source-map --source-map-include-sources --style=expanded
    if [ -f "$MAP_OUTPUT" ]; then
      MAP_SIZE=$(stat -f%z "$MAP_OUTPUT" 2>/dev/null || stat -c%s "$MAP_OUTPUT" 2>/dev/null || echo "unknown")
      echo "🗺️ Source map: $MAP_OUTPUT (${MAP_SIZE} bytes)"
    fi
  fi
fi
exit 0

Sass Configuration Example

Example sass configuration for SCSS compilation options

{
  "sass": {
    "outputStyle": "expanded",
    "sourceMap": true,
    "sourceMapIncludeSources": true,
    "loadPaths": ["node_modules", "src/styles"]
  }
}

Troubleshooting

Compilation fails with 'sass command not found'

Install Dart Sass globally with npm install -g sass or locally npm install sass, then restart terminal. For project-specific, hook uses npx sass which auto-detects local installations. Verify installation with sass --version. Check PATH environment variable.

Source maps not generated in output directory

Ensure write permissions on output directory. Hook generates maps automatically: sass "$FILE_PATH" "$CSS_OUTPUT" --source-map. Check if MAP_OUTPUT path is writable and not gitignored. Verify source map generation with --source-map-include-sources option. Test with various output directory configurations.

Hook compiles partials creating unwanted CSS

Add early exit for partials: if [[ "$(basename "$FILE_PATH")" == _* ]]; then exit 0; fi before compilation. SCSS partials (prefixed with _) shouldn't compile to separate CSS files. Verify partial detection. Test with various partial naming conventions.

node-sass deprecated warnings appear in output

Migrate to Dart Sass: uninstall npm uninstall node-sass, install npm install sass. Hook automatically prefers Dart Sass over node-sass when both are available and shows migration notice. Verify Dart Sass installation. Test with various Sass compiler configurations.

Cannot parse @import vs @use distinction

Hook uses regex grep -q '@import\|@use' to detect both. For separate counts, use: IMPORT=$(grep -c '@import' ...) and USE=$(grep -c '@use' ...) to distinguish modern @use from legacy @import. Verify regex patterns. Test with various SCSS import patterns.

SCSS compilation is slow on large projects

Use incremental compilation with Dart Sass. Consider using --watch mode for development. Optimize SCSS imports and use @use instead of @import. Use loadPaths for faster module resolution. Verify compilation settings. Test with various project sizes.

Source maps point to wrong file locations

Ensure source map paths are relative to CSS output location. Use --source-map-embed for embedded source maps. Verify source map configuration. Check file path resolution. Test with various source map configurations.

Compiled CSS has incorrect formatting or style

Configure output style with --style=expanded (default), --style=compressed, or --style=compact. Use sass configuration file for consistent formatting. Verify style options. Test with various output style configurations.

Source citations

Add this badge to your README

Show that SCSS Auto Compiler - Hooks is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/hooks/scss-auto-compiler.svg)](https://heyclau.de/entry/hooks/scss-auto-compiler)

How it compares

SCSS Auto Compiler - Hooks side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

Field

Automatically compiles SCSS/Sass files to CSS when they are modified.

Open dossier

Automatically compiles and validates Svelte components when they are modified.

Open dossier

Automatically formats code files after Claude writes or edits them using industry-standard formatters including Prettier 3.6.2+ (JavaScript/TypeScript/Web), Black or Ruff (Python), gofmt (Go), and rustfmt (Rust).

Open dossier

Automatically creates timestamped backups of files before modification to prevent data loss. This hook runs before file editing operations (Edit, Write, Multiedit) and creates versioned backups in a centralized .backups directory with ISO 8601-compliant timestamps including nanoseconds for collision prevention.

Open dossier
Next steps
Trust
Review statusReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewed
Package trustPackage not verifiedPackage not verifiedPackage not verifiedPackage not verified
Source provenanceSource-backedSource-backedSource-backedSource-backed
Submitter
Install riskReview firstReview firstReview firstReview first
Notes Safety Privacy Safety Privacy Safety Privacy Safety Privacy
Brand
Categoryhookshookshookshooks
Sourcesource-backedsource-backedsource-backedsource-backed
AuthorJSONboredJSONboredJSONboredJSONbored
Added2025-09-192025-09-192025-09-192025-09-19
Platforms
Claude Code
Claude Code
Claude Code
Claude Code
Source repo
Safety notesRuns automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.Runs automatically after write/edit tool use for .svelte files and may invoke npx svelte-check inside the current project. Uses the local project toolchain and dependencies, so validation can be slow or fail when Svelte dependencies are missing.Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.
Privacy notesReceives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.Reads modified .svelte components, package.json, svelte.config.js, and vite.config.js to infer framework, component, accessibility, and performance signals. Prints component statistics and validation output to the local Claude Code hook output stream.Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.
Prerequisites— none listed— none listed— none listed— none listed
Install
mkdir -p .claude/hooks && touch .claude/hooks/scss-auto-compiler.sh && chmod +x .claude/hooks/scss-auto-compiler.sh
mkdir -p .claude/hooks && touch .claude/hooks/svelte-component-compiler.sh && chmod +x .claude/hooks/svelte-component-compiler.sh
mkdir -p .claude/hooks && touch .claude/hooks/auto-code-formatter-hook.sh && chmod +x .claude/hooks/auto-code-formatter-hook.sh
mkdir -p .claude/hooks && touch .claude/hooks/auto-save-backup.sh && chmod +x .claude/hooks/auto-save-backup.sh
Config
{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/scss-auto-compiler.sh",
      "matchers": [
        "write",
        "edit"
      ]
    }
  }
}
{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/svelte-component-compiler.sh",
      "matchers": [
        "write",
        "edit"
      ]
    }
  }
}
{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/auto-code-formatter-hook.sh",
      "matchers": [
        "write",
        "edit",
        "multiedit"
      ]
    }
  }
}
{
  "hooks": {
    "preToolUse": {
      "script": "./.claude/hooks/auto-save-backup.sh",
      "matchers": [
        "edit",
        "write",
        "multiedit"
      ]
    }
  }
}
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed
Open 4 picks in the interactive comparison tool

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.