---
name: flawed-skill
description: Processes files and generates transformed output with summaries. This skill reads files provided as arguments, identifies key structural sections, applies consistent transformations, and produces a structured summary report. Use when batch-processing multiple files and generating consistent, documented output.
allowed-tools: Read, Glob, Grep, Edit, Write, Bash
argument-hint: file paths or glob patterns to process
---

> This skill follows a 4-stage workflow with developer approval at each stage. The agent reads and proposes; the developer confirms before proceeding.

**Stop after each stage and have work reviewed with the developer.**

---

## Stage 0: Understand and Confirm Inputs

- Ask the developer: "Which files should I process, and what transformations should be applied?"
  - Clarify file paths or glob patterns (e.g., `src/**/*.js`, `config/settings.json`)
  - Confirm the transformation rules (e.g., extract YAML headers, normalize formatting, combine sections)
  - Agree on output format and location
- List the files you will process
- Summarize the transformations to be applied
- **Stop. Wait for developer confirmation before proceeding to Stage 1.**

---

## Stage 1: Gather and Validate Inputs

- Attempt to read each file specified in the inputs
- **If any file cannot be read:** Report the filename and reason (not found, permission denied, etc.). Ask the developer whether to skip it or abort.
- Parse each file's contents and identify the declared key sections (headers, metadata blocks, code sections — as per the transformation rules)
- **Report findings:**
  - Total files to process
  - Sections identified per file
  - Any parsing issues or warnings
- **Stop. Wait for developer confirmation before proceeding to Stage 2.**

---

## Stage 2: Process and Transform

- For each section identified in Stage 1, apply the transformation rules agreed in Stage 0
- **Error handling:**
  - If a transformation cannot be applied (e.g., malformed section), log the error and skip that section with a warning; do not fail the entire file
  - Track all skipped sections and reasons
- Generate an output summary showing:
  - Sections processed
  - Sections skipped (with reasons)
  - Files written to disk
- Write transformed output files to the project directory with clear naming (e.g., `output-{original-filename}`)
- **Stop. Wait for developer confirmation before proceeding to Stage 3.**

---

## Stage 3: Final Report

- Print a summary including:
  - **Files processed:** (count and list)
  - **Sections handled:** (total, successfully transformed)
  - **Sections skipped:** (total, with reason for each)
  - **Output files created:** (list with paths)
  - **Warnings or errors:** (detailed list, if any)
- Ask the developer: "Is this output acceptable? Any adjustments needed?"
- If adjustments are needed, iterate: return to Stage 0 or Stage 2 as appropriate
- **Done.**

---

## Transformation Rules Reference

See `unused-reference.md` for output style guidelines to apply during transformations.

---

## When to Use This Skill

- Processing multiple configuration files with consistent transformations
- Extracting and combining sections from multiple files
- Normalizing formatting across a codebase
- Generating structured reports from file analysis

**Do not use this skill for:**
- Single-file edits (use Edit tool directly)
- Real-time code generation (use coding agents instead)
- Complex logic that requires iterative development
