Instantly identify and fix problems in shell scripts with the power of ShellCheck and LLMs.
Access screencast directly here.
See example directory to see script contents before and after.
- ShellCheck should be installed and in your PATH.
- An active OpenAI API key.
brew install kkyr/tap/shellcheck-gptDownload the latest release and add the executable to your PATH.
go install github.com/kkyr/shellcheck-gptAdd your OpenAI API key to the environment:
export OPENAI_API_KEY=replace-with-your-api-keyRun shellcheck-gpt against a script:
shellcheck-gpt script.shThis will:
- Run shellcheck against
script.sh - Feed the contents of the script and the output of shellcheck into an OpenAI LLM and ask it to make corrections
- Write the LLM's output to stdout
Warning
The entire content of your script is sent in cleartext to OpenAI.
If you'd like to instead write the output back into the script, use the -w flag:
shellcheck-gpt -w script.shNote that this will ovewrite any contents already in the script.
By default, shellcheck-gpt uses the gpt-3.5-turbo model. You change model using the -m flag:
shellcheck-gpt -m gpt-4-turbo script.shSee available options and models using the --help flag:
shellcheck-gpt --helpContributions are welcome!
Areas for improvement:
- Use
shellcheck -f diffto apply fixes that can be automatically applied before calling into LLM. - Support more LLMs
- Add verbose flag to print LLM input/output

