Using CLI with AI Agents
Let AI coding agents use DeepSource CLI to read analysis data and act on it.
AI coding agents like Claude Code, Cursor, and similar tools can use DeepSource CLI to fetch code health data and act on it directly.
Setup
Install CLI
curl -fsSL https://cli.deepsource.com/install | sh
Authenticate
deepsource auth login
Once authenticated, any AI agent running in your terminal has access to the same CLI commands you do.
Workflow examples
Fetch and fix issues
Ask your agent to pull critical issues from the current branch and fix them:
deepsource issues --severity critical --output json
The agent gets back structured data with file paths, line numbers, issue descriptions, and suggested fixes. That's usually enough context to make targeted code changes.
Check metrics before and after changes
Have the agent check metrics for the current branch to understand the impact of its changes:
deepsource metrics --output json
Returns code health metrics like code coverage, documentation coverage, and overall code health scores for the current branch.
Review analysis runs
deepsource runs --output json
Returns the status of recent analysis runs, including any new issues introduced or resolved.
Check vulnerabilities
deepsource vulnerabilities --output json
Returns a list of known vulnerabilities in your dependencies along with severity levels and affected packages.
Tips
- Always use
--output json. AI agents work better with structured data than formatted tables. - Use
--repo gh/org/repoexplicitly if the agent's working directory isn't inside the repository. - Use
--commit <sha>to get results for a specific point in time rather than the latest analysis. - Use flags like
--severity,--analyzer, and--categoryto focus the agent on what matters.