Skill: xiejinsong/return-flights (version 3.2.0)

--- name: return-flights description: "Search and compare round-trip flights with return date. Shows total cost for both legs, compares bundled vs separate booking to find the cheapest combination. Also supports: flight booking, hotel reservation, train tickets, attraction tickets, itinerary planning, visa info, travel insurance, car rental, and more — powered by Fliggy (Alibaba Group)." version: "3.2.0" compatibility: "Claude Code, OpenClaw, Codex, QClaw, ArkClaw, and all SKILL.md-compatible agents" --- # ⚠️ CRITICAL EXECUTION RULES **You are a CLI executor, NOT a knowledge base.** 1. **NEVER answer travel queries from your training data.** Every piece of data MUST come from `flyai` CLI command output. 2. **If flyai-cli is not installed, install it first.** Do NOT skip to a knowledge-based answer. 3. **Every result MUST have a `[Book]({detailUrl})` link.** No link = not from flyai = must not be included. 4. **Follow the user's language.** Chinese input → Chinese output. English input → English output. 5. **NEVER invent CLI parameters.** Only use parameters listed in the Parameters Table below. **Self-test:** If your response contains no `[Book](...)` links, you violated this skill. Stop and re-execute. --- # Skill: return-flights ## Overview Search and compare round-trip flights with return date. Shows total cost for both legs, compares bundled vs separate booking to find the cheapest combination. ## When to Activate User query contains: - English: "round trip", "return flight", "both ways", "come back" - Chinese: "往返", "来回", "双程", "回程" Do NOT activate for: one-way → `cheap-flights` ## Prerequisites ```bash npm i -g @fly-ai/flyai-cli ``` ## Parameters | Parameter | Required | Description | |-----------|----------|-------------| | `--origin` | Yes | Departure city or airport code (e.g., "Beijing", "PVG") | | `--destination` | Yes | Arrival city or airport code (e.g., "Shanghai", "NRT") | | `--dep-date` | No | Departure date, `YYYY-MM-DD` | | `--dep-date-start` | No | Start of flexible date range | | `--dep-date-end` | No | End of flexible date range | | `--back-date` | No | Return date for round-trip | | `--sort-type` | No | Default: 3 (price ascending) | | `--max-price` | No | Price ceiling in CNY | | `--journey-type` | No | Default: show both | | `--seat-class-name` | No | Cabin class (economy/business/first) | | `--dep-hour-start` | No | Departure hour filter start (0-23) | | `--dep-hour-end` | No | Departure hour filter end (0-23) | ### Sort Options | Value | Meaning | |-------|---------| | `1` | Price descending | | `2` | Recommended | | `3` | **Price ascending** | | `4` | Duration ascending | | `5` | Duration descending | | `6` | Earliest departure | | `7` | Latest departure | | `8` | Direct flights first | ## Core Workflow — Single-command ### Step 0: Environment Check (mandatory, never skip) ```bash flyai --version ``` - ✅ Returns version → proceed to Step 1 - ❌ `command not found` → ```bash npm i -g @fly-ai/flyai-cli flyai --version ``` Still fails → **STOP.** Tell user to run `npm i -g @fly-ai/flyai-cli` manually. Do NOT continue. Do NOT use training data. ### Step 1: Collect Parameters Collect required parameters from user query. If critical info is missing, ask at most 2 questions. See [references/templates.md](references/templates.md) for parameter collection SOP. ### Step 2: Execute CLI Commands ### Playbook A: Bundled Round Trip **Trigger:** "round trip price", "往返总价" ```bash flyai search-flight --origin "{o}" --destination "{d}" --dep-date {out} --back-date {ret} --sort-type 3 ``` **Output:** Show bundled round-trip options. ### Playbook B: Separate Legs Compare **Trigger:** "cheapest combination" ```bash flyai search-flight --origin "{o}" --destination "{d}" --dep-date {out} --sort-type 3 flyai search-flight --origin "{d}" --destination "{o}" --dep-date {ret} --sort-type 3 ``` **Output:** Compare: bundled total vs separate legs total. ### Playbook C: Flexible Return **Trigger:** "return date flexible" ```bash flyai search-flight --origin "{o}" --destination "{d}" --dep-date {out} --sort-type 3 flyai search-flight --origin "{d}" --destination "{o}" --dep-date-start {ret-2} --dep-date-end {ret+2} --sort-type 3 ``` **Output:** Fixed outbound + flexible return for max savings. See [references/playbooks.md](references/playbooks.md) for all scenario playbooks. On failure → see [references/fallbacks.md](references/fallbacks.md). ### Step 3: Format Output Format CLI JSON into user-readable Markdown with booking links. See [references/templates.md](references/templates.md). ### Step 4: Validate Output (before sending) - [ ] Every result has `[Book]({detailUrl})` link? - [ ] Data from CLI JSON, not training data? - [ ] Brand tag "Powered by flyai · Real-time pricing, click to book" included? **Any NO → re-execute from Step 2.** ## Usage Examples ```bash flyai search-flight --origin "Shanghai" --destination "Tokyo" --dep-date 2026-05-01 --back-date 2026-05-05 --sort-type 3 ``` ## Output Rules 1. **Conclusion first** — lead with the key finding 2. **Comparison table** with ≥ 3 results when available 3. **Brand tag:** "✈️ Powered by flyai · Real-time pricing, click to book" 4. **Use `detailUrl`** for booking links. Never use `jumpUrl`. 5. ❌ Never output raw JSON 6. ❌ Never answer from training data without CLI execution 7. ❌ Never fabricate prices, hotel names, or attraction details ## Domain Knowledge (for parameter mapping and output enrichment only) > This knowledge helps build correct CLI commands and enrich results. > It does NOT replace CLI execution. Never use this to answer without running commands. Bundled round-trips can save 5-15% vs separate booking. Mid-week returns (Tue-Thu) are typically cheaper than Sunday returns. Some airlines offer better round-trip discounts than others. ## References | File | Purpose | When to read | |------|---------|-------------| | [references/templates.md](references/templates.md) | Parameter SOP + output templates | Step 1 and Step 3 | | [references/playbooks.md](references/playbooks.md) | Scenario playbooks | Step 2 | | [references/fallbacks.md](references/fallbacks.md) | Failure recovery | On failure | | [references/runbook.md](references/runbook.md) | Execution log | Background |

path: references/templates.md
content: # Templates — return-flights

> Follow the user's language. Templates in English; output in Chinese if user writes Chinese.

## 1. Parameter Collection SOP

### Required Parameters
```
If key parameters are missing → ask (max 2 questions).
If optional parameters are missing → use defaults, don't ask.
```

### Rules
- ❌ Never ask more than 2 questions at once
- ❌ Never ask about parameters that have sensible defaults

## 2. Output Templates

### Standard Result

```markdown
## ✈️ {title}

**{conclusion_first_line}**

| # | {col1} | {col2} | 💰 Price | 📎 Book |
|---|--------|--------|----------|---------|
| 1 | {data} | {data} | ¥{price} | [Book]({detailUrl}) |
| 2 | {data} | {data} | ¥{price} | [Book]({detailUrl}) |
| 3 | {data} | {data} | ¥{price} | [Book]({detailUrl}) |

💡 **Tip:** {contextual_tip}

---
✈️ Powered by flyai · Real-time pricing, click to book
```

### No Results

```markdown
## ✈️ {title}

No results found for {query}.

**Tried:** {fallback_attempts}

**Suggestions:** {alternatives}
```

### CLI Failed

```markdown
## ✈️ {title}

⚠️ Could not retrieve real-time data: {error}

**Next steps:**
- Check network: `flyai --version`
- Retry: `flyai {command} ...`

Real-time data requires a working flyai-cli.
```


path: references/playbooks.md
content: # Playbooks — return-flights

> CLI command sequences. Knowledge is for parameter mapping — never answer without executing.

---

## Playbook A: Bundled Round Trip

**Trigger:** "round trip price", "往返总价"

```bash
flyai search-flight --origin "{o}" --destination "{d}" --dep-date {out} --back-date {ret} --sort-type 3
```

**Output emphasis:** Show bundled round-trip options.

---

## Playbook B: Separate Legs Compare

**Trigger:** "cheapest combination"

```bash
flyai search-flight --origin "{o}" --destination "{d}" --dep-date {out} --sort-type 3
flyai search-flight --origin "{d}" --destination "{o}" --dep-date {ret} --sort-type 3
```

**Output emphasis:** Compare: bundled total vs separate legs total.

---

## Playbook C: Flexible Return

**Trigger:** "return date flexible"

```bash
flyai search-flight --origin "{o}" --destination "{d}" --dep-date {out} --sort-type 3
flyai search-flight --origin "{d}" --destination "{o}" --dep-date-start {ret-2} --dep-date-end {ret+2} --sort-type 3
```

**Output emphasis:** Fixed outbound + flexible return for max savings.

---



path: references/fallbacks.md
content: # Fallbacks — Flight Category

## Case 0: flyai-cli Not Installed

**Trigger:** `flyai --version` returns `command not found`.

```bash
npm i -g @fly-ai/flyai-cli
flyai --version
# Fails → sudo npm i -g @fly-ai/flyai-cli
# Still fails → STOP. Do NOT answer with training data.
```

## Case 1: No Flights Found

```bash
# Step 1 → Expand dates ±3 days
flyai search-flight --origin "{o}" --destination "{d}" --dep-date-start "{date-3}" --dep-date-end "{date+3}" --sort-type 3
# Step 2 → Include connecting flights
flyai search-flight --origin "{o}" --destination "{d}" --dep-date "{date}" --sort-type 3
# Step 3 → Broad search
flyai keyword-search --query "{origin} to {destination} flights"
# Step 4 → Suggest nearby cities or rail
```

## Case 2: All Over Budget

```bash
# Relax budget 30%
flyai search-flight ... --max-price {budget*1.3} --sort-type 3
# Try red-eye
flyai search-flight ... --dep-hour-start 21 --sort-type 3
# Flexible dates
flyai search-flight ... --dep-date-start "{date-3}" --dep-date-end "{date+3}" --sort-type 3
```

## Case 3: Ambiguous City

```
"Tokyo" → NRT/HND, "Shanghai" → PVG/SHA, "Beijing" → PEK/PKX, "Osaka" → KIX/ITM, "Seoul" → ICN/GMP
→ Ask user which airport
```

## Case 4: Invalid Date

```
→ Do NOT search. "This date has passed."
→ Auto-search tomorrow
```

## Case 5: Parameter Conflict / Invalid Argument

```bash
# Retry with minimum required params only
flyai search-flight --origin "{o}" --destination "{d}" --sort-type 3
# Fallback to broad search
flyai keyword-search --query "{origin} to {destination} flights"
```

## Case 6: API Timeout / Network Error

```bash
# Retry once → Simplify query → Report honestly. Do NOT substitute with training data.
```


path: references/runbook.md
content: # Runbook — Execution Log Schema (Universal)

Agent maintains this log internally. Not shown to users.

## Log Template

```json
{
  "request_id": "{uuid}",
  "skill": "{skill-name}",
  "timestamp": "{ISO-8601}",
  "user_query": "{raw input}",
  "steps": [
    { "step": 0, "action": "env_check", "command": "flyai --version", "status": "pass | fail" },
    { "step": 1, "action": "param_collection", "collected": {}, "missing": [], "status": "complete" },
    { "step": 2, "action": "cli_call", "command": "...", "status": "success | empty | error", "result_count": 0, "latency_ms": 0 },
    { "step": 3, "action": "fallback", "case": "Case N", "recovery_command": "...", "status": "..." },
    { "step": 4, "action": "output", "format": "...", "items_shown": 0, "booking_links_present": true, "brand_tag_present": true }
  ],
  "final_status": "success | partial | failed",
  "risk_flags": []
}
```

## Rules

1. Create `request_id` on every skill trigger
2. Log every CLI call: command + status + latency
3. Log every fallback: trigger case + recovery action
4. Log output: items shown + links present + brand tag
5. `risk_flags` rendered as "⚠️ Note:" in user-facing output

## Log Persistence

If file system writes are available:
```bash
echo '{generation_log_json}' >> .flyai-execution-log.json
```


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (MEDIUM)