Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c349ac0

Browse files
committed
Update tasks how-to
1 parent e3ec375 commit c349ac0

File tree

1 file changed

+38
-61
lines changed

1 file changed

+38
-61
lines changed

docs/tutorials/quickstart.md

Lines changed: 38 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -244,67 +244,44 @@ advanced capabilities that Coder offers.
244244
### Get Coder Tasks Running
245245

246246
Coder Tasks is an interface that allows you to run and manage coding agents like
247-
Claude Code. Tasks become available when a template has the `coder_ai_task`
248-
resource and `coder_parameter` named `AI Prompt` defined in its source code.
249-
Subsequently, any existing template can become a Task template by adding in that
250-
resource and parameter.
251-
252-
Let's try turning the **Docker Containers** template into a Task template
253-
running Claude Code:
254-
255-
1. Head to **Templates**
256-
1. Click into the template, and then click **Source Code** -> **Edit**
257-
1. Add the following code snippit to the bottom of the terraform. This defines
258-
the `coder_ai_task` resource and `coder_parameter`
259-
260-
```hcl
261-
# Claude API Key variable (filled in during template build)
262-
variable "claude_api_key" {
263-
type = string
264-
description = "Your Anthropic API key for Claude AI"
265-
sensitive = true
266-
}
267-
268-
# AI Prompt parameter
269-
data "coder_parameter" "ai_prompt" {
270-
name = "AI Prompt"
271-
display_name = "AI Prompt"
272-
description = "Optional AI prompt to customize behavior"
273-
type = "string"
274-
default = ""
275-
}
276-
277-
# Claude app
278-
resource "coder_app" "claude-code" {
279-
agent_id = coder_agent.main.id
280-
slug = "claude"
281-
display_name = "Claude"
282-
url = "https://claude.ai"
283-
icon = "https://claude.ai/favicon.ico"
284-
external = true
285-
}
286-
287-
# Claude AI task
288-
resource "coder_ai_task" "claude-code" {
289-
count = data.coder_parameter.ai_prompt.value != "" ? 1 : 0
290-
291-
sidebar_app {
292-
id = coder_app.claude-code.id
293-
}
294-
}
295-
296-
```
297-
298-
1. **Build the Template**: Click "Build version". This will process your
299-
template updates. After it finishes building successfully:
300-
1. **Activate the Template**: Click "Promote Version" on the new version to make
301-
it the active template version.
302-
1. **Create a Task**: Click "Create Task".
303-
1. Once your workspace is running, navigate to the **Tasks** tab in the upper
304-
left hand corner. Type in a message or coding request like "Help me write a
305-
HelloWorld application in Python". Click **Run Task** to start the task
306-
1. The task will open VS Code with Claude Code running in the left sidebar. You
307-
are now successfully using Coder Tasks with Claude Code!
247+
Claude Code within a given Workspace. Tasks become available when the Template for a Workspace has the `coder_ai_task` resource and `coder_parameter` named `AI Prompt` defined in its source code.
248+
In other words, any existing template can become a Task template by adding in that
249+
resource and parameter.
250+
251+
Coder maintains the [Tasks on Docker](https://registry.coder.com/templates/coder-labs/tasks-docker?_gl=1*19yewmn*_gcl_au*MTc0MzUwMTQ2NC4xNzU2MzA3MDkxLjk3NTM3MjgyNy4xNzU3Njg2NDY2LjE3NTc2ODc0Mzc.*_ga*NzUxMDI1NjIxLjE3NTYzMDcwOTE.*_ga_FTQQJCDWDM*czE3NTc3MDg4MDkkbzQ1JGcxJHQxNzU3NzA4ODE4JGo1MSRsMCRoMA..) template which has Anthropic's Claude Code agent built in with a sample application. Let's try using this template by pulling it from Coder's Registry of public templates, and pushing it to your local server:
252+
253+
1. **Push the Template to your Coder Deployment**:
254+
1. In the upper right hand corner, click **Use this template**
255+
1. Open a terminal on your machine
256+
1. Ensure your CLI is authenticated with your Coder deployment by [logging in](https://coder.com/docs/reference/cli/login)
257+
1. Create an [API Key with Anthropic](https://console.anthropic.com/)
258+
1. Head to the [Tasks on Docker](https://registry.coder.com/templates/coder-labs/tasks-docker?_gl=1*19yewmn*_gcl_au*MTc0MzUwMTQ2NC4xNzU2MzA3MDkxLjk3NTM3MjgyNy4xNzU3Njg2NDY2LjE3NTc2ODc0Mzc.*_ga*NzUxMDI1NjIxLjE3NTYzMDcwOTE.*_ga_FTQQJCDWDM*czE3NTc3MDg4MDkkbzQ1JGcxJHQxNzU3NzA4ODE4JGo1MSRsMCRoMA..) template
259+
1. Clone the Coder Registry repo to your local machine
260+
```hcl
261+
git clone https://github.com/coder/registry.git
262+
```
263+
1. Switch to the template directory
264+
```hcl
265+
cd registry/registry/coder-labs/templates/tasks-docker
266+
```
267+
1. Push the template to your Coder deployment. Note: this command differs from the registry since we're defining the Anthropic API Key as an environment variable
268+
```hcl
269+
coder template push tasks-docker -d . --variable anthropic_api_key="your-api-key"
270+
```
271+
1. **Create the new Workspace**
272+
1. In your Coder Deployment, click **Workspaces** in the upper left hand corner
273+
1. Click **New workspace** and choose **tasks-docker**
274+
1. Fill in the Workspace name. Add in an AI Prompt for Claude Code like "Make the background yellow". Click **Create workspace**
275+
1. **See Tasks in action**
276+
1. Once your workspace is running, click **View tasks** with your workspace. This will bring you to the Tasks view where you can see Claude Code (left panel), preview the sample application, and interact with the code in code-server. You might need to wait for Claude Code to finish changing the background color of the application.
277+
![Tasks changing background color of demo application](../images/screenshots/quickstart-tasks-background-change.png)
278+
navigate to the **Tasks** tab in the upper
279+
left hand corner
280+
1. Try typing in a new request to Claude Code: "make the background red"
281+
1. Let's exit out of this specific Task view, so we can see all the running tasks
282+
1. You can start a new task by prompting in the "Prompt your AI agent to start a task" box. You can select which template to run this from, so tasks-docker here, and that will spin up a new Workspace
283+
284+
Congratulation! You now have a Coder Task running. This demo has shown you how to spin up a task, and prompt Claude Code to change parts of your application. Learn more specifics about Coder Tasks [here](https://coder.com/docs/ai-coder/tasks).
308285

309286
## Troubleshooting
310287

0 commit comments

Comments
 (0)