CLI Reference

Complete command reference for the kp CLI tool.

kp init

Create a new Knowledge Pack with interactive setup.

Usage

kp init [OPTIONS] [NAME]

Arguments

[NAME] Directory name (default: current directory ".")

Options

-t, --template Template: minimal, standard (default: standard)
-l, --language Language: en, es (default: en)
--no-git Don't initialize Git repository
-f, --force Overwrite if directory exists
--yes Skip interactive prompts, use defaults

Examples

# Interactive mode
kp init

# Create in specific directory
kp init my-knowledge

# Spanish templates, non-interactive
kp init -l es --yes

# Minimal template
kp init -t minimal my-project

kp validate

Validate pack structure and schemas.

Usage

kp validate [OPTIONS] [PATH]

Options

-s, --strict Treat warnings as errors
-f, --format Output format: text, json, github (default: text)
--fix Auto-fix simple issues

Examples

# Validate current directory
kp validate

# Strict mode for CI
kp validate --strict

# JSON output for automation
kp validate -f json

kp bundle

Generate a single file optimized for AI context windows. This is the primary way to feed your knowledge pack to an AI.

Usage

kp bundle [OPTIONS] [PATH]

Options

-o, --output Output file (prints to stdout if omitted)
--max-tokens Maximum tokens to include (truncates if exceeded)
--raw Include full document contents (not just summaries)
-f, --format Output format: markdown, xml (default: markdown)

Examples

# Print to stdout (pipe to clipboard)
kp bundle | pbcopy

# Save to file
kp bundle -o context.md

# Full content, XML format
kp bundle --raw -f xml -o context.xml

# Limit to 50k tokens
kp bundle --max-tokens 50000 -o context.md

kp context

Get relevant context for a specific topic.

Usage

kp context [OPTIONS] <TOPIC>

Options

-p, --path Path to the pack (default: .)
-d, --depth Depth of relations to include (default: 1)
-m, --max-files Maximum files to return (default: 10)
-f, --format Output format: list, json, prompt (default: list)
--include-content Include file contents in output

Examples

# Find auth-related docs
kp context authentication

# Include related topics
kp context api --depth 2

# JSON with content
kp context deploy -f json --include-content

kp stats

Show pack statistics.

Usage

kp stats [OPTIONS] [PATH]

Options

-f, --format Output format: text, json (default: text)

kp export

Export pack in various formats.

Usage

kp export <FORMAT> [OPTIONS]

Formats

json Full pack as JSON
yaml Full pack as YAML
single-md All docs in one Markdown file
html Static HTML site

Examples

kp export json -o pack.json
kp export single-md -o docs.md
kp export html -o site/

kp index

Generate or update indices (topics, glossary, relations).

Options

--only Only update specific index: topics, glossary, relations
--dry-run Preview changes without applying
-f, --force Force regeneration

kp lint

Check style and formatting issues.

Options

--fix Auto-fix issues
--errors-only Only show errors, not warnings

kp describe

Get pack description optimized for AI consumption.

Options

-f, --format Output format: text, json, yaml (default: json)
-s, --stats Include statistics

kp update

Update kp to the latest version.

Options

--check Check for updates without installing

kp completions

Generate shell completions.

Usage

kp completions <SHELL>

Shells

bash, zsh, fish, powershell, elvish

Examples

# Zsh
kp completions zsh > ~/.zfunc/_kp

# Bash
eval "$(kp completions bash)"

# Fish
kp completions fish > ~/.config/fish/completions/kp.fish

โš ๏ธ EXPERIMENTAL: These features may change or be removed.

kp ai

AI-powered analysis commands. Requires OPENAI_API_KEY or ANTHROPIC_API_KEY.

Subcommands

suggest Find documentation gaps and suggest improvements
summarize Generate document summaries
review Review document quality

Examples

# Set API key first
export OPENAI_API_KEY=sk-...

# Find gaps
kp ai suggest --gaps

# Summarize a doc
kp ai summarize docs/architecture.md

# Review quality
kp ai review docs/api.md