npm package: @skill-kit/distill
Description: Distill AI agent conversations into reusable Skills - Part of Skill Kit
Latest version: 1.0.0

# @skill-kit/distill

Distill AI agent conversations into reusable Skills. Part of the Skill Kit ecosystem.

## Installation

```bash
# Using npm
npm install @skill-kit/distill

# Using pnpm
pnpm add @skill-kit/distill

# Using yarn
yarn add @skill-kit/distill
```

## Quick Start

### CLI Usage

```bash
# Distill the most recent session
skill-distill distill --last

# Distill a specific session
skill-distill distill --session ses_abc123

# Add custom prompts
skill-distill distill --last --prompt "Focus on error handling"

# List available sessions
skill-distill list

# Show session details
skill-distill show ses_abc123
```

### Programmatic Usage

```typescript
import { ClaudeSessionLoader, Distiller, SkillGenerator } from '@skill-kit/distill';

// Load a session
const loader = new ClaudeSessionLoader();
const session = await loader.getLatestSession();

// Distill into a skill
const distiller = new Distiller();
const result = await distiller.distill(session, {
  userPrompts: ['Focus on error handling'],
  verbose: true,
});

// Generate SKILL.md
const generator = new SkillGenerator();
const generated = await generator.generate(result.skill, {
  outputDir: './skills',
});

console.log(`Generated: ${generated.skillPath}`);
```

## Features

- **Session Loading**: Read conversation history from Claude Code, Codex CLI, or Cursor
- **Smart Filtering**: Automatically filter out failed attempts and trial-and-error
- **LLM Analysis**: Use Claude to extract intent, steps, and parameters
- **Template Generation**: Generate standard SKILL.md files
- **Validation**: Validate generated skills against best practices

## API Reference

### Session Loaders

```typescript
import { ClaudeSessionLoader, createSessionLoader } from '@skill-kit/distill';

// Create a loader for a specific platform
const loader = createSessionLoader('claude');

// List available sessions
const sessions = await loader.listSessions();

// Get a specific session
const session = await loader.getSession('ses_abc123');

// Get the most recent session
const latest = await loader.getLatestSession();
```

### Distiller

```typescript
import { Distiller } from '@skill-kit/distill';

const distiller = new Distiller();

const result = await distiller.distill(session, {
  userPrompts: ['Focus on security'],  // Additional guidance
  skipFailedFilter: false,              // Filter failed attempts
  verbose: true,                        // Show progress
});

// Result contains:
// - result.skill: The distilled Skill object
// - result.metadata.sessionId: Source session ID
// - result.metadata.tokenUsage: API token usage
// - result.metadata.stepsFiltered: Number of filtered steps
```

### Skill Generator

```typescript
import { SkillGenerator } from '@skill-kit/distill';

const generator = new SkillGenerator();

const result = await generator.generate(skill, {
  outputDir: './skills',
  overwrite: false,
  includeReferences: true,
  includeExamples: false,
});

// Result contains:
// - result.skillPath: Path to generated SKILL.md
// - result.files: All generated files
// - result.validation: Validation results
```

## Configuration

Set your Anthropic API key:

```bash
export ANTHROPIC_API_KEY=sk-ant-xxx
```

## Supported Platforms

| Platform | Status |
|----------|--------|
| Claude Code | Supported |
| Codex CLI | Planned |
| Cursor | Planned |

## License

MIT