AgentSkillsCN

agentform

创建并调试 Agentform AI 代理配置文件(.af 文件)。适用于以下场景: (1) 创建新的 Agentform 项目或工作流; (2) 调试 Agentform 语法错误; (3) 添加 MCP 服务器集成; (4) 配置代理、模型、策略或能力; (5) 编写带有路由与人工审批的工作流步骤。 Agentform 是“AI 代理的基础设施即代码”——通过声明式的 .af 文件,定义代理、工作流与策略。

SKILL.md
--- frontmatter
name: agentform
description: |
  Create and debug Agentform AI agent configurations (.af files). Use when:
  (1) Creating new agentform projects or workflows
  (2) Debugging agentform syntax errors
  (3) Adding MCP server integrations
  (4) Configuring agents, models, policies, or capabilities
  (5) Writing workflow steps with routing and human approval
  Agentform is "Infrastructure as Code for AI agents" - declarative .af files define agents, workflows, and policies.

Agentform Skill

Create declarative AI agent configurations using Agentform's .af syntax.

File Structure

Number files for alphabetical processing order:

code
project/
├── 00-project.af      # Project metadata
├── 01-variables.af    # API keys, secrets
├── 02-providers.af    # LLM providers + models
├── 03-servers.af      # MCP servers (optional)
├── 04-capabilities.af # Server capabilities (optional)
├── 05-policies.af     # Cost/timeout limits
├── 06-agents.af       # Agent definitions
├── 07-workflows.af    # Workflow definitions
└── input.yaml         # Example inputs

Block Types Quick Reference

agentform (required)

hcl
agentform {
  version = "0.1"
  project = "my-project"
}

variable

hcl
variable "api_key" {
  type        = string
  description = "API key"
  sensitive   = true
}

Reference: var.api_key

provider

Format: provider "type.vendor" "name" { ... }

hcl
provider "llm.anthropic" "default" {
  api_key = var.anthropic_api_key
}

provider "llm.openai" "default" {
  api_key = var.openai_api_key
  default_params {
    temperature = 0.7
    max_tokens  = 2000
  }
}

Reference: provider.llm.anthropic.default

model

hcl
model "claude_sonnet" {
  provider = provider.llm.anthropic.default
  id       = "claude-sonnet-4-5-20250929"
}

model "gpt4o" {
  provider = provider.llm.openai.default
  id       = "gpt-4o"
  params {
    temperature = 0.5
  }
}

Reference: model.claude_sonnet

Model IDs

Do not hardcode model IDs. Always fetch current model names from the provider's API documentation:

Model IDs change with new releases. Example workflow:

  1. Check provider docs for current model ID
  2. Use exact ID string in your config
  3. Test with agentform validate

server (MCP integration)

hcl
server "github" {
  type      = "mcp"
  transport = "stdio"
  command   = ["npx", "-y", "@modelcontextprotocol/server-github"]

  auth {
    token = var.github_token
  }
}

Reference: server.github

capability

hcl
capability "get_pr" {
  server      = server.github
  method      = "get_pull_request"
  side_effect = "read"
}

capability "create_review" {
  server            = server.github
  method            = "create_pull_request_review"
  side_effect       = "write"
  requires_approval = true
}

Reference: capability.get_pr

policy

Each budget needs its own budgets {} block:

hcl
policy "review_policy" {
  budgets { max_cost_usd_per_run = 0.50 }
  budgets { max_capability_calls = 15 }
  budgets { timeout_seconds = 300 }
}

Reference: policy.review_policy

agent

hcl
agent "reviewer" {
  model           = model.claude_sonnet
  fallback_models = [model.gpt4o]
  policy          = policy.review_policy
  allow           = [capability.get_pr, capability.create_review]

  instructions = <<EOF
You are a code reviewer.
Focus on security and performance.
EOF
}

Reference: agent.reviewer

Heredoc Syntax (CRITICAL)

Multi-line strings use heredoc. The closing marker MUST be at column 0 (no indentation):

hcl
instructions = <<EOF
Line 1
Line 2
EOF

WRONG (will fail validation):

hcl
  instructions = <<EOF
    Line 1
  EOF

The EOF has leading spaces - this breaks parsing.

Expression Syntax

References

TypeSyntaxExample
Variablevar.namevar.api_key
Providerprovider.type.nameprovider.llm.openai.default
Modelmodel.namemodel.gpt4o
Agentagent.nameagent.reviewer
Capabilitycapability.namecapability.get_pr
Serverserver.nameserver.github
Policypolicy.namepolicy.default
Stepstep.namestep.fetch_pr

State References (in workflows)

ContextSyntax
Workflow inputinput.field
Step outputstate.step_output
Nested fieldstate.review.response
Result in stepresult.text, result.data

Operators

hcl
// Comparison
condition = state.value == "expected"
condition = state.count > 10

// Logical
condition = state.a && state.b
condition = !state.flag

// Ternary
value = state.premium ? "gold" : "standard"

NO FUNCTION CALLS - contains(), length() etc. are NOT supported.

Workflow Reference

See references/workflows.md for complete workflow patterns.

CLI Commands

bash
# Validate
agentform validate --var api_key=$API_KEY

# Run workflow
agentform run workflow_name \
  --var api_key=$API_KEY \
  --input '{"field": "value"}'

# Verbose
agentform run workflow_name --verbose

Troubleshooting

ErrorCauseFix
Unexpected token <Heredoc EOF indentedMove EOF to column 0
Unexpected token (Function call usedUse comparison operators
Variable has no valueMissing runtime varAdd --var name=value
MCP server not foundWrong package nameCheck npm package exists

Common MCP Servers

  • @modelcontextprotocol/server-github
  • @modelcontextprotocol/server-filesystem

Templates

Copy these pre-validated templates as starting points:

Simple Agent (no MCP)

bash
cp -r ~/.claude/skills/agentform/assets/templates/simple-agent ./my-agent

MCP Agent (GitHub PR reviewer)

bash
cp -r ~/.claude/skills/agentform/assets/templates/mcp-agent ./my-pr-reviewer