Skip to main content

🔧 Pre-commit Hooks

Reusable pre-commit hooks for OpenSCAD projects.

Published on PyPI as kellerlab-pre-commit-hooks.

📌 What

Two hooks for OpenSCAD-based 3D printing projects:

Hook Description
flatten-validate Runs scadm flatten --all and fails if flattened files have uncommitted changes
optimize-images Resizes oversized JPEGs/PNGs, compresses them, and strips metadata (privacy)

🔧 Usage

Add to your .pre-commit-config.yaml:

- repo: https://github.com/kellerlabs/pre-commit-hooks
  rev: v0.1.0  # use latest tag
  hooks:
    - id: flatten-validate
    - id: optimize-images

flatten-validate

Flattens OpenSCAD files via scadm and validates that the output is committed. Reads flatten config from scadm.json automatically.

- id: flatten-validate
  # Override trigger pattern (default: always_run)
  always_run: false
  files: '^(scadm\.json|models/.*\.scad)'

Options:

Arg Default Description
--flatten-dir Read from scadm.json Override flatten output dirs (list of paths/globs)

optimize-images

Resizes JPEGs and PNGs exceeding max width, compresses them, and strips metadata. EXIF data (including GPS coordinates) is removed from JPEGs; text metadata chunks are removed from PNGs.

- id: optimize-images
  args: [--max-width=1920, --quality=85]

Options:

Arg Default Description
--max-width 1920 Maximum image width in pixels
--quality 85 JPEG compression quality (1-95, ignored for PNG)

Both hooks fail when files are modified, printing instructions to git add the changes. Re-run git commit after staging.

🏗️ Used In

🤝 Contributing

See CONTRIBUTING.md.

📜 License

MIT

Metadata

Release files for kellerlab-pre-commit-hooks 0.3.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kellerlab-pre-commit-hooks 0.3.13
File Size Uploaded
kellerlab_pre_commit_hooks-0.3.13.tar.gz 8.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kellerlab-pre-commit-hooks 0.3.13
File Interpreter ABI Platform
kellerlab_pre_commit_hooks-0.3.13-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / kellerlab_pre_commit_hooks-0.3.13.tar.gz

Download URL kellerlab_pre_commit_hooks-0.3.13.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
70d149d5ea1ccaca691d50e5639337d0c494e6fa9513cdbb4f50bdf0d278c4fa
BLAKE2b-256 checksum
How to use checksums
85d2c7cd07a579adae6b903c5faac3a1e1c6551d9b4fa926c6371ab997114bc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release files / kellerlab_pre_commit_hooks-0.3.13-py3-none-any.whl

Download URL kellerlab_pre_commit_hooks-0.3.13-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0849fcd8b15377a6eeaa4d6be978a61a14adf2aef90829455424f9d45765b488
BLAKE2b-256 checksum
How to use checksums
0f4ed73d7bf02b1f6a87fcf392e572c32b187fc801def86b48285112f52ec69b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 5, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.14

2 release files

This release

0.3.13 This release

2 release files

0.3.12

2 release files

0.3.11

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page