## Description Add two Claude Code skills for the Coder Registry: `coder-modules` and `coder-templates`. These skills guide AI agents through creating and updating registry modules and workspace templates, covering scaffolding, Terraform patterns, testing, README standards, icon management, version bumps, and newer features like presets, prebuilds, and task-oriented templates.
21 KiB
name, description
| name | description |
|---|---|
| coder-templates | Creates and updates Coder Registry workspace templates with agent setup, infrastructure provisioning, and module consumption |
Coder Templates
Coder workspace templates are complete workspace definitions that live under registry/<namespace>/templates/<name>/ and provision the infrastructure that workspaces run on.
Before You Start
Before writing or modifying any code:
- Understand the request. What platform is the template targeting (Docker, AWS, GCP, Azure, Kubernetes)? What kind of workspace (VM, container, devcontainer)?
- Research existing templates and modules. Look under
registry/in this repo for similar templates and modules first; if you are not in the repo or cannot find a match, browse https://registry.coder.com. Readmain.tfto understand patterns for that platform, especially how they handle agent setup, persistent storage, and module consumption. Prefer platform-specific helper modules (e.g. region selectors) that provide ready-madecoder_parameterblocks over hard-coding option lists. - Check provider docs. Verify the infrastructure provider resources you plan to use. Check both the Coder provider and the platform provider (AWS, Docker, etc.) version-specific docs if needed.
- Clarify before building. If the request is ambiguous (e.g. unclear platform, whether to use devcontainers vs plain VMs, what parameters to expose, or which namespace to use), ask for clarification rather than guessing. Never assume a namespace; always confirm with the user.
- Plan the structure. Decide on infrastructure resources, what
coder_parameteroptions to expose, which registry modules to consume, and whether additional files like cloud-init configs are needed. When the user describes requirements in terms of their development needs rather than specific Terraform changes (e.g. "I need Node 20 + Postgres 16" or "make this template work for data science"), summarize what you plan to add or change before proceeding. Keep it brief: list the parameters, modules, and infrastructure changes. Skip this for straightforward requests where the action is clear (e.g. "add the code-server module" or "change the default region to us-west-2").
When updating an existing template, read and understand all of its current resources, parameters, and module consumption before making changes. If you observe patterns that deviate from the coder template standards (e.g. missing metadata blocks, hardcoded values that should be parameters, inline implementations that existing modules could replace, missing error handling in scripts), note these to the user as improvement opportunities in your response.
Always prefer the proper implementation over a simpler shortcut. Templates are infrastructure that users depend on. Doing less work is not the same as reducing complexity if it leaves the template incomplete or fragile.
Features marked as "Premium" in this skill require a Coder Premium license. When your implementation uses a Premium feature, note this in your response to the user so they can verify their deployment supports it.
Documentation References
Coder
- Platform docs (latest): https://coder.com/docs
- Version-specific docs:
https://coder.com/docs/@v{MAJOR}.{MINOR}.{PATCH}(e.g. https://coder.com/docs/@v2.31.5) - Creating templates: https://coder.com/docs/admin/templates/creating-templates
- Extending templates: https://coder.com/docs/admin/templates/extending-templates
- Template parameters: https://coder.com/docs/admin/templates/extending-templates/parameters
- Dynamic parameters: https://coder.com/docs/admin/templates/extending-templates/dynamic-parameters
- Workspace presets: https://coder.com/docs/admin/templates/extending-templates/parameters#workspace-presets
- Prebuilt workspaces: https://coder.com/docs/admin/templates/extending-templates/prebuilt-workspaces
- Tasks: https://coder.com/docs/ai-coder/tasks
- Agent Boundaries: https://coder.com/docs/ai-coder/agent-boundaries
- Coder Registry: https://registry.coder.com
Coder Terraform provider
- Provider docs (latest): https://registry.terraform.io/providers/coder/coder/latest/docs
- Version-specific provider docs: replace
latestwith a version number (e.g. https://registry.terraform.io/providers/coder/coder/2.13.1/docs)
Resources:
Data sources:
Terraform providers commonly used in templates
All provider docs follow https://registry.terraform.io/providers/ORG/NAME/latest/docs:
| Provider | Source |
|---|---|
| Docker | kreuzwerker/docker |
| AWS | hashicorp/aws |
| Azure | hashicorp/azurerm |
| GCP | hashicorp/google |
| Kubernetes | hashicorp/kubernetes |
| Cloud-Init | hashicorp/cloudinit |
Browse all providers: https://registry.terraform.io/browse/providers
Scaffolding a New Template
Only use this when creating a brand new template that does not yet exist. When updating an existing template, edit its files directly.
From repo root:
./scripts/new_template.sh namespace/template-name
Names must be lowercase alphanumeric with hyphens (e.g. my-org/aws-ec2). Underscores are not allowed.
Creates registry/<namespace>/templates/<template-name>/ with:
main.tf: full workspace Terraform config with common patterns — read this as the primary reference for template structureREADME.md: frontmatter and documentation
If the namespace is new, the script also creates registry/<namespace>/ with a README. New namespaces additionally need:
registry/<namespace>/.images/avatar.svg(or.png): square image, 400x400px minimum- The namespace README
avatarfield pointing to./.images/avatar.svg
The scaffolding script does not create the .images/ directory or avatar file. When a new namespace is created, create registry/<namespace>/.images/ and add a placeholder avatar.svg so the directory structure is ready for the user to replace with their real avatar.
The generated namespace README contains placeholder fields (display_name, bio, status, github, avatar, etc.) that the user must fill out. The status field is required and must be official, partner, or community (typically community for new contributors).
Key Patterns
- Provider version constraints must reflect actual functionality requirements. Only set a minimum
coderprovider version when the template uses a resource, attribute, or behavior introduced in that version. The same applies to infrastructure providers (Docker, AWS, etc.); check provider changelogs to confirm. - Include
data.coder_workspace.meanddata.coder_workspace_owner.mefor workspace and owner metadata. Includedata.coder_provisioner.meonly when you need the provisioner'sarchorosforcoder_agent(typical for Docker, Kubernetes, Incus); omit when the workspace OS/arch is fixed (e.g. cloud VMs with a known image). - Use
locals {}for computed values: username, environment variables, startup scripts, URL assembly - Use
data.coder_workspace.me.start_countascounton ephemeral resources - Connect containers/VMs to the agent via
coder_agent.main.init_scriptandCODER_AGENT_TOKEN - Add
metadatablocks for workspace dashboard stats (coder stat cpu,coder stat mem, etc.) - Use
coder_metadataon the primary compute resource to surface key details (region, instance type, image, disk size) in the workspace dashboard - Optionally use
display_appsblock to hide specific built-in apps (defaults show all) - Before implementing functionality from scratch, look for an existing module under
registry/*/modules/in this repo; if you cannot find one or are not in the repo, search https://registry.coder.com. If a module already exists for what you need, consume it rather than reimplementing it. When multiple modules serve similar purposes, prefer the actively maintained one and check that you are not using a deprecated or superseded module. - Before consuming a module, read its
main.tfandREADME.mdto understand the full interface: accepted variables, outputs, prerequisites, and runtime requirements. Prefer paths underregistry/<namespace>/modules/<name>/in this workspace; otherwise usehttps://registry.coder.com/modules/<namespace>/<module-name>. Never pass arguments without confirming they exist. - After identifying a module's prerequisites, verify the template's base image satisfies them. If it lacks a required tool, either switch to an image that includes it or ensure the prerequisite is installed before the module's script runs. These runtime issues are not caught by
terraform validate; they only surface when the workspace starts. - Module source URLs use
registry.coder.com/<namespace>/<module>/coder. Older templates may useregistry.coder.com/modules/...; prefer the shorter form when writing new modules or templates. - Label infrastructure resources with
coder.ownerandcoder.workspace_idfor tracking orphans - Use
lifecycle { ignore_changes = all }on persistent volumes to prevent data loss - Do not add comments that narrate what the code does or label sections. Only comment when explaining something non-obvious (e.g. why a workaround exists, a subtle constraint, or an unusual design choice).
Additional files
Templates can include files beyond main.tf + README.md:
cloud-init/*.tftpl: cloud-init configs for VM provisioning (AWS, Azure, GCP), loaded viatemplatefile(). Prefer this subdirectory over placing cloud-init files at the template root.build/Dockerfile: custom container images built by the template.tftplfiles: any Terraform template files for scripts, configs, or cloud-init data
Parameters
Use data "coder_parameter" for user-facing workspace options. Typical parameters: region/instance type/CPU/memory/disk for cloud VMs; container image or runtime version for Docker (pass as build_arg when using a local Dockerfile). Use same-platform templates in registry/ as a starting reference, not a rigid pattern. Expose stated preferences as the parameter default with additional sensible option values unless the user explicitly restricts it.
- Prefer
dynamic "option"blocks withfor_eachfrom alocalsmap over staticoptionblocks. See the region selector modules (e.g.coder/aws-region) for the pattern. - Use
form_typefor richer UI controls:dropdown(searchable),multi-select(forlist(string)),slider(numeric),radio,checkbox,textarea. - Conditional parameters: use
countto show/hide a parameter based on another parameter's value. mutable = falsefor infrastructure that can't change after creation (region, disk);mutable = truefor runtime config.ephemeral = truefor one-shot build options that don't persist between starts.validation {}withmin/max/monotonicfor numbers,regex/errorfor strings.- Dynamic parameter features require Coder provider
>= 2.4.0.
Presets
Workspace presets bundle commonly-used parameter combinations into selectable options. When a user creates a workspace, they can pick a preset to auto-fill multiple parameters at once. Define presets with data "coder_workspace_preset":
data "coder_workspace_preset" "default" {
name = "Standard Dev Environment"
default = true
parameters = {
"region" = "us-east-1"
"cpu" = "4"
"memory" = "8"
"container_image" = "codercom/enterprise-base:ubuntu"
}
}
- The keys in
parametersmust match thenameattribute ofcoder_parameterdata sources in the same template. - Set
default = trueon at most one preset to pre-select it in the UI. - A template can define multiple presets for different use cases.
- Optional fields:
description(context text in UI) andicon(e.g./emojis/1f680.png).
Prebuilds (Premium)
Prebuilds maintain an automatically-managed pool of pre-provisioned workspaces for a preset, reducing workspace creation time. This is a Premium feature. Prebuilds are configured as a nested block inside a preset:
data "coder_workspace_preset" "goland" {
name = "GoLand: Large"
parameters = {
"jetbrains_ide" = "GO"
"cpu" = "8"
"memory" = "16"
}
prebuilds {
instances = 3
expiration_policy {
ttl = 86400
}
scheduling {
timezone = "UTC"
schedule {
cron = "* 8-18 * * 1-5"
instances = 5
}
}
}
}
instances: number of prebuilt workspaces to keep in the pool (base count when no schedule matches).expiration_policy.ttl: seconds before unclaimed prebuilds are cleaned up.scheduling: scale the pool up or down on a time-based cron schedule. Thecronminute field must always be*.- The preset must define all required parameters needed to build the workspace.
- When a prebuild is claimed, ownership transfers to the real user. Use
lifecycle { ignore_changes = [...] }on resources that reference owner-specific values to prevent unnecessary recreation.
Task-Oriented Templates
A template becomes task-capable by adding a coder_ai_task resource, which enables the Coder Tasks UI for AI agent workflows. Task templates require three additions on top of a regular template:
resource "coder_ai_task" "task" {
count = data.coder_workspace.me.start_count
app_id = module.claude-code[count.index].task_app_id
}
data "coder_task" "me" {}
module "claude-code" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/claude-code/coder"
version = "~> 4.0"
agent_id = coder_agent.main.id
workdir = "/home/coder/projects"
ai_prompt = data.coder_task.me.prompt
system_prompt = data.coder_parameter.system_prompt.value
model = "sonnet"
permission_mode = "plan"
enable_boundary = true
}
coder_ai_task: declares the template as task-capable. Itsapp_idmust point to the agent module'stask_app_idoutput.data "coder_task": reads the user's task prompt. Pass it to the agent module viaai_prompt.- Agent module: consume an AI agent module (
claude-code,codex, etc.) with task-specific variables. Key variables includeai_prompt,system_prompt,permission_mode, andenable_boundary. - Boundaries: set
enable_boundary = trueon the agent module to enable network-level filtering for the AI agent. See https://coder.com/docs/ai-coder/agent-boundaries for allowlist configuration. - A
coder_appwithslug = "preview"gets special treatment in the Tasks UI navbar. - Task templates heavily use presets to define scenarios (different repos, system prompts, setup scripts, container images).
- See
registry/coder-labs/templates/tasks-dockeras a reference implementation.
Docs: https://coder.com/docs/ai-coder/tasks
README.md
Required YAML frontmatter:
---
display_name: Docker Containers
description: Provision Docker containers with persistent home volumes as Coder workspaces
icon: ../../../../.icons/docker.svg
verified: false
tags: [docker, container]
---
Content rules:
- Single H1 heading matching
display_name, directly below frontmatter - When increasing header levels, increment by one each time (h1 -> h2 -> h3, not h1 -> h3)
- Opening paragraph describing what the template provisions. Be specific about the platform, compute type, and key capabilities (e.g. "Provision Kubernetes pods on an existing Amazon EKS cluster as Coder workspaces with persistent home volumes") rather than generic (e.g. "AWS Kubernetes template"). The frontmatter
descriptionfield should follow the same principle. - Prerequisites section (infrastructure requirements, provider credentials)
- Architecture section (what resources are created, what's ephemeral vs persistent)
- Code fences labeled
tf(NOThcl) - Relative icon paths (e.g.
../../../../.icons/) - Do NOT include tables or lists that enumerate variables, parameters, or outputs. The registry generates variable and output documentation automatically from the Terraform source. Workspace parameter options are visible in the Coder UI. Describe what the template does and how to use it in prose, not by listing every configurable field.
- Use GFM alerts for callouts:
> [!NOTE],> [!TIP],> [!IMPORTANT],> [!WARNING],> [!CAUTION]
Icons
Templates reference icons in the README frontmatter icon: field using a relative path to the repo's .icons/ directory (e.g. ../../../../.icons/aws.svg). This icon is displayed on the registry website.
Workflow:
- Check what exists. List the
.icons/directory at the repo root for available SVGs. - Use existing icons when they fit. Most templates use a platform icon (aws, gcp, azure, docker, kubernetes) that already exists.
- When an icon doesn't exist, reference the expected path anyway so the structure is correct. Try to source the official SVG from the platform's branding page or repository. If you can obtain it, add it to
.icons/in this repo. - Don't substitute a generic icon. If the platform has its own brand identity, use the correct name even if the file doesn't exist yet.
- Track missing icons so you can report them in your response.
Testing
Templates do NOT require .tftest.hcl or main.test.ts. Testing is done by pushing the template to a Coder deployment.
Commands
| Task | Command | Scope |
|---|---|---|
| Format all | bun run fmt |
Repo |
| Validate | ./scripts/terraform_validate.sh |
Repo |
| ShellCheck | bun run shellcheck |
Repo |
Final Checks
Before considering the work complete, verify:
terraform init && terraform validatepasses in the template directorybun run fmthas been runbun run shellcheckpasses if the template includes shell scripts- README documents prerequisites and architecture
- Shell scripts handle errors gracefully (
|| echo "Warning..."for non-fatal failures). If a script sources external files ($HOME/.bashrc,/etc/bashrc,/etc/os-release), thesourcemust come beforeset -u; CI enforces this ordering. - No hardcoded values that should be configurable via variables or parameters
- Asset and icon paths in frontmatter and Terraform must be relative (e.g.
../../../../.icons/), not absolute. External hyperlinks to docs or other websites are fine.
Response to the User
In your response, include:
- A ready-to-run push command with real values filled in. Use
-dto point at the template directory (so it works from the repo root),-mfor a short description, and-yto skip interactive prompts:
coder templates push \
registry/ \
-m "Initial version: <brief description>" \
-y < template-name > -d < namespace > /templates/ < template-name > /
- If a new namespace was created, remind the user to fill out the namespace README (
display_name,bio,status,github, etc.) and replace the placeholder avatar. Note that this is only needed if they plan to contribute to the registry. - If any icons were referenced but not found, list them and note they need to be sourced and added to both this repo's
.icons/directory and thecoder/coderrepo atsite/static/icon/. - A note that to contribute the template to the public registry, they can open a pull request to https://github.com/coder/registry.