Keep your crystal clean crystal-shard lint lint-staged
0.1.0 Latest release released


Master build status


walter is a command line tool that aims to keep your crystal clean, simplifying the routine checks on staged files that are ready to be committed and help you maintain a healthy and clean codebase.


From a consistency perspective, there are plenty of tools that support us on our never-ending pursue of code-cleanliness. Linters, static code analyzers, code formatters… Great! However, more often than not, our git history ends up cluttered with ~~angry~~ commits fixing violations detected by those tools.

One way to avoid these commits from getting into our history is to run your linters and code formatters before committing your changes. But running these tools against the entire project every time you're committing something can be slow and lead to unexpected or irrelevant results.

This tool allows you to specify a series of commands to run on staged files that match a given pattern.


Add the following entry to your shard.yml on the development_dependencies section and run shards install.

  github: gtramontina/
  version: <current-version>


Next, create a .walter.yml at the root of your project with the following content:

expression: \.cr$
  - crystal tool format
  - git add


Executing bin/walter now would run crystal tool format and git add on your staged files that match the \.cr$ regular expression. For example, if you have file1.txt, and, water will run, in this order:

  1. crystal tool format
  2. git add
  3. crystal tool format
  4. git add

Notice that file1.txt was not referenced, as it doesn't match the \.cr$ regular expression.

Running the commands on each individual staged file was deliberate. The idea is that it would foster a small/atomic commit mindset.

More Examples

Here's a few more configuration examples for you to draw inspiration from:

expression: \.cr$
command: bin/ameba
expression: \.png$
  - pngcrush -ow
  - git add
  • All examples at once:
- expression:
    - \.cr$
    - bin/ameba
    - crystal tool format
    - git add

- expression:
    - \.png$
    - pngcrush -ow
    - git add


  • Although you can manually run bin/walter before every commit, this quickly becomes boring and quite often forgotten. You can leverage the precommit git hook. Take a look at It makes versioning your git hooks easier! Here's an example of a ghooks pre-commit hook (.githooks/pre-commit) configured to run bin/walter:
#!/usr/bin/env sh



Walter - Keeping your Crystal clean!

  walter (-c <config> | -C <config-file>)
  walter (-h | --help | -v | --version)

  -h --help                         Show this screen.
  -v --version                      Show version.
  -c --config=<config>              Rules configuration in YAML.
  -C --config-file=<config-file>    Rules configuration file in YAML [default: .walter.yml]

$ bin/walter --help

Design Decisions

  • Every interaction with the operating system is abstracted;
  • Methods have only one output (no exceptions or nils). If needed, use the Result class;
  • Favor composition over inheritance: augment behavior by decorating existing implementations;


Contributions of any kind are very welcome!


At the root of the project, you'll find a Makefile. This is meant to be the entry point for any build step during development. Running make help will yield you a list of existing phony targets:

make build
make clean
make format
make help
make install (default)
make lint
make test

$ make help

  github: gtramontina/
  version: ~> 0.1.0
License MIT
Crystal 0.27.0


Dependencies 4

  • crz 1.0.0
    {'github' => 'dhruvrajvanshi/crz', 'version' => '1.0.0'}
  • docopt
    {'github' => 'chenkovsky/'}
  • griffith 1.0.0
    {'github' => 'gtramontina/', 'version' => '1.0.0'}
  • spinner-frames 1.0.0
    {'github' => 'gtramontina/', 'version' => '1.0.0'}

Development Dependencies 4

  • ameba 0.8.1
    {'github' => 'veelenga/ameba', 'version' => '0.8.1'}
  • 0.1.0
    {'github' => 'gtramontina/', 'version' => '0.1.0'}
  • minitest 0.4.1
    {'github' => 'ysbaddaden/', 'version' => '0.4.1'}
  • 0.1.0
    {'github' => 'gtramontina/', 'version' => '0.1.0'}

Dependents 1

Last synced .
search fire star recently