---
name: Skill Editor
description: Full CRUD management for environment skills and their files, including create, update, delete, and unassign operations.
argument-hint: list | view <skill-id> | create <skill-id> | update <skill-id> | delete <skill-id> [--force] [--unassign-only] | file list <skill-id> | file read <skill-id> <path> | file write <skill-id> <path> | file delete <skill-id> <path>
---

# Skill Editor Skill

This skill provides full management for skills assigned to the current environment:
- Skill-level operations: list, view, create, update, delete, and unassign
- File-level operations: list, read, create/update, and delete for supporting files

Use this when users want direct control over skill behavior and skill file contents.

## Scope And Guardrails

- This skill can only modify non-read-only skills that are assigned to the current environment.
- System skills and read-only imported skills are blocked by the API.
- Use explicit user intent for destructive operations (`delete` at skill level, recursive directory deletion at file level).
- If user intent is already clear and explicit, execute directly; do not add unnecessary confirmation loops.

## Available Commands

### 1. List Skills (`/skill-editor list`)

List editable skills assigned to the current environment.

### 2. View Skill (`/skill-editor view <skill-id>`)

Fetch skill metadata and body from `SKILL.md`, plus top-level supporting entries.

### 3. Create Skill (`/skill-editor create <skill-id>`)

Create a new skill with required fields:
- `id`
- `name`
- `description`
- `body`

Optional:
- `allowed-tools`
- `model`
- `argument-hint`
- `assignToEnvironment` (default `true`)

### 4. Update Skill (`/skill-editor update <skill-id>`)

Patch one or more fields on `SKILL.md` frontmatter/body:
- `name`
- `description`
- `body`
- `allowed-tools`
- `model`
- `argument-hint`

### 5. Delete Or Unassign Skill (`/skill-editor delete <skill-id> [--force] [--unassign-only]`)

Two supported modes:
- `delete` (default): remove the skill directory and unassign it from environments
- `unassign`: remove the skill from only the current environment, keep files on disk

Rules:
- If deleting a skill that is assigned to other environments, `force=true` is required.
- Without `force`, delete is limited to the current environment.

### 6. File Operations

- List files from skill details: `/skill-editor file list <skill-id>`
- Read file: `/skill-editor file read <skill-id> <path>`
- Write file: `/skill-editor file write <skill-id> <path>`
- Delete file or directory: `/skill-editor file delete <skill-id> <path>`

Notes:
- `PUT` creates parent directories automatically.
- `DELETE` supports files and directories (directories are recursive).
- `SKILL.md` must be modified via skill update (`PATCH /skills/:skillId`) and cannot be deleted via file delete endpoint.

## How It Works

This skill uses the task-scoped skill management API.

### Environment Variables

- `CODERFLOW_SERVER_URL` - Base URL for CoderFlow server
- `TASK_ID` - Task identifier used for auth (`X-Task-Id`)

### API Endpoints

- `GET /api/skill-management/skills` - List editable skills
- `POST /api/skill-management/skills` - Create a skill
- `GET /api/skill-management/skills/:skillId` - Get skill details
- `PATCH /api/skill-management/skills/:skillId` - Update skill
- `DELETE /api/skill-management/skills/:skillId` - Delete or unassign skill (`mode`, `force`)
- `GET /api/skill-management/skills/:skillId/files/*` - Read supporting file
- `PUT /api/skill-management/skills/:skillId/files/*` - Create/update supporting file
- `DELETE /api/skill-management/skills/:skillId/files/*` - Delete supporting file or directory

## Skill Structure

Each skill is a directory under `skills/<skill-id>/` containing:
1. `SKILL.md` (required)
2. Supporting files/directories (optional)

### SKILL.md Frontmatter

```yaml
---
name: Display Name
description: Brief description
argument-hint: optional argument hints
model: optional model override
allowed-tools:
  - Read
  - Write
  - Bash
---
```

### SKILL.md Body

The body contains the operative instructions used by the AI.

## Implementation

### List Skills

```bash
curl -s "${CODERFLOW_SERVER_URL}/api/skill-management/skills" \
  -H "X-Task-Id: ${TASK_ID}"
```

### View Skill

```bash
curl -s "${CODERFLOW_SERVER_URL}/api/skill-management/skills/<skill-id>" \
  -H "X-Task-Id: ${TASK_ID}"
```

### Create Skill

```bash
curl -s -X POST "${CODERFLOW_SERVER_URL}/api/skill-management/skills" \
  -H "Content-Type: application/json" \
  -H "X-Task-Id: ${TASK_ID}" \
  -d '{
    "id": "db-migration",
    "name": "Database Migration",
    "description": "Run and validate database migrations",
    "body": "# Database Migration Skill\\n\\nGuide the user through...",
    "allowed-tools": ["Bash", "Read", "Write"],
    "assignToEnvironment": true
  }'
```

### Update Skill

```bash
curl -s -X PATCH "${CODERFLOW_SERVER_URL}/api/skill-management/skills/<skill-id>" \
  -H "Content-Type: application/json" \
  -H "X-Task-Id: ${TASK_ID}" \
  -d '{
    "description": "Updated description",
    "body": "# Updated Skill\\n\\n..."
  }'
```

### Delete Skill (Current Environment)

```bash
curl -s -X DELETE "${CODERFLOW_SERVER_URL}/api/skill-management/skills/<skill-id>" \
  -H "X-Task-Id: ${TASK_ID}"
```

### Force Delete Skill From All Environments

```bash
curl -s -X DELETE "${CODERFLOW_SERVER_URL}/api/skill-management/skills/<skill-id>?force=true" \
  -H "X-Task-Id: ${TASK_ID}"
```

### Unassign Skill Only (Keep Files)

```bash
curl -s -X DELETE "${CODERFLOW_SERVER_URL}/api/skill-management/skills/<skill-id>?mode=unassign" \
  -H "X-Task-Id: ${TASK_ID}"
```

### Read Supporting File

```bash
curl -s "${CODERFLOW_SERVER_URL}/api/skill-management/skills/<skill-id>/files/<path>" \
  -H "X-Task-Id: ${TASK_ID}"
```

### Write Supporting File

```bash
curl -s -X PUT "${CODERFLOW_SERVER_URL}/api/skill-management/skills/<skill-id>/files/<path>" \
  -H "Content-Type: application/json" \
  -H "X-Task-Id: ${TASK_ID}" \
  -d '{
    "content": "# Examples\\n\\n..."
  }'
```

### Delete Supporting File Or Directory

```bash
curl -s -X DELETE "${CODERFLOW_SERVER_URL}/api/skill-management/skills/<skill-id>/files/<path>" \
  -H "X-Task-Id: ${TASK_ID}"
```

## Important Notes

1. Preserve valid frontmatter when updating `SKILL.md`.
2. Prefer precise file paths for file operations (including nested paths).
3. `SKILL.md` updates must go through skill update endpoint, not file write endpoint.
4. Skill deletions can affect multiple environments when `force=true`; call this out before execution.
5. If skill assignment or visibility behavior changes, verify with a follow-up list/view call.
