Creating PRs with the Dev Agent
How to use the Dev Agent to automatically create pull requests — prerequisites, commands, examples, and tips for getting the best results.
Creating PRs with the Dev Agent
The Dev Agent reads your codebase, generates code changes using Claude, and opens pull requests automatically. This guide covers how to use it effectively.
Estimated time: 5 minutes to learn, then seconds per PR
Prerequisites
Before using the Dev Agent to create PRs, ensure:
GITHUB_TOKENis configured withreposcope (required for reading code, creating branches, and opening PRs)ANTHROPIC_API_KEYis configured (required for Claude code generation)- A repository is linked via
@codespar link owner/repo
Verify Setup
You should see a linked project with an active Project Agent. If no project is linked, follow the Configure a Project guide first.
Commands
Two commands trigger the Dev Agent to create PRs:
@codespar instruct <task>
For new features, additions, and general coding tasks:
@codespar fix <issue>
For bug fixes and corrections:
Both commands follow the same flow internally — the distinction is semantic, helping the agent understand whether you want new code or a fix to existing code.
How It Works
When you send a command, the Dev Agent executes this flow:
For a deeper technical explanation, see the Dev Agent documentation.
Examples
Example 1: Add an Endpoint
Command:
Agent Response:
What the PR contains:
The Dev Agent creates a new src/routes/health.ts file with a health check handler and modifies src/routes/index.ts to register the new route. The PR description includes the list of changes and a note that it was generated by CodeSpar.
Example 2: Fix a Bug
Command:
Agent Response:
Example 3: Refactor
Command:
Agent Response:
Response Format
The Dev Agent always responds with:
| Field | Description |
|---|---|
| Branch | The codespar/<taskId> branch where changes were committed |
| Files changed | List of files with action (new, modified, deleted) |
| PR URL | Direct link to the pull request on GitHub |
| Summary | Brief description of what was changed and why |
After the PR is Created
Review the Code
Always review the generated PR before merging. The Dev Agent produces good code but is not infallible.
Automated Review
You can ask the Review Agent to analyze the PR:
The Review Agent will:
- Fetch the PR diff
- Classify the risk level (low, medium, high)
- Provide specific code review comments
- Suggest improvements
CI Checks
If your repository has CI configured (GitHub Actions, etc.), the PR will trigger your normal CI pipeline. The CodeSpar webhook integration will notify you of the result.
Iterate
If the PR needs changes, you can send another instruction:
Or fix specific issues:
Tips for Best Results
Be Specific About Location
Instead of:
Be specific:
Mention File Paths
The Dev Agent's code search works well, but explicitly mentioning file paths ensures it reads the right files:
Reference Existing Patterns
If your codebase has established patterns, reference them:
Keep Tasks Focused
One task = one well-defined change. Instead of:
Break it into three commands:
Specify the Framework
If the agent needs to know framework specifics:
Limitations
| Limitation | Detail |
|---|---|
| 5 files maximum | The agent reads at most 5 files for context |
| 20 KB per file | Large files (generated code, bundles) are skipped |
| 4,000 output tokens | Claude's response is capped, limiting very large changes |
| No binary files | Cannot generate images, compiled assets, etc. |
| Single repo | Each task operates on one repository |
For tasks that exceed these limits, break the work into smaller, focused tasks.
Merging PRs from Chat
After reviewing a pull request (either manually or via the Review Agent), you can merge it directly from your messaging channel:
This uses the repository's default merge strategy. You can also specify a merge strategy explicitly:
Example flow:
The merge command checks that the PR exists, that CI checks have passed (if configured), and that you have the required permissions before proceeding.
Next Steps
- Dev Agent -- technical deep dive into the Dev Agent
- Review Pull Requests -- automated PR review
- Approval System -- configure approval workflows
- Command Reference -- full list of all commands