# Codebase Export - Selected Files

Exported 1 files.

## Structure

```
SKILL.md
```

## Files

### SKILL.md

``````markdown
---
name: codebase-export
description: Package files or folders for another AI to review. Use when the user says "package these files for another AI review", "export this codebase", "create an export for AI review", or similar requests involving preparing code for external AI analysis.
allowed-tools: Bash, Read, Edit, Glob, Grep
---

# Codebase Export Skill

Export code files to a single markdown document for AI review.

## When to Use

Trigger on phrases like:
- "package these files for another AI review"
- "export this folder/codebase"
- "create an export for [AI name] to review"
- "prepare these files for external review"

## How to Export

### Folder Mode (entire directory)

```bash
~/.claude/skills/codebase-export/scripts/export.sh /path/to/folder
~/.claude/skills/codebase-export/scripts/export.sh --name auth-review /path/to/folder
```

Exports all files in the folder. Uses folder name as export name by default, or custom `--name` if provided.

### File-List Mode (specific files)

**IMPORTANT: Always provide `--name` to identify the export!**

```bash
~/.claude/skills/codebase-export/scripts/export.sh --files --name auth-security-review src/auth/*.ts src/middleware/auth.js
```

**CRITICAL - Quote rules:**
- **Globs must be UNQUOTED** (so the shell expands them): `src/*.ts`
- **Paths with spaces must be QUOTED**: `"docs/my file.md"`
- **Always use `--name`** to give exports meaningful, identifiable names

If `--name` is omitted in file-list mode, a random 8-character ID is generated (e.g., `export_a3k9x2m1`) to prevent overwrites.

## Output

- Saved to: `/workspace/downloads/<name>_export.md`
- Returns a download URL: `https://www.tonki.dev/downloads/<name>_export.md`
- Prints summary: files included, files excluded (by reason), export size

## Safety Features

The script automatically:
- **Excludes sensitive file content**: `.env`, `id_rsa`, `*.pem`, `*.key`, credentials, etc.
- **Excludes binary/media content**: images, videos, archives, executables, fonts
- **Detects non-text files**: uses `grep -Iq` to catch binaries without known extensions
- **Enforces size limits**: files >512KB are marked as too-large
- **Ignores common junk folders**: `node_modules`, `dist`, `build`, `.git`, etc.

Files are still listed in the structure, but their content is excluded with a reason.

## After Export

1. **Open the download link** for the user: `~/bin/open <url>`
2. **Add reviewer context block** if requested (see below)

---

## REQUIRED: Add Reviewer Context Block

When the user wants an intro/outro for the reviewing AI, you MUST add a context block that:

1. **Clearly explains:**
   - What this codebase is (app/script/library/etc)
   - What the user is trying to accomplish
   - The environment/runtime assumptions (Node/Python/Bash, OS, deployment target)
   - The main entrypoints and where to start reading
   - Any known constraints, pain points, or suspected bugs
   - What the reviewer should prioritize (security, correctness, architecture, etc)

2. **Explicitly asks the reviewing AI to respond as:**
   - A structured, action-oriented plan
   - Written as instructions to an AI agent who will implement the changes
   - Precise, step-by-step, with commands/paths where relevant
   - Including edge cases + tests
   - Including a checklist of fixes, ordered by impact/risk

### Template to Prepend

Use the Edit tool to prepend this template (filled in) to the export file:

```markdown
# Context for External Reviewer

## What this is
- **Project type:** [app/library/script/CLI tool/etc]
- **What it does:** [1-2 sentence description]
- **Target environment:** [Node.js/Python/Bash/Browser/etc, OS assumptions]

## How it's supposed to work
- **Primary flow:** [main user journey or execution path]
- **Key entrypoints:** [main files to start reading]
- **Inputs/outputs:** [what goes in, what comes out]

## What we need from you

Please respond with:
1. **Findings** (bugs, edge cases, security concerns)
2. **Fix plan** written as **instructions for an AI agent** (step-by-step, action-oriented)
3. **Patch strategy** (what files to change, what to add/remove)
4. **Tests / verification steps** (exact commands + expected outcomes)
5. **Risk notes** (what could break / rollout concerns)

## Constraints / preferences
- Be precise and practical.
- Provide exact file paths and code-level guidance.
- Avoid vague recommendations.

## Specific focus areas
[User's specific concerns: security, performance, correctness, architecture, etc.]

---
```

## Workflow Example

User: "Package the auth folder for another AI to review for security issues"

1. Run the export:
   ```bash
   ~/.claude/skills/codebase-export/scripts/export.sh /path/to/auth
   ```

2. Prepend context block using Edit tool (fill in the template above with specifics about the auth module)

3. Open the download link:
   ```bash
   ~/bin/open https://www.tonki.dev/downloads/auth_export.md
   ```

4. Tell the user the download URL

## Ignored Patterns

**Folders (exact match):** `node_modules`, `dist`, `build`, `__pycache__`, `.git`, `.vscode`, `.idea`, `.next`, `coverage`, `.cache`, `vendor`

**Folders (prefix match):** `.` (hidden), `@` (like @types)

**Sensitive files:** `.env*`, `id_rsa`, `id_ed25519`, `credentials*`, `secrets.*`, `*.pem`, `*.key`, `*.p12`

**Binary extensions:** images, videos, archives, executables, fonts, compiled files, lock files

## Tips

- For large codebases, prefer file-list mode to export only relevant files
- Use glob patterns like `src/**/*.ts` for selective exports (remember: unquoted!)
- The structure section lists relative paths for easy navigation
- Check the summary output for excluded file counts

``````

