---
name: format-converter
description: Convert DevOps artifacts between formats and tooling — docker-compose to Kubernetes, Bash to Ansible, cURL to code, iptables to nftables, JSON to YAML, and more.
---

## Trigger Phrases
Use this skill when the request is to convert or migrate between DevOps formats or tools:

- "Convert this docker-compose.yml to Kubernetes manifests."
- "Turn this Bash script into an Ansible playbook."
- "I have a cURL command from the docs — convert it to Python requests."
- "Migrate this iptables config to nftables."
- "Convert this JSON to YAML."
- "Rewrite this Makefile target as a GitHub Actions step."

Do not use this skill for generating from scratch with no source artifact. Use the appropriate generator skill.

## Deterministic Execution Flow

### Stage 0: Identify Conversion Pair

| From | To | Key considerations |
|------|----|--------------------|
| `docker-compose.yml` | Kubernetes manifests | Service → Service + Deployment; volumes → PVC; networks → NetworkPolicy optional |
| `docker-compose.yml` | Helm chart | Parameterize image, replicas, env vars as values |
| Bash script | Ansible playbook | Idempotency, module selection, variable extraction |
| `cURL` command | Python `requests` | Auth headers, SSL, error handling, JSON body |
| `cURL` command | Go `net/http` | Struct for request/response, error wrapping |
| JSON | YAML | Scalar quoting, multiline strings, null handling |
| `iptables` rules | `nftables` | Chain types, hook priorities, set syntax differences |
| Makefile target | GitHub Actions step | Shell quoting, env var injection, working-directory |
| Jenkins pipeline | GitHub Actions workflow | Stage → job, agent → runner, credentials → secrets |

If the conversion pair is not in the table above, proceed with best judgment and state assumptions.

### Stage 1: Collect Source Artifact and Constraints
Request or confirm:

1. The **complete source artifact** — do not proceed with a partial file or a description
2. **Target constraints** (ask only if missing and they affect the output):
   - For K8s: target API version, namespace, whether to use Helm or raw YAML
   - For Ansible: target OS family, whether to use FQCN module names (default: yes), collections available
   - For code: target language version, library preferences, async vs. sync
   - For nftables: kernel version (4.x vs. 5.x+ syntax differences)

State any assumptions made before generating output.

### Stage 2: Conversion Standards

**docker-compose to Kubernetes:**
- Each `service` becomes a `Deployment` + `Service`
- Named volumes become `PersistentVolumeClaim`; use `ReadWriteOnce` as default storage mode
- `environment` values become `env:` entries; flag values that look like secrets for `Secret` extraction
- `ports` → `Service.spec.ports`; expose as `ClusterIP` by default, not `NodePort`
- `depends_on` has no direct K8s equivalent — document that readiness probes replace it
- Add `resources.requests` and `resources.limits` as placeholder comments

**Bash to Ansible:**
- Map shell commands to FQCN modules (`ansible.builtin.package`, `ansible.builtin.service`, `ansible.builtin.copy`)
- Extract hardcoded values to `vars:` or `defaults/`
- Replace `if [ -f ]` checks with `when:` conditions and `ansible.builtin.stat`
- Mark tasks that cannot be made idempotent with a comment explaining why
- Use `no_log: true` for tasks handling secrets

**cURL to requests/http:**
- Preserve all headers, including auth
- Map `--data` / `-d` to JSON body; infer `Content-Type` from flag
- Add error handling (non-2xx response codes)
- Extract URL and credentials to named constants or environment variables

**iptables to nftables:**
- Map `-A INPUT` → `chain input { type filter hook input priority 0; }`
- Map `-j ACCEPT/DROP` → `accept/drop`
- Combine related rules into sets where applicable
- Note rules that have no direct nftables equivalent

### Stage 3: Output Format

```
## Conversion: [Source format] → [Target format]

**Assumptions:**
- [List every assumption made]

**What changed:**
- [Key structural differences the user should know about]
- [Anything that could not be converted directly and why]

**Output:**
[fenced code block with converted artifact]

**Next steps:**
- [Any manual verification, placeholder replacement, or follow-up required]
```

For multi-file outputs (e.g., docker-compose to K8s with Deployment + Service + PVC), use separate named code blocks:

```yaml
# deployment.yaml
...
```
```yaml
# service.yaml
...
```

## Done Criteria
- The full source artifact was provided before generating output.
- All assumptions are stated explicitly.
- No placeholder values remain unresolved unless they require user-specific input (clearly labeled as `<REPLACE_ME>`).
- Key semantic differences between source and target are explained (not just translated silently).
- Output is separated into logical files when the target format requires multiple files.
