CLI tool for code analysis and generation using DeepSeek API
npm install deepseek-codebash
npm install -g deepseek-code
`
Or for development:
`bash
git clone https://github.com/KolyanCat128/deepseek-code.git
cd deepseek-code
npm install
npm run build
npm start
`
Setup
First, configure your DeepSeek API key:
`bash
deepseek config sk-your-api-key-here
`
Optionally specify a model:
`bash
deepseek config sk-your-api-key-here --model deepseek-r1
`
Available models:
- deepseek-r1 (Default) - Best for reasoning and analysis
- deepseek-coder - Optimized for code generation
- deepseek-chat - General purpose chat model
Usage
$3
Analyze a file for bugs, security issues, and quality problems:
`bash
deepseek analyze ./example.js
`
Output includes:
- Quality score (0-100)
- Identified issues with severity levels
- Suggestions for improvement
- Summary analysis
$3
Generate code based on a description:
`bash
deepseek generate "Create a function to fetch user data from API" \
--language javascript \
--output ./api.js
`
Options:
- --language, -l - Programming language (default: javascript)
- --output, -o - Save generated code to file
- --context, -c - Additional context for generation
Supported languages:
- javascript, typescript, python, java, cpp, c, rust, go, php, ruby, csharp, swift, kotlin, jsx, tsx
$3
Get detailed explanation of code:
`bash
deepseek explain ./complex-function.ts
`
Output includes:
- Summary of what the code does
- Detailed explanation of key parts
- Complexity analysis
- Key points to understand
$3
Improve code quality and readability:
`bash
deepseek refactor ./old-code.js \
--output ./refactored-code.js \
--goals "improve performance and readability"
`
Options:
- --output, -o - Save refactored code to file
- --goals, -g - Specific refactoring goals
Configuration
Configuration is stored in ~/.deepseek-code/config.json
You can modify:
- API key
- Model selection
- Max tokens (default: 4096)
- Temperature (default: 0.7, range: 0-1)
API Key
Get your API key from DeepSeek API Console
Important: Never commit your API key to version control. Use environment variables or .env files.
Examples
$3
`bash
deepseek analyze ./src/utils/helpers.ts
`
$3
`bash
deepseek generate "Create a decorator for memoization" \
--language python \
--output ./memoize.py
`
$3
`bash
deepseek explain ./algorithms/quicksort.js
`
$3
`bash
deepseek refactor ./legacy.js \
--goals "convert to ES6+, add error handling, improve performance" \
--output ./modern.js
`
Environment Variables
- DEBUG=1 - Enable debug logging
- HOME - Used to locate config directory (if not using Windows)
Troubleshooting
$3
Run: deepseek config sk-your-api-key
$3
Check that your API key is correct and has valid credits
$3
Wait a moment and try again, or upgrade your API plan
$3
Check your internet connection and API endpoint
Development
`bash
Build TypeScript
npm run build
Run in development mode
npm run dev
Run tests
npm run test
Build and watch
npx tsc --watch
`
Project Structure
`
src/
āāā index.ts # Main CLI entry point
āāā config.ts # Configuration management
āāā types.ts # TypeScript interfaces
āāā commands/
ā āāā analyze.ts # Code analysis command
ā āāā generate.ts # Code generation command
ā āāā explain.ts # Code explanation command
ā āāā refactor.ts # Code refactoring command
āāā utils/
āāā deepseek-client.ts # API client
āāā file-handler.ts # File operations
āāā logger.ts # Logging utilities
``