skill.translate

Format translators: SKILL.md <-> agent-specific formats.

Module Attributes

translators

Registry of format translators (Skill -> target format string).

translation_losses

Registry of what each lossy format drops (Skill -> lost field names), by format.

Functions

from_mdc(content)

Import a Cursor .mdc file as a Skill.

lost_fields(skill, *, target_format)

What translating skill to target_format drops; [] for a lossless format.

to_cline_rule(skill)

Translate a Skill to a Cline rule file (Markdown; always active).

to_copilot_instructions(skill)

Translate a Skill to GitHub Copilot instructions format.

to_gemini_md(skill)

Translate a Skill to a section of Gemini CLI's GEMINI.md.

to_mdc(skill)

Translate a Skill to Cursor .mdc format.

to_windsurf_rule(skill)

Translate a Skill to a Windsurf rule, applied when the model judges it relevant.

translate(skill, *, target_format)

Translate a Skill to the specified target format.

skill.translate.from_mdc(content)[source]

Import a Cursor .mdc file as a Skill.

>>> content = "---\ndescription: Do things\nglobs: '*.py'\nalwaysApply: false\n---\n# Rules"
>>> s = from_mdc(content)
>>> s.meta.description
'Do things'
>>> s.meta.metadata.get('cursor.globs')
'*.py'

Globs as Cursor itself writes them (unquoted, not valid YAML) are kept verbatim:

>>> from_mdc("---\nglobs: **/*.py, **/*.ts\n---\nx").meta.metadata['cursor.globs']
'**/*.py, **/*.ts'
Return type:

Skill

skill.translate.lost_fields(skill, *, target_format)[source]

What translating skill to target_format drops; [] for a lossless format.

>>> from skill.base import SkillMeta
>>> s = Skill(meta=SkillMeta(name='t', description='d', license='MIT'), body='x')
>>> lost_fields(s, target_format='mdc')
['license']
>>> lost_fields(s, target_format='skill.md')
[]
Return type:

list[str]

skill.translate.to_cline_rule(skill)[source]

Translate a Skill to a Cline rule file (Markdown; always active).

metadata key cline.paths becomes the paths frontmatter that makes the rule conditional. Lossy: no progressive disclosure, and allowed-tools, license and bundled resources are dropped.

>>> from skill.base import SkillMeta
>>> s = Skill(meta=SkillMeta(name='lint', description='Lint rules'), body='Use ruff.')
>>> to_cline_rule(s).splitlines()[:3]
['# lint', '', '> Lint rules']
Return type:

str

skill.translate.to_copilot_instructions(skill)[source]

Translate a Skill to GitHub Copilot instructions format.

Produces a Markdown section suitable for appending to .github/copilot-instructions.md. Lossy: no frontmatter support beyond applyTo, no progressive disclosure, no resources.

>>> from skill.base import SkillMeta
>>> s = Skill(meta=SkillMeta(name='lint', description='Lint rules'), body='Use ruff.')
>>> md = to_copilot_instructions(s)
>>> '## lint' in md
True
>>> 'Use ruff.' in md
True
Return type:

str

skill.translate.to_gemini_md(skill)[source]

Translate a Skill to a section of Gemini CLI’s GEMINI.md.

Lossy: the file is always loaded (no progressive disclosure), and allowed-tools, license and bundled resources are dropped.

>>> from skill.base import SkillMeta
>>> s = Skill(meta=SkillMeta(name='lint', description='Lint rules'), body='Use ruff.')
>>> to_gemini_md(s).splitlines()[0]
'## lint'
Return type:

str

skill.translate.to_mdc(skill)[source]

Translate a Skill to Cursor .mdc format.

Lossy: allowed-tools, license, bundled resources, and progressive disclosure semantics are lost.

>>> from skill.base import SkillMeta
>>> s = Skill(meta=SkillMeta(name='test', description='Test skill'), body='Do stuff.')
>>> mdc = to_mdc(s)
>>> 'description: Test skill' in mdc
True
>>> 'Do stuff.' in mdc
True
Return type:

str

skill.translate.to_windsurf_rule(skill)[source]

Translate a Skill to a Windsurf rule, applied when the model judges it relevant.

metadata keys windsurf.trigger (default model_decision) and windsurf.globs pass through. Lossy: allowed-tools, license and bundled resources are dropped.

>>> from skill.base import SkillMeta
>>> s = Skill(meta=SkillMeta(name='lint', description='Lint rules'), body='Use ruff.')
>>> print(to_windsurf_rule(s))
---
trigger: model_decision
description: Lint rules
---

Use ruff.
Return type:

str

skill.translate.translate(skill, *, target_format)[source]

Translate a Skill to the specified target format.

>>> from skill.base import SkillMeta
>>> s = Skill(meta=SkillMeta(name='x', description='y'), body='z')
>>> 'alwaysApply' in translate(s, target_format='mdc')
True
Return type:

str

skill.translate.translation_losses: Registry[Callable[[Skill], list[str]]] = Registry('translation_losses', keys=['mdc', 'copilot_md', 'gemini_md', 'windsurf_md', 'clinerules_md'])

Registry of what each lossy format drops (Skill -> lost field names), by format.

The SSOT for lossy down-casts: translators warn from it, and linters (opsward’s portability check) read it without translating anything.

skill.translate.translators: Registry[Callable[[Skill], str]] = Registry('translators', keys=['mdc', 'copilot_md', 'gemini_md', 'windsurf_md', 'clinerules_md'])

Registry of format translators (Skill -> target format string).