AI-powered CLI tool to format and explain code blocks using Groq API
Project description
QuickFix (qfix)
A powerful command-line tool that uses AI (Groq's Llama models) to format and explain specific blocks of code within your files. It allows you to target specific lines, receive intelligent improvements without logic changes, and optionally write the changes back to your file in proper format.
Features
- Targeted Formatting: Select specific line ranges to process, leaving the rest of the file untouched.
- AI-Powered: Uses Groq's fast Llama models for intelligent code formatting.
- Strict Formatting: Enforces best practices (indentation, spacing) without altering the underlying logic.
- Detailed Explanations: Provides a Markdown-formatted explanation of why changes were made.
- Write-Back Support: Apply the improved code directly to your file with the
--applyflag or interactive prompt. - Mock Mode: Works offline or without an API key (returns a mock response for testing).
Prerequisites
- Python 3.8+
- A Groq API Key (Get one free from Groq Console)
Installation
Option 1: Install from PyPI (Recommended)
pip install qfix-cli
Option 2: Install from GitHub
pip install git+https://github.com/Kunshika/QuickFix.git
Option 3: Install from Source
git clone https://github.com/Kunshika/QuickFix.git
cd QuickFix
pip install .
Configuration
-
Create a
.envfile in your project directory or home directory:touch .env -
Add your Groq API Key to
.env:GROQ_API_KEY=your_api_key_here
Alternatively, you can pass the key via the CLI argument
--api-key.
Usage
Run the tool using qfix with the target file and line range.
Basic Usage (View Only)
This will print the original code, the improved version, and the explanation to the console without modifying the file.
qfix path/to/file.py --start 10 --end 20
Apply Changes
To write the formatted code back to the file, use the --apply flag or answer "Yes" to the interactive prompt.
qfix path/to/file.py --start 10 --end 20 --apply
Command Line Arguments
| Argument | Description | Required |
|---|---|---|
file |
Path to the source file to process. | Yes |
--start |
Start line number (1-based). | Yes |
--end |
End line number (1-based). | Yes |
--apply |
Automatically apply changes to the file. | No |
--api-key |
Provide API key directly (overrides .env). |
No |
Example
Input File (example.py):
7 def complex_logic(a, b):
8 # This is a bad implementation
9 if a > b: return a - b
10 else: return
11 b - a
Command:
qfix example.py --start 7 --end 11
Output: The tool will display:
- Original Code: Syntax-highlighted view of lines 7-11.
- Improved Implementation: Properly formatted code (e.g., fixing the
else: returnline break). - Detailed Explanation: "Fixed indentation and line breaks for readability..."
Troubleshooting
- 429 Quota Exceeded: The free tier of Gemini API has rate limits. If you see this error, wait a minute and try again.
- Mock Explanation: If you see this, it means the tool couldn't access the API (missing key or network issue). Check your
.envfile.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qfix_cli-0.1.0.tar.gz.
File metadata
- Download URL: qfix_cli-0.1.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa052f20c2351374694dfc8c8f17e9e74d2cdda999bb0e0ae93e4f46a22b4763
|
|
| MD5 |
48ef6646910920f0d688f177870148f9
|
|
| BLAKE2b-256 |
b95e7a6be820ad09ab6e3a75c09ed81984ed532f2942a60153293b53d0849194
|
File details
Details for the file qfix_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: qfix_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a9389fc993b7b039ac3c9a2ba588173ec105ed435c472934d6fb1f6e365b189
|
|
| MD5 |
5afbb500784c6850f8fc06ed80d9b192
|
|
| BLAKE2b-256 |
a5ddb83aa77b36662dbcdd96f71d84376f74fa342067029939894dc9537513ef
|