---
name: skillify
description: "Create custom reusable skills from conversation patterns or described workflows"
when_to_use: "Use when user wants to create a skill, automate a workflow, save a repeatable process, or says 'make this a skill'"
---

# Skillify — Create Custom Skills

## Goal
Help the user create a reusable skill (SKILL.md file) and register it for immediate use.

## Step 1: Understand Intent

Ask the user:
- "What do you want to automate?"
- "Is this based on something we just did, or a new workflow?"

If based on conversation history, review the recent tool calls to extract the pattern.

## Step 2: Interview (3-5 questions)

Use AskUserQuestion (if available) or direct questions:

1. **Name**: "What should this skill be called?"
   - Generate slug: lowercase, hyphens only, letters/numbers, start with letter, max 50 chars
   - Examples: "Competitor Analysis" → `competitor-analysis`, "竞品分析" → `competitor-analysis`
   - **Always use English for slug, even if name is in Chinese**

2. **Trigger**: "When should this skill activate? Give me example phrases."

3. **Arguments**: "What inputs does it need each time?" (e.g., keyword, region, URL)

4. **Config**: "Does it need any API keys or credentials?" (most skills don't)

5. **Output**: "Should it produce a file, display results, or both?"

## Step 3: Generate SKILL.md

Create the file following this template exactly:

```
---
name: {slug}
description: "{one-line description in the user's language}"
when_to_use: "{trigger phrases as a sentence}"
---

# {Display Name}

## Goal
{Clear statement of what this skill accomplishes}

## Inputs
- `$arg1`: {description}
- `$arg2`: {description}

## Steps

### 1. {First Step}
{Specific instructions — use exact CLI commands where possible}

**Success criteria**: {How to verify this step succeeded}

### 2. {Second Step}
...

### N. {Final Step — Output}
{Generate report / display results / write file}

**Success criteria**: {Final deliverable verification}
```

**Rules:**
- Every step MUST have **Success criteria**
- Use `$arg_name` for referencing inputs (this is a prompt convention, not a template system)
- Be specific: include exact CLI commands (e.g., `scout search "$keyword"`)
- If a step uses a known skill's CLI, include the full command syntax
- Keep total content under 100KB
- Frontmatter: only use `name`, `description`, `when_to_use` (other fields are for future use)

## Step 4: Preview & Confirm

Show the complete SKILL.md to the user:

"Here's your new skill. Review it and let me know if you want changes:"

Display the full content. Wait for confirmation. If changes requested, modify and show again.

## Step 5: Save

On confirmation:

1. Create directory and write file:
```bash
mkdir -p /home/aiuser/.claude/skills/{slug}
```
Then use Write tool: `/home/aiuser/.claude/skills/{slug}/SKILL.md`

2. Register with registry:
```bash
optima-skills-cli skill create --slug "{slug}" --name "{name}" --description "{description}" --file "/home/aiuser/.claude/skills/{slug}/SKILL.md"
```

3. Parse the JSON output. If it contains an `id` field, creation succeeded.

4. Tell the user: "Skill '{name}' created! Try it by saying: '{trigger phrase}'"

## Step 6: Error Handling

- **CLI outputs `TOKEN_EXPIRED`**: "注册失败（token 过期），但 skill 在当前会话可用。刷新页面后重试。"
- **CLI outputs error with `slug already exists`**: Suggest alternative slug, retry with new slug.
- **CLI outputs other error**: "Skill 保存到本地成功，但注册到云端失败。当前会话可正常使用。"
- **Write tool fails**: Inform user and abort.
- **CLI hangs (10s timeout)**: CLI will auto-abort. Tell user: "注册超时，但 skill 在当前会话可用。"
