Skip to content

Support using templates in skip: run fields #1310

@neefrehman

Description

@neefrehman

Description

I've noticed that templated scripts cannot be run when passed to the skip field.

templates:
  skip_slow_hooks: '[ "$CLAUDECODE" != "1" ];'

pre-commit:
  parallel: true
  jobs:
    - name: "Typecheck"                                                                                                      
      skip:                                                                                                                  
        - run: '{skip_slow_hooks}' # doesn't work                                                                             
      run: 'uv run npx pyright --threads 4 {staged_files}'
templates:
  skip_slow_hooks: '[ "$CLAUDECODE" != "1" ]; then exit 0; fi &&'

pre-commit:
  parallel: true
  jobs:
    - name: "Typecheck"                                                                                                                                                                             
      run: '{skip_slow_hooks} uv run npx pyright --threads 4 {staged_files}' # works

What problem it is solving?

As can be seen, I'm trying to implement an easily overridable config where Claude code commit will trigger more extensive hooks, and also any user who wants to opt in can do so via their local config file. While skip is more verbose, I think it is easier to reason about than manually gating commands via early exits. skip also allows you to skip a whole group at once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestA new lefthook feature description

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions