A simple command-line tool built in Go to help review source code using AI.
The tool reads a code file, generates a prompt based on the selected command, and sends it to an AI model for analysis.
Currently supported commands:
Analyze a source file and get:
- Time complexity
- Space complexity
- General explanation
- Potential bottlenecks
cphelp analyze solution.cppReview a source file and identify:
- Possible bugs
- Runtime issues
- Logic errors
- Edge cases
cphelp debug solution.cppGet suggestions for improving code quality, including:
- Readability
- Performance
- Maintainability
- Best practices
cphelp improve solution.cppcp_help_cli/
├── cmd/
│ ├── analyze.go
│ ├── debug.go
│ ├── improve.go
│ └── root.go
│
├── internal/
│ ├── ai/
│ │ ├── client.go
│ │ ├── config.go
│ │ └── prompts.go
│ │
│ ├── output/
│ │ └── printer.go
│ │
│ └── parser/
│ └── file.go
│
├── .env
├── .gitignore
├── main.go
├── go.mod
└── go.sum
Clone the repository:
git clone https://github.com/Sri-Varshith/cp_help_cli.git
cd cp_help_cliInstall dependencies:
go mod tidyCreate a .env file:
OPENAI_API_KEY=your_api_key
OPENAI_MODEL=gpt-5Run:
go run . analyze sample.cppcphelp analyze solution.cpp
cphelp debug solution.cpp
cphelp improve solution.cpp- Go
- Cobra CLI
- OpenAI API
- godotenv
Some ideas planned for future versions:
- Add an
explaincommand for code walkthroughs - JSON output support
- Support for analyzing entire directories
- Better formatting of AI responses
- Generate test cases from source code
- Generate explanations for competitive programming solutions
- Direct Codeforces integration
- Submit solutions directly to Codeforces
- Fetch and display Codeforces problem statements
- Analyze accepted Codeforces submissions
- Store previous analyses locally
- Multi-language support (C++, Python, Java, Go)
This is a learning project built to explore:
- Go CLI development
- Working with external APIs
- Prompt generation
- Code analysis workflows
The project is still evolving and new features may be added over time.