create-agent
Create and update Harness AI agent instances - standalone templates for agentic workflows in pipelines. Use when asked to create agent, update agent, modify agent spec, build autonomous systems, or work with AI agents.
Harness · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add harness/harness-skills --skill create-agent技能说明
name: create-agent description: >- Create and update Harness AI agent instances - standalone templates for agentic workflows in pipelines. Use when asked to create agent, update agent, modify agent spec, build autonomous systems, or work with AI agents. metadata: author: Harness version: 1.0.0 mcp-server: harness-mcp-v2 module: global summary: Create and update Harness AI agent instances for agentic pipeline workflows license: Apache-2.0 compatibility: Requires Harness MCP v2 server (harness-mcp-v2)
Custom AI Agents
Create and update Harness AI agent instances - standalone templates used as building blocks in pipelines for automated code, agentic workflows, and infrastructure tasks.
Instructions
Follow this workflow to create or update an agent. This is INTERACTIVE — show YAML for review and wait for confirmation before creating/updating the agent.
Phase 1: Check Existing Solutions First
IMPORTANT: Before creating a new agent, check if an existing one can solve the use case.
- List existing agents — Call
harness_listwithresource_type="agent"(includeorg_idandproject_idif scoped to a project)- Check if any system or custom agents already exist that can handle this task
- Ask user if they want to use/modify an existing agent instead of creating new
- For updating existing agents — Use
harness_getwithresource_type="agent"andagent_idto retrieve the current agent configuration- Review the current
spec,name,description, and other fields - Identify what needs to be changed (spec, name, description, wiki, logo)
- Use
harness_update(notharness_create) to update the agent with only the fields that need modification
- Review the current
Phase 2: Requirements Gathering
If creating a new agent or updating an existing one, collect the following before generating YAML:
1. Agent Metadata
- Name: Display name for the agent (e.g. "Code Coverage Agent", "PR Reviewer")
- Description: Brief description of the agent's purpose (optional)
- UID/UUID: Always generate this from the name and pass it explicitly to create/update APIs. Do not rely on the create API fallback.
- Generation rule : prefix with
ca_, then lowercase the name, convert spaces and hyphens (-) to_, replace any remaining non-alphanumeric runs with_, collapse duplicate_, and trim leading/trailing_from the slug portion (e.g. "Code Coverage Agent" →ca_code_coverage_agent, "PR Reviewer" →ca_pr_reviewer) - If the generated UID conflicts with an existing agent, ask the user whether to reuse/update that agent or append a short suffix
- Generation rule : prefix with
2. Task Details - Interactive Requirements Gathering
Ask and clarify the following with the user:
- Agent's exact goal: What specific outcome should the agent achieve? Be specific — avoid vague goals.
- Inputs the agent needs: Repository info? Execution context? Configuration? Secrets?
- Outputs the agent produces: Files? External actions? Data/metrics?
- What the agent works on: Specific file paths? External services? Databases/APIs?
- Task workflow: Step-by-step workflow (do 1, then 2, then 3, etc.)
- Constraints and preferences: Limitations, rules, or coding standards (e.g., "Use idiomatic Go code", "Do not modify existing tests")
- Definition of done: How do you know the agent succeeded? Specific criteria, artifacts, or exit conditions.
3. Recommend Configuration
Based on requirements, recommend and verify with the user:
-
Task instructions (
taskfield):- Break down the goal into detailed step-by-step instructions
- Include specific commands, file paths, and expected outcomes
- Reference inputs using
${{inputs.fieldName}}syntax insidePLUGIN_TASKand other env vars - Add
## RULESsection at the end with constraints formatted as markdown bullet points
-
Runtime inputs (
inputssection in spec):- Only add if user confirms runtime parameters are needed
- Map each input to what the agent needs (repo, branch, executionId, thresholds, etc.)
- Always set a
defaultvalue for every non-required input — if${{inputs.fieldName}}is referenced inPLUGIN_TASKor any env var and no value is supplied at runtime nor a default exists, the agent will error at execution time - Always include
allowedDomainsso users understand and control non-LLM/non-MCP network access
-
Connectors:
- LLM connector for model access (required for all agents) - User must create via Harness UI or MCP
- MCP connectors for external services (GitHub, Slack, Harness platform, etc.) - only if needed
- All authentication and secrets are managed within the connectors
Present this recommended configuration to the user and iterate until confirmed.
4. Default Configuration & Inputs
Agent Structure: Agents use agent.step.group.steps format — the run step is nested inside a named step group.
Default structure:
version: 1
agent:
step:
group:
steps:
- name: Agent
if: <+Always>
id: agent
run:
container:
image: pkg.harness.io/vrvdt5ius7uwygso8s0bia/harness-agents/harness-ai-agent:latest
env:
PLUGIN_TASK: |
<step-by-step task instructions>
PLUGIN_MAX_TURNS: 150
PLUGIN_HARNESS_CONNECTOR: ${{inputs.llmConnector.id}}
PLUGIN_ALLOWED_DOMAINS: ${{inputs.allowedDomains}}
Required environment variables:
env:
PLUGIN_TASK: | # Task instructions go here as a multiline string
<step-by-step instructions>
PLUGIN_MAX_TURNS: 150 # Adjust 100-200 based on task complexity
PLUGIN_HARNESS_CONNECTOR: ${{inputs.llmConnector.id}} # References llmConnector input's id property
PLUGIN_ALLOWED_DOMAINS: ${{inputs.allowedDomains}} # Regexes for additional ne
阅读完整来源 ↗