Building env-doctor with GitHub Copilot CLI
Source: Dev.to
This submission for the GitHub Copilot CLI Challenge introduces env‑doctor, a CLI tool that automatically checks whether your local environment matches the requirements of a project.
Overview
When you clone a repository, you often spend valuable time figuring out missing Node versions, environment variables, or required services. env‑doctor scans common project files—package.json, Dockerfile, docker-compose.yml, README, CI configurations, and more—to extract the actual dependencies. It then validates your local setup and produces a clear checklist indicating what works and what needs attention.
Features
- Runtime version checks (Node.js, Python, Go, etc.)
- Package manager verification (npm, pip, go modules)
- Service detection (Docker, Redis, PostgreSQL, etc.)
- Environment variable validation
- Port availability testing
- Supports JSON output for CI pipelines
- Verbose mode with detailed explanations
- Colored output with emoji indicators for quick visual feedback
Usage
$ env-doctor --verbose
Sample Output
env-doctor - Analyzing project environment...
Runtime Versions:
✅ Node.js 18.17.0 (required: >=18.0.0)
✅ Docker running (v24.0.7)
❌ Python 3.8.10 (required: >=3.9.0)
Services:
❌ redis not found
✅ PostgreSQL accessible on port 5432
Environment Variables:
❌ DATABASE_URL environment variable not set
❌ JWT_SECRET environment variable not set
✅ NODE_ENV=development
📊 Results: 4/8 checks passed (4 failed)
❌ Environment needs attention
Next steps:
1. Update Python to >=3.9.0
2. Install and start redis
3. Set DATABASE_URL environment variable
4. Set JWT_SECRET environment variable
Example Project
A comprehensive example project is included in the repository to demonstrate all capabilities. It features a realistic full‑stack application with:
- Node.js, Python, and Go services
- Multiple databases (PostgreSQL, Redis)
- Complex Docker setup
- Numerous environment variables
Running env-doctor on this project yields 13/59 checks passing, showcasing how the tool handles intricate, real‑world scenarios.
You can clone the repository and try the demo script:
git clone https://github.com/env-doctor/env-doctor.git
cd env-doctor/example-project
./demo.sh
Development with GitHub Copilot CLI
Using the GitHub Copilot CLI dramatically accelerated development:
- File parsers for
package.json,Dockerfile,docker‑compose.yml, and CI configs were generated automatically. - Environment checking logic (runtime verification, Docker status, database connectivity, env‑var validation) was produced with comprehensive error handling and user‑friendly messages.
- User experience enhancements such as colored output, emoji status indicators, verbose mode, and JSON output were suggested and implemented without explicit prompts.
- Testing: Copilot created unit tests for individual components and an integration test that builds a temporary project structure to verify end‑to‑end functionality.
- Feature expansion: Adding Python support (parsers for
requirements.txtandpyproject.toml, version checks, pip availability) was accomplished in minutes.
The experience highlighted how AI tools can manage repetitive, mechanical aspects of programming while allowing the developer to focus on problem design and overall user experience.
Repository
The tool and example project are available at: