multi-harness-portability
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMulti-Harness Portability
多框架可移植性
Part of Agent Skills™ by googleadsagent.ai™
隶属于 Agent Skills™,由 googleadsagent.ai™ 开发
Description
简介
Multi-Harness Portability is the engineering discipline of writing agent skills, prompts, and configurations that work across every major AI coding harness — Claude Code, Cursor, Codex, Gemini CLI, OpenCode, and beyond. The AI tooling landscape is fragmenting rapidly: teams use different editors, different CLI tools, different models. Skills that are locked to a single platform become liabilities; skills that are portable become assets that compound in value across the entire organization.
This skill encodes the portability architecture developed for Agent Skills™ by googleadsagent.ai™, where every skill in the repository is designed to function across all major harnesses. The key insight is that portability is an architectural decision, not an afterthought. It requires abstraction layers that map platform-specific capabilities (hooks, rules, instructions, system prompts) to a universal skill interface, with platform-specific adapters handling the translation.
The portability layer handles three categories of platform differences: skill loading (how the skill enters the agent's context), tool access (what tools are available and how they're invoked), and output formatting (how the agent delivers results). Each category requires its own adapter pattern, and the combination provides true write-once-run-anywhere agent skills.
多框架可移植性是一种工程方法论,指编写可在所有主流AI编码框架(包括Claude Code、Cursor、Codex、Gemini CLI、OpenCode等)中运行的Agent技能、提示词和配置。AI工具领域正迅速分化:团队使用不同的编辑器、不同的CLI工具、不同的模型。被锁定在单一平台的技能会成为负担;而具备可移植性的技能则会成为资产,在整个组织中持续增值。
本技能编码了由 googleadsagent.ai™ 为 Agent Skills™ 开发的可移植性架构,该仓库中的每个技能都设计为可在所有主流框架中运行。核心思路是:可移植性是一种架构决策,而非事后补充。它需要抽象层将平台特定的能力(钩子、规则、指令、系统提示词)映射到通用技能接口,由平台特定的适配器负责转换。
可移植性层处理三类平台差异:技能加载(技能如何进入Agent的上下文)、工具访问(可用工具及调用方式)、输出格式(Agent如何交付结果)。每一类都需要独立的适配器模式,三者结合实现真正的“一次编写、随处运行”的Agent技能。
Use When
适用场景
- Your team uses multiple AI coding tools (Claude Code, Cursor, Codex, etc.)
- You want to maintain a single skill repository that serves all platforms
- Skills developed for one platform need to be ported to others
- You are building an open-source skill library for the community
- CI/CD pipelines need to validate skills across multiple platforms
- Organization policy requires platform-agnostic tooling
- 你的团队使用多种AI编码工具(Claude Code、Cursor、Codex等)
- 你希望维护一个服务所有平台的单一技能仓库
- 为某一平台开发的技能需要移植到其他平台
- 你正在为社区构建开源技能库
- CI/CD流水线需要在多个平台上验证技能
- 组织政策要求使用与平台无关的工具
How It Works
工作原理
mermaid
graph TD
A[Universal SKILL.md] --> B[Platform Detector]
B --> C{Which Harness?}
C -->|Claude Code| D[Claude Adapter]
C -->|Cursor| E[Cursor Adapter]
C -->|Codex| F[Codex Adapter]
C -->|Gemini| G[Gemini Adapter]
D --> H[CLAUDE.md Rules + Hooks]
E --> I[.cursor/rules/ + Skills]
F --> J[codex instructions]
G --> K[System Prompt Config]
H --> L[Unified Execution]
I --> L
J --> L
K --> LThe portability layer sits between the universal skill definition (SKILL.md) and the platform-specific loading mechanism. A platform detector identifies the current execution environment. Platform adapters translate the universal skill format into the native configuration of each harness: Claude Code uses CLAUDE.md and hooks, Cursor uses and SKILL.md files, Codex uses instruction files, and Gemini uses system prompt configuration. The unified execution layer ensures that regardless of the loading path, the agent receives equivalent instructions and constraints.
.cursor/rules/mermaid
graph TD
A[Universal SKILL.md] --> B[Platform Detector]
B --> C{Which Harness?}
C -->|Claude Code| D[Claude Adapter]
C -->|Cursor| E[Cursor Adapter]
C -->|Codex| F[Codex Adapter]
C -->|Gemini| G[Gemini Adapter]
D --> H[CLAUDE.md Rules + Hooks]
E --> I[.cursor/rules/ + Skills]
F --> J[codex instructions]
G --> K[System Prompt Config]
H --> L[Unified Execution]
I --> L
J --> L
K --> L可移植性层位于通用技能定义(SKILL.md)和平台特定加载机制之间。平台检测器识别当前执行环境。平台适配器将通用技能格式转换为各框架的原生配置:Claude Code使用CLAUDE.md和钩子,Cursor使用和SKILL.md文件,Codex使用指令文件,Gemini使用系统提示词配置。统一执行层确保无论加载路径如何,Agent都能收到等效的指令和约束。
.cursor/rules/Implementation
实现方案
Platform Detection:
bash
#!/bin/bash
detect_platform() {
if [ -n "$CLAUDE_CODE" ] || [ -f "CLAUDE.md" ]; then
echo "claude-code"
elif [ -d ".cursor" ] || [ -n "$CURSOR_SESSION" ]; then
echo "cursor"
elif [ -n "$CODEX_SESSION" ] || [ -f ".codex/instructions.md" ]; then
echo "codex"
elif [ -n "$GEMINI_CLI" ]; then
echo "gemini"
else
echo "generic"
fi
}Universal Skill Installer:
python
import os
import shutil
from pathlib import Path
class SkillInstaller:
PLATFORM_CONFIGS = {
"claude-code": {
"skill_dir": ".",
"rules_file": "CLAUDE.md",
"hooks_dir": ".claude/hooks",
"format": "markdown_rules",
},
"cursor": {
"skill_dir": ".cursor/skills",
"rules_file": ".cursor/rules/{name}.md",
"hooks_dir": None,
"format": "skill_md",
},
"codex": {
"skill_dir": ".codex",
"rules_file": ".codex/instructions.md",
"hooks_dir": None,
"format": "instructions",
},
"gemini": {
"skill_dir": ".gemini",
"rules_file": ".gemini/system_prompt.md",
"hooks_dir": None,
"format": "system_prompt",
},
}
def install(self, skill_path: str, platform: str, project_root: str):
config = self.PLATFORM_CONFIGS[platform]
skill = self.parse_skill(skill_path)
if config["format"] == "markdown_rules":
self.install_claude_code(skill, config, project_root)
elif config["format"] == "skill_md":
self.install_cursor(skill, config, project_root)
elif config["format"] == "instructions":
self.install_codex(skill, config, project_root)
elif config["format"] == "system_prompt":
self.install_gemini(skill, config, project_root)
def install_cursor(self, skill, config, root):
skill_dir = Path(root) / config["skill_dir"] / skill["name"]
skill_dir.mkdir(parents=True, exist_ok=True)
(skill_dir / "SKILL.md").write_text(skill["content"])
def install_claude_code(self, skill, config, root):
claude_md = Path(root) / config["rules_file"]
existing = claude_md.read_text() if claude_md.exists() else ""
section = f"\n\n## Skill: {skill['name']}\n\n{skill['instructions']}\n"
if skill["name"] not in existing:
claude_md.write_text(existing + section)
def parse_skill(self, path: str) -> dict:
content = Path(path).read_text()
name = content.split("\n")[0].replace("# ", "").strip()
return {"name": name, "content": content, "instructions": self.extract_instructions(content)}
def extract_instructions(self, content: str) -> str:
sections = content.split("\n## ")
for section in sections:
if section.startswith("Use When") or section.startswith("Best Practices"):
return section
return content[:2000]Cross-Platform Skill Testing:
yaml
undefined平台检测:
bash
#!/bin/bash
detect_platform() {
if [ -n "$CLAUDE_CODE" ] || [ -f "CLAUDE.md" ]; then
echo "claude-code"
elif [ -d ".cursor" ] || [ -n "$CURSOR_SESSION" ]; then
echo "cursor"
elif [ -n "$CODEX_SESSION" ] || [ -f ".codex/instructions.md" ]; then
echo "codex"
elif [ -n "$GEMINI_CLI" ]; then
echo "gemini"
else
echo "generic"
fi
}通用技能安装器:
python
import os
import shutil
from pathlib import Path
class SkillInstaller:
PLATFORM_CONFIGS = {
"claude-code": {
"skill_dir": ".",
"rules_file": "CLAUDE.md",
"hooks_dir": ".claude/hooks",
"format": "markdown_rules",
},
"cursor": {
"skill_dir": ".cursor/skills",
"rules_file": ".cursor/rules/{name}.md",
"hooks_dir": None,
"format": "skill_md",
},
"codex": {
"skill_dir": ".codex",
"rules_file": ".codex/instructions.md",
"hooks_dir": None,
"format": "instructions",
},
"gemini": {
"skill_dir": ".gemini",
"rules_file": ".gemini/system_prompt.md",
"hooks_dir": None,
"format": "system_prompt",
},
}
def install(self, skill_path: str, platform: str, project_root: str):
config = self.PLATFORM_CONFIGS[platform]
skill = self.parse_skill(skill_path)
if config["format"] == "markdown_rules":
self.install_claude_code(skill, config, project_root)
elif config["format"] == "skill_md":
self.install_cursor(skill, config, project_root)
elif config["format"] == "instructions":
self.install_codex(skill, config, project_root)
elif config["format"] == "system_prompt":
self.install_gemini(skill, config, project_root)
def install_cursor(self, skill, config, root):
skill_dir = Path(root) / config["skill_dir"] / skill["name"]
skill_dir.mkdir(parents=True, exist_ok=True)
(skill_dir / "SKILL.md").write_text(skill["content"])
def install_claude_code(self, skill, config, root):
claude_md = Path(root) / config["rules_file"]
existing = claude_md.read_text() if claude_md.exists() else ""
section = f"\n\n## Skill: {skill['name']}\n\n{skill['instructions']}\n"
if skill["name"] not in existing:
claude_md.write_text(existing + section)
def parse_skill(self, path: str) -> dict:
content = Path(path).read_text()
name = content.split("\n")[0].replace("# ", "").strip()
return {"name": name, "content": content, "instructions": self.extract_instructions(content)}
def extract_instructions(self, content: str) -> str:
sections = content.split("\n## ")
for section in sections:
if section.startswith("Use When") or section.startswith("Best Practices"):
return section
return content[:2000]跨平台技能测试:
yaml
undefined.github/workflows/skill-test.yml
.github/workflows/skill-test.yml
name: Skill Portability Test
on: [push, pull_request]
jobs:
test-skills:
strategy:
matrix:
platform: [claude-code, cursor, codex, gemini]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install skill for ${{ matrix.platform }}
run: |
python scripts/install_skill.py
--skill skills/claude-mythos/context-engineering/SKILL.md
--platform ${{ matrix.platform }}
--root ./test-project - name: Validate installation run: | python scripts/validate_installation.py
--platform ${{ matrix.platform }}
--root ./test-project - name: Run platform-specific checks run: | python scripts/platform_checks.py
--platform ${{ matrix.platform }}
--root ./test-project
--skill skills/claude-mythos/context-engineering/SKILL.md
--platform ${{ matrix.platform }}
--root ./test-project - name: Validate installation run: | python scripts/validate_installation.py
--platform ${{ matrix.platform }}
--root ./test-project - name: Run platform-specific checks run: | python scripts/platform_checks.py
--platform ${{ matrix.platform }}
--root ./test-project
**Portable Skill Template:**
```markdownname: Skill Portability Test
on: [push, pull_request]
jobs:
test-skills:
strategy:
matrix:
platform: [claude-code, cursor, codex, gemini]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install skill for ${{ matrix.platform }}
run: |
python scripts/install_skill.py
--skill skills/claude-mythos/context-engineering/SKILL.md
--platform ${{ matrix.platform }}
--root ./test-project - name: Validate installation run: | python scripts/validate_installation.py
--platform ${{ matrix.platform }}
--root ./test-project - name: Run platform-specific checks run: | python scripts/platform_checks.py
--platform ${{ matrix.platform }}
--root ./test-project
--skill skills/claude-mythos/context-engineering/SKILL.md
--platform ${{ matrix.platform }}
--root ./test-project - name: Validate installation run: | python scripts/validate_installation.py
--platform ${{ matrix.platform }}
--root ./test-project - name: Run platform-specific checks run: | python scripts/platform_checks.py
--platform ${{ matrix.platform }}
--root ./test-project
**可移植技能模板:**
```markdown{Skill Name}
{Skill Name}
Part of Agent Skills™
<!-- PORTABLE: This skill is designed for cross-platform compatibility -->
<!-- PLATFORMS: claude-code, cursor, codex, gemini -->Part of Agent Skills™
<!-- PORTABLE: This skill is designed for cross-platform compatibility -->
<!-- PLATFORMS: claude-code, cursor, codex, gemini -->Description
Description
{Platform-agnostic description using no platform-specific terminology}
{Platform-agnostic description using no platform-specific terminology}
Use When
Use When
{Conditions that apply regardless of platform}
{Conditions that apply regardless of platform}
Implementation
Implementation
{Code examples using standard libraries, no platform-specific APIs}
{Code examples using standard libraries, no platform-specific APIs}
Platform Notes
Platform Notes
| Platform | Loading | Notes |
|---|---|---|
| Claude Code | CLAUDE.md / hooks | {specific guidance} |
| Cursor | .cursor/skills/ | {specific guidance} |
| Codex | instructions.md | {specific guidance} |
| Gemini | system_prompt | {specific guidance} |
undefined| Platform | Loading | Notes |
|---|---|---|
| Claude Code | CLAUDE.md / hooks | {specific guidance} |
| Cursor | .cursor/skills/ | {specific guidance} |
| Codex | instructions.md | {specific guidance} |
| Gemini | system_prompt | {specific guidance} |
undefinedBest Practices
最佳实践
- Write platform-agnostic instructions first — the core skill logic should use no platform-specific terminology; platform adapters handle translation.
- Test on at least two platforms — portability bugs are only caught by actually running the skill on multiple platforms; CI validation is essential.
- Use the SKILL.md format as the universal source — it is the most widely supported format; all other formats are derived from it.
- Document platform-specific limitations — if a feature requires hooks (Claude Code only) or extensions (Cursor only), document it clearly in the compatibility table.
- Avoid tool-specific assumptions — not all platforms have the same tools; use capability detection rather than assuming tool availability.
- Version your adapter layer — as platforms evolve their skill loading mechanisms, adapters need updates; version them independently from skill content.
- Provide fallback instructions — if a platform doesn't support a feature natively, provide manual instructions the user can follow.
- 先编写与平台无关的指令——核心技能逻辑不应使用任何平台特定术语;平台适配器负责转换。
- 至少在两个平台上测试——只有在多个平台上实际运行技能才能发现可移植性问题;CI验证至关重要。
- 将SKILL.md格式作为通用源——这是支持最广泛的格式;所有其他格式都派生自它。
- 记录平台特定限制——如果某功能需要钩子(仅Claude Code支持)或扩展(仅Cursor支持),请在兼容性表中明确记录。
- 避免工具特定假设——并非所有平台都有相同的工具;应使用能力检测而非假设工具可用。
- 为适配器层版本化——随着平台更新其技能加载机制,适配器需要更新;将其与技能内容独立版本化。
- 提供 fallback 指令——如果平台不原生支持某功能,提供用户可遵循的手动指令。
Platform Compatibility
平台兼容性
| Feature | Claude Code | Cursor | Codex | Gemini CLI |
|---|---|---|---|---|
| SKILL.md loading | ✅ Via CLAUDE.md | ✅ Native | ⚠️ Via instructions | ⚠️ Via system prompt |
| Automated installation | ✅ Hooks | ✅ Skills | ✅ CLI | ✅ Config |
| Cross-platform CI | ✅ Full | ✅ Full | ✅ Full | ✅ Full |
| Adapter layer | ✅ Full | ✅ Full | ✅ Full | ✅ Full |
| Hot-reload | ✅ File watch | ✅ Native | ❌ Restart needed | ❌ Restart needed |
| 功能 | Claude Code | Cursor | Codex | Gemini CLI |
|---|---|---|---|---|
| SKILL.md加载 | ✅ 通过CLAUDE.md | ✅ 原生支持 | ⚠️ 通过指令 | ⚠️ 通过系统提示词 |
| 自动化安装 | ✅ 钩子 | ✅ 技能 | ✅ CLI | ✅ 配置 |
| 跨平台CI | ✅ 完全支持 | ✅ 完全支持 | ✅ 完全支持 | ✅ 完全支持 |
| 适配器层 | ✅ 完全支持 | ✅ 完全支持 | ✅ 完全支持 | ✅ 完全支持 |
| 热重载 | ✅ 文件监听 | ✅ 原生支持 | ❌ 需要重启 | ❌ 需要重启 |
Related Skills
相关技能
- Prompt Architecture - Platform-agnostic prompt layering that forms the portable core adapted by harness-specific loaders
- Anthropic Tool Mastery - Tool orchestration patterns that must be adapted across platform-specific tool interfaces
- Context Engineering - Context management techniques that apply universally but require platform-specific token budget tuning
- Prompt Architecture - 与平台无关的提示词分层,构成由框架特定加载器适配的可移植核心
- Anthropic Tool Mastery - 工具编排模式,需适配跨平台特定工具接口
- Context Engineering - 上下文管理技术,通用适用但需针对平台特定令牌预算调优
Keywords
关键词
multi-harness, portability, cross-platform, write-once-run-anywhere, platform-adapter, skill-installation, claude-code, cursor, codex, gemini, agent-skills
© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License
multi-harness, portability, cross-platform, write-once-run-anywhere, platform-adapter, skill-installation, claude-code, cursor, codex, gemini, agent-skills
© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License