Translate source agent files from a specified source provider into a target client's custom agent format. Use when: converting agents to VS Code Copilot, Factory Droid, Kilo Code, or other targets; generating target agent files; migrating agents cross-platform; building field mappings from source to target format.
Translate source agent files from a specified source provider into a target client's custom agent format, then place them at the target's user-wide location.
Detect whether the source is being run from Windows or Linux/WSL. Record this as the target environment—target files will be placed at the target's user-wide location for this same environment.
Determine which source provider to use. The user may specify a source provider explicitly (e.g., , ) or omit it.
.claude.opencodeDefault source provider is defined in generate-target-agents.md under "Source provider selection → Default source provider". If the user does not specify a source provider, use that default. Do not hardcode the default here — always read it from the instructions file.
Once the source provider is determined:
.source/agents/<provider>/agents/ to discover the format: parse frontmatter fields, identify required vs optional fields, note naming conventions. Then record the newly discovered provider as a new subsection in the "Learned source provider index" of generate-target-agents.md. This prevents re-discovery on future runs.If the provider sub-directory does not exist (e.g., .source/agents/.foo/agents/), stop the run and report that the specified source provider is not available. List the available providers by enumerating sub-directories under .source/agents/.
Read all agent files from the resolved source provider's agent directory (e.g., .source/agents/.claude/agents/ or .source/agents/.opencode/agents/).
Use the format and field definitions from the source provider's cached entry (step 2) to parse each file. Each file will have:
If a source file has malformed frontmatter or cannot be parsed, skip it, log the error, and continue with the remaining files. Include skipped files and error details in the conversion report.
Reference: Source agents index
Given the target client name or docs URL:
If web fetch fails (rate limited, docs moved, site down), stop the entire run — the target format is a hard dependency. Report the failure clearly with the URL attempted and the error received.
Create a mapping between each source field (from the resolved source provider's format) and the most appropriate target field:
| Source (from provider) | Target | Transformation |
|---|---|---|
name / filename | (target's name field) | (document rule) |
description | (target's description field) | (document rule) |
tools | (target's tool config) | (map tool names/format to target equivalents) |
model | (target's model field) | (map model identifiers) |
| Body (markdown) | (target's prompt/body area) | (preserve verbatim) |
| Provider-specific fields | (comments/extra metadata) | (document preservation strategy) |
Note: Different source providers may have different field names, types, and structures. For example, Claude Code uses an array-style tools field while OpenCode uses an object-style tools map. The field mapping must account for the source provider's specific conventions.
CRITICAL: Lossless translation. All source information must appear in the target output. Where the target format's structure differs from the source (e.g., body content moves into a YAML field like roleDefinition), the information is preserved even if the structure changes. Use these priority tiers:
name/identifier, description, body/prompt content.tools (mapped to target equivalents), model (mapped to target identifiers).permissionMode, hooks, permission, temperature). Add as comments in the target file or document in the conversion report.For each source agent file:
<filename>.bak.20260301T1423)..tmp file first. Only after verification, atomically replace the original (Move-Item -Force on Windows).Re-run behavior: If target files already exist from a prior conversion, overwrite them unconditionally (the backup in substep 1 protects against data loss). Include a diff summary of what changed in the conversion report.
Place generated files at the target's user-wide location for the detected environment.
After completion, generate a conversion report directory at docs/reports/<target>/ (e.g., docs/reports/kilo-code/, docs/reports/factory-droid/). This allows multiple report files per target if needed (e.g., separate field mapping docs, issue logs, or re-run reports).
The primary report file is always named conversion-report.md (e.g., docs/reports/kilo-code/conversion-report.md). It should contain:
Reference existing reports for format: docs/reports/
The generate-target-agents.md task guide maintains two caches:
Run these checks before considering the conversion complete. If any check fails, fix the issue before finishing.
name/identifier, description, body content) are present in every target filetools, model) are mapped where the target supports themdocs/reports/<target>/conversion-report.md