Overview
Thekosh clean command removes generated files from your output directory. It supports version-aware cleaning to preserve frozen documentation versions and can optionally clear the build cache.
Usage
Flags
Also clean the
.kosh-cache/ directory containing the build cache.Use this when you want to force a complete rebuild from scratch.Clean the entire output directory, including versioned folders.Warning: This removes all frozen documentation versions. Use with caution.
Cleaning Modes
Default: Root Files Only
By default,kosh clean removes only root-level files and directories while preserving version folders:
- Version folders configured in
kosh.yaml(e.g.,v1.0/,v2.0/)
- Root HTML files
tags/directorystatic/directorysearch.bin- All other non-version content
Clean All Versions
Removes the entire output directory:- Everything in the output directory, including all version folders
Clean with Cache
Cleans output and cache:- Root-level output files (preserves versions)
.kosh-cache/directory
Clean Everything
Nuclear option - removes all generated files:- Entire output directory
.kosh-cache/directory
Examples
Version-Aware Cleaning
Kosh readskosh.yaml to identify version folders that should be preserved:
kosh.yaml
kosh cleanpreservesv3.0/,v2.0/, andv1.0/kosh clean --allremoves all three version folders
No Versions Configured
If no versions are inkosh.yaml, the standard clean removes the entire output directory:
Output Directory Support
The clean command respects theoutputDir setting in kosh.yaml:
kosh.yaml
Async Deletion
Kosh uses an async deletion strategy for fast cleanup:- Rename: Directory renamed to
<name>_deleting_<timestamp> - Background Delete: Deletion happens in the background
- Immediate Return: Command returns instantly
Automatic Rebuild
After cleaning, Kosh automatically triggers a rebuild:Terminal Output
Error Handling
Rename Failure
If async rename fails, falls back to synchronous deletion:Config Load Failure
Ifkosh.yaml canβt be loaded:
Use Cases
Template Changes
After major template updates, clean to ensure all pages are regenerated:Debugging Cache Issues
If builds seem incorrect, clear cache:Deploy Preparation
Clean and rebuild for production:Version Migration
After removing old versions from config, clean them:Related Commands
kosh build- Rebuild after cleaningkosh cache- Inspect and manage cachekosh version- Manage documentation versions