First Agent
Step-by-step tutorial to deploy your first CodeSpar agent, link a GitHub repository, and execute tasks from Slack.
Deploy Your First Agent
This tutorial walks you through deploying a CodeSpar Project Agent connected to Slack, linking it to a GitHub repository, and using it to execute tasks, review pull requests, and manage your project — all from Slack.
Prerequisites
Before starting, make sure you have:
- CodeSpar installed (Installation guide)
- A Slack workspace where you have permission to install apps
- A GitHub repository you want to link
- A GitHub personal access token with
reposcope (create one here) - Your Anthropic API key set in
.env
Step 1: Create a Slack App
- Go to api.slack.com/apps and click Create New App
- Choose From scratch, give it the name
CodeSpar, and select your workspace - Under OAuth & Permissions, add these Bot Token Scopes:
app_mentions:read— detect@codesparmentionschat:write— send messageschannels:history— read channel messagesgroups:history— read private channel messagesfiles:write— upload code snippets and diffs
- Under Event Subscriptions, enable events and subscribe to:
app_mention— triggers when someone mentions@codesparmessage.channels— monitors channel messages
- Install the app to your workspace
- Copy the Bot User OAuth Token (
xoxb-...) from the OAuth & Permissions page - Copy the Signing Secret from the Basic Information page
Step 2: Configure Environment Variables
Add your Slack credentials and GitHub token to .env:
Step 3: Start CodeSpar
You should see:
The Project Agent starts at L1 (Notify) by default — it monitors and alerts but never auto-executes actions.
Step 4: Verify the Connection
Invite the CodeSpar bot to a Slack channel, then type:
The agent responds with available commands:
Step 5: Link a Repository
Connect a GitHub repository to your Project Agent:
Replace owner/repo with your actual GitHub repository (e.g., acme/backend). The agent confirms:
Step 6: Check Project Status
Ask for the current state of your project:
The agent responds with a summary:
Step 7: Execute a Task
Give the agent a coding task using natural language:
The agent:
- Spawns an ephemeral Task Agent
- Clones the repo into a sandboxed Docker container
- Writes the code, runs existing tests
- Creates a branch and opens a pull request
- Reports back in Slack with a link to the PR
Step 8: Review a Pull Request
Ask the agent to review any open PR:
The agent spawns a Review Agent that analyzes the PR and responds with findings:
Step 9: List Open Pull Requests
See all open PRs on the linked repository:
The agent lists them with status:
Step 10: Explore Further
Now that you have a working agent, try these:
Adjust autonomy level
At L2 (Suggest), the agent proactively proposes actions when it detects issues — like a failing CI build — but still waits for your approval before acting.
Ask about a CI failure
Request a fix
Summary
In this tutorial you:
- Created a Slack app and connected it to CodeSpar
- Linked a GitHub repository to a Project Agent
- Checked project status from Slack
- Executed a coding task that produced a pull request
- Reviewed a pull request with automated analysis
- Listed open pull requests
The same @mention interface works identically across Discord, Telegram, WhatsApp, and CLI. To enable another channel, set the corresponding ENABLE_* and token environment variables and restart CodeSpar.
Next Steps
- Learn about the eight agent types and what each one does
- Configure autonomy levels for your team's risk tolerance
- Set up multiple channels for the same project