shellcheck-gpt
Automatically correct script issues by feeding shellcheck analysis into an LLM.
Getting started
Prerequisites
- ShellCheck should be installed and in your $PATH.
- Go
- A valid OpenAI API key
Basic installation
shellcheck-gpt can be installed using the go install tool. Distribution methods that do not depend on Go are coming soon!
go install github.com/kkyr/shellcheck-gpt
Usage
Store your OpenAI API key into the environment:
export OPENAI_API_KEY=replace-with-your-key
Run shellcheck-gpt against a script:
shellcheck-gpt script.sh
This will:
- Run shellcheck against
script.sh
- Feed the script and the output of shellcheck into an LLM and ask it to make the corrections
- Write the LLM's output onto stdout
If you'd like to write the output back into the script, use the -w flag:
shellcheck-gpt -w script.sh
Configuration
By default, shellcheck-gpt uses the gpt-3.5-turbo model. You can modify this to another model using the -m flag:
shellcheck-gpt -m gpt-4-turbo script.sh
See available options and models using the --help flag:
shellcheck-gpt --help
Contributing
Contributions are welcome!