Skip to main content
hooksSource-backedReview first Safety Privacy

Doc Auto Generator

Automatically generates or updates project documentation when session ends.

by JSONbored·added 2025-09-19·
HarnessClaude Code
Trigger:Stop
Review first review before installing

Open the source and read safety notes before installing.

Citation facts

Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.

Safety notes
Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.
Privacy notes
Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.
Author
JSONbored
Claim status
unclaimed
Last verified
2025-09-19

Decision playbook

Review trust signals before you adopt

Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.

Compare context
Selected

0

Current score

78

Baseline

Delta

No baseline selected

No major trust-signal divergence detected in the current selection.

Source and provenance checks

Complete

Confirm ownership and provenance before trusting install instructions.

  • Source link availableRequired

    Open the canonical repository and verify ownership.

    Done
  • Source provenance statusRequired

    Marked as source-backed.

    Done
  • Metadata reviewed

    Registry metadata indicates a reviewed listing.

    Done

Safety and privacy checks

Complete

Validate risk disclosures before installation or API wiring.

  • Safety notes presentRequired

    Review the listed safety guidance before running commands.

    Done
  • Privacy notes presentRequired

    Review data handling notes before connecting accounts or secrets.

    Done
  • Trust level risk gateRequired

    Trust level does not block evaluation.

    Done

Package and install checks

Needs review

Check package metadata and artifact integrity signals.

  • Install payload available

    Install or copy payload is available for review.

    Done
  • Package verification flag

    No package verification flag provided.

    Pending
  • Checksum metadata

    No checksum provided for downloaded artifact.

    Pending

Compare-driven decision checks

Needs review

Use compare context to validate trade-offs before adoption.

  • Compare tray has multiple entries

    Add at least one more entry to compare trust differences.

    Pending
  • Baseline comparison available

    No baseline peer selected yet.

    Pending
  • Diverging trust signals identified

    No major trust-signal divergence found.

    Pending

Setup at a glance

CLI install

Copy-ready — paste the snippet to get started.

Install command

Provided

Config snippet

Provided

Copy snippet

Provided

Prerequisites

None

Platforms

1 listed

Difficulty

0/100

Adoption plan

Balanced adoption plan

Current risk score 16/100. Use staged verification before broader rollout.

Risk 16

Pre-adoption checks

Validate source and review signals before any execution.

  • Confirm source provenanceRequired

    Source URL/provenance metadata is present.

    Done
  • Confirm metadata review state

    Listing has review metadata.

    Done
  • Verify install payload

    Install/config payload exists and can be inspected.

    Done

Security checks

Confirm safety, privacy, and package integrity signals.

  • Review safety notesRequired

    Safety notes are present.

    Done
  • Review privacy notesRequired

    Privacy notes are present.

    Done
  • Verify package integrity metadata

    No package verification/checksum metadata.

    Pending

Rollout

Adopt in controlled steps based on the selected plan.

  • Run in isolated sandbox firstRequired

    Use a constrained sandbox and observe behavior across multiple tasks.

    Pending
  • Roll out graduallyRequired

    Roll out to a small cohort before wider usage.

    Pending
  • Set monitoring and fallback

    Define rollback path and monitor errors after adoption.

    Pending

Evidence readiness

Evidence readiness matrix · balanced

Required evidence gates are covered (5/6 signals complete).

Risk 15

Source provenance

Present

Source repository/provenance is listed.

Required in this preset

Metadata review

Present

Review metadata is present.

Required in this preset

Safety notes

Present

Safety notes are present.

Required in this preset

Privacy notes

Present

Privacy notes are present.

Optional in this preset

Package integrity

Missing

Package integrity metadata is missing.

Optional in this preset

Install payload

Present

Install payload is available.

Required in this preset

Required evidence gates are covered for this preset.

Decision timeline

Decision timeline · balanced

5/6 steps complete with no blocking gaps for this preset.

Risk 14

triage

Confirm source provenanceRequired

Source/provenance metadata is available.

Done

triage

Check metadata review statusRequired

Review metadata is available.

Done

verify

Review safety notesRequired

Safety notes are available.

Done

verify

Review privacy notes

Privacy notes are available.

Done

verify

Validate package integrity metadata

Package integrity metadata is missing.

Pending

rollout

Verify install payload and commandsRequired

Install payload is available.

Done

No required blockers for this timeline preset.

Safety & privacy surface

Safety & privacy surface

1 safety and 1 privacy notes across 2 risk areas. Review closely: credentials & tokens, permissions & scopes.

2 areas
  • SafetyPermissions & scopesRuns automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.
  • PrivacyCredentials & tokensReceives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.

Safety notes

  • Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.

Privacy notes

  • Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.

Schema details

Install type
cli
Reading time
1 min
Difficulty score
0
Troubleshooting
Yes
Breaking changes
No
Runtime and command metadata
Trigger
Stop
Script language
bash
Script body
#!/usr/bin/env bash

echo "📚 Starting documentation generation..." >&2

# Create docs directory if it doesn't exist
mkdir -p ./docs

# Generate timestamp for session
SESSION_DATE=$(date +"%Y-%m-%d")
SESSION_TIME=$(date +"%H:%M:%S")
TIMESTAMP="$SESSION_DATE $SESSION_TIME"

# Count modified files if in git repo
MODIFIED_COUNT=0
if command -v git &> /dev/null && git rev-parse --git-dir > /dev/null 2>&1; then
  MODIFIED_COUNT=$(git diff --name-only 2>/dev/null | wc -l | xargs)
fi

echo "📊 Session summary: $MODIFIED_COUNT files modified" >&2

# JavaScript/TypeScript projects
if [ -f "package.json" ]; then
  echo "🟡 JavaScript/TypeScript project detected" >&2
  
  # Try TypeDoc first for TypeScript projects
  if ls *.ts src/**/*.ts 2>/dev/null | head -1 > /dev/null; then
    if command -v npx &> /dev/null && npx typedoc --version &> /dev/null 2>&1; then
      echo "📝 Generating TypeDoc documentation..." >&2
      npx typedoc --out ./docs/api src 2>/dev/null && echo "✅ TypeDoc documentation generated" >&2
    else
      echo "💡 Install TypeDoc for better TypeScript docs: npm install -g typedoc" >&2
    fi
  fi
  
  # Try JSDoc for JavaScript projects
  if [ -f "jsdoc.json" ] || [ -f "jsdoc.conf.json" ]; then
    if command -v npx &> /dev/null && npx jsdoc --version &> /dev/null 2>&1; then
      echo "📝 Generating JSDoc documentation..." >&2
      npx jsdoc -c jsdoc.json 2>/dev/null || npx jsdoc -c jsdoc.conf.json 2>/dev/null
      [ $? -eq 0 ] && echo "✅ JSDoc documentation generated" >&2
    fi
  fi
  
  # Try documentation.js as fallback
  if command -v npx &> /dev/null; then
    if npx documentation --version &> /dev/null 2>&1; then
      echo "📝 Generating documentation.js docs..." >&2
      npx documentation build './src/**/*.js' -f md -o ./docs/api.md 2>/dev/null
      [ $? -eq 0 ] && echo "✅ Documentation.js docs generated" >&2
    fi
  fi
fi

# Python projects
if [ -f "setup.py" ] || [ -f "pyproject.toml" ] || [ -f "requirements.txt" ]; then
  echo "🐍 Python project detected" >&2
  
  # Try pdoc for simple API docs
  if command -v pdoc &> /dev/null; then
    echo "📝 Generating pdoc documentation..." >&2
    pdoc --html --output-dir ./docs . 2>/dev/null && echo "✅ pdoc documentation generated" >&2
  elif command -v python &> /dev/null; then
    if python -c "import pdoc" 2>/dev/null; then
      echo "📝 Generating pdoc documentation..." >&2
      python -m pdoc --html --output-dir ./docs . 2>/dev/null && echo "✅ pdoc documentation generated" >&2
    fi
  fi
  
  # Try Sphinx for comprehensive docs
  if [ -f "docs/conf.py" ]; then
    if command -v sphinx-build &> /dev/null; then
      echo "📝 Building Sphinx documentation..." >&2
      sphinx-build -b html docs ./docs/_build 2>/dev/null && echo "✅ Sphinx documentation built" >&2
    fi
  elif command -v sphinx-quickstart &> /dev/null; then
    echo "📝 Setting up Sphinx documentation..." >&2
    PROJECT_NAME=$(basename "$(pwd)")
    sphinx-quickstart -q -p "$PROJECT_NAME" -a "Claude" --ext-autodoc --makefile docs 2>/dev/null
    [ $? -eq 0 ] && echo "✅ Sphinx project initialized in docs/" >&2
  fi
fi

# Go projects
if [ -f "go.mod" ]; then
  echo "🐹 Go project detected" >&2
  
  if command -v go &> /dev/null; then
    echo "📝 Generating Go documentation..." >&2
    go doc -all > ./docs/api.txt 2>/dev/null && echo "✅ Go documentation generated" >&2
    
    # Try godoc if available
    if command -v godoc &> /dev/null; then
      echo "💡 Run 'godoc -http=:6060' to serve documentation locally" >&2
    fi
  fi
fi

# Rust projects
if [ -f "Cargo.toml" ]; then
  echo "🦀 Rust project detected" >&2
  
  if command -v cargo &> /dev/null; then
    echo "📝 Generating Rust documentation..." >&2
    cargo doc --no-deps --target-dir ./docs/rust 2>/dev/null && echo "✅ Rust documentation generated" >&2
  fi
fi

# Update CHANGELOG.md
echo "📝 Updating changelog..." >&2
CHANGELOG_ENTRY="## Session $SESSION_DATE at $SESSION_TIME\n\n- Files modified: $MODIFIED_COUNT\n- Documentation updated automatically\n- Session completed\n\n"

if [ -f "CHANGELOG.md" ]; then
  # Prepend to existing changelog
  echo -e "$CHANGELOG_ENTRY$(cat CHANGELOG.md)" > CHANGELOG.md.tmp && mv CHANGELOG.md.tmp CHANGELOG.md
else
  # Create new changelog
  echo -e "# Changelog\n\n$CHANGELOG_ENTRY" > CHANGELOG.md
fi

echo "✅ Changelog updated" >&2

# Generate or update README.md if it doesn't exist
if [ ! -f "README.md" ]; then
  echo "📝 Creating basic README.md..." >&2
  PROJECT_NAME=$(basename "$(pwd)")
  cat > README.md << EOF
# $PROJECT_NAME

Project documentation generated automatically.

## Documentation

API documentation can be found in the \`docs/\` directory.

## Last Updated

$TIMESTAMP
EOF
  echo "✅ README.md created" >&2
fi

# Create documentation index
echo "📋 Creating documentation index..." >&2
cat > ./docs/index.md << EOF
# Project Documentation

Generated on: $TIMESTAMP

## Available Documentation

EOF

# List available documentation files
find ./docs -name "*.md" -o -name "*.html" -o -name "index.html" 2>/dev/null | while read -r file; do
  echo "- [$(basename "$file")]($(basename "$file"))" >> ./docs/index.md
done

echo "" >&2
echo "📚 Documentation generation completed!" >&2
echo "📁 Check the ./docs/ directory for generated documentation" >&2
echo "📋 Documentation index available at ./docs/index.md" >&2

exit 0
Full copyable content
{
  "hooks": {
    "stop": {
      "script": "./.claude/hooks/documentation-auto-generator-on-stop.sh"
    }
  }
}

About this resource

Features

  • Automatic API documentation generation for multiple languages (TypeScript, JavaScript, Python, Go, Rust) with TypeDoc 0.26.0+, JSDoc 4.0.0+, Sphinx 7.0+, pdoc 14.0+, Go doc, and Cargo doc support
  • Changelog updates with session summaries including file modification counts, timestamps, and automatic session tracking for project history
  • Support for JSDoc 4.0.0+, TypeDoc 0.26.0+, Sphinx 7.0+, pdoc 14.0+, documentation.js, and other doc generators with automatic tool detection and configuration
  • Project structure analysis and documentation with automatic detection of project type and appropriate documentation generator selection
  • README file updates and maintenance with automatic generation of basic README.md if missing and project metadata inclusion
  • Multi-format output (HTML, Markdown, PDF) supporting various documentation formats and export options for different use cases
  • Documentation index generation with automatic creation of documentation index files listing all available documentation resources
  • Session-based documentation updates with automatic timestamp tracking and session metadata for documentation versioning

Use Cases

  • Automated API documentation maintenance ensuring API documentation stays synchronized with code changes automatically after each development session
  • End-of-session project documentation updates providing automatic documentation generation when development sessions end, keeping documentation current
  • Multi-language documentation generation supporting TypeScript, JavaScript, Python, Go, and Rust projects with appropriate documentation tools
  • Changelog automation and project tracking maintaining automatic changelog updates with session summaries and file modification tracking
  • Development workflow documentation integration seamlessly integrating documentation generation into development workflows without manual intervention
  • Project onboarding and documentation setup automatically generating initial documentation structure for new projects and maintaining documentation completeness

Installation

  1. Create hooks directory: mkdir -p .claude/hooks
  2. Create hook file: touch .claude/hooks/documentation-auto-generator-on-stop.sh
  3. Make executable: chmod +x .claude/hooks/documentation-auto-generator-on-stop.sh
  4. Add configuration from Hook Configuration section above to .claude/settings.json or ~/.claude/settings.json
  5. Alternative: Use the interactive /hooks command in Claude Code

Config paths

  • Local (not committed): .claude/settings.local.json
  • User settings (global): ~/.claude/settings.json
  • Project-wide (committed): .claude/settings.json

Requirements

  • Claude Code CLI installed
  • Project directory initialized
  • Bash shell available
  • Documentation generator: TypeDoc 0.26.0+ (TypeScript), JSDoc 4.0.0+ (JavaScript), Sphinx 7.0+ or pdoc 14.0+ (Python), Go doc (Go), Cargo doc (Rust)
  • Git repository (optional, for changelog tracking)
  • Runtime environment: Node.js 18+ and npm/yarn/pnpm (for TypeDoc/JSDoc) or Python 3.8+ and pip (for Sphinx/pdoc) or Go toolchain (for Go doc) or Rust toolchain (for Cargo doc) depending on project language

Hook Configuration

{
  "hooks": {
    "stop": {
      "script": "./.claude/hooks/documentation-auto-generator-on-stop.sh"
    }
  }
}

Hook Script

#!/usr/bin/env bash

echo "📚 Starting documentation generation..." >&2

# Create docs directory if it doesn't exist
mkdir -p ./docs

# Generate timestamp for session
SESSION_DATE=$(date +"%Y-%m-%d")
SESSION_TIME=$(date +"%H:%M:%S")
TIMESTAMP="$SESSION_DATE $SESSION_TIME"

# Count modified files if in git repo
MODIFIED_COUNT=0
if command -v git &> /dev/null && git rev-parse --git-dir > /dev/null 2>&1; then
  MODIFIED_COUNT=$(git diff --name-only 2>/dev/null | wc -l | xargs)
fi

echo "📊 Session summary: $MODIFIED_COUNT files modified" >&2

# JavaScript/TypeScript projects
if [ -f "package.json" ]; then
  echo "🟡 JavaScript/TypeScript project detected" >&2

  # Try TypeDoc first for TypeScript projects
  if ls *.ts src/**/*.ts 2>/dev/null | head -1 > /dev/null; then
    if command -v npx &> /dev/null && npx typedoc --version &> /dev/null 2>&1; then
      echo "📝 Generating TypeDoc documentation..." >&2
      npx typedoc --out ./docs/api src 2>/dev/null && echo "✅ TypeDoc documentation generated" >&2
    else
      echo "💡 Install TypeDoc for better TypeScript docs: npm install -g typedoc" >&2
    fi
  fi

  # Try JSDoc for JavaScript projects
  if [ -f "jsdoc.json" ] || [ -f "jsdoc.conf.json" ]; then
    if command -v npx &> /dev/null && npx jsdoc --version &> /dev/null 2>&1; then
      echo "📝 Generating JSDoc documentation..." >&2
      npx jsdoc -c jsdoc.json 2>/dev/null || npx jsdoc -c jsdoc.conf.json 2>/dev/null
      [ $? -eq 0 ] && echo "✅ JSDoc documentation generated" >&2
    fi
  fi

  # Try documentation.js as fallback
  if command -v npx &> /dev/null; then
    if npx documentation --version &> /dev/null 2>&1; then
      echo "📝 Generating documentation.js docs..." >&2
      npx documentation build './src/**/*.js' -f md -o ./docs/api.md 2>/dev/null
      [ $? -eq 0 ] && echo "✅ Documentation.js docs generated" >&2
    fi
  fi
fi

# Python projects
if [ -f "setup.py" ] || [ -f "pyproject.toml" ] || [ -f "requirements.txt" ]; then
  echo "🐍 Python project detected" >&2

  # Try pdoc for simple API docs
  if command -v pdoc &> /dev/null; then
    echo "📝 Generating pdoc documentation..." >&2
    pdoc --html --output-dir ./docs . 2>/dev/null && echo "✅ pdoc documentation generated" >&2
  elif command -v python &> /dev/null; then
    if python -c "import pdoc" 2>/dev/null; then
      echo "📝 Generating pdoc documentation..." >&2
      python -m pdoc --html --output-dir ./docs . 2>/dev/null && echo "✅ pdoc documentation generated" >&2
    fi
  fi

  # Try Sphinx for comprehensive docs
  if [ -f "docs/conf.py" ]; then
    if command -v sphinx-build &> /dev/null; then
      echo "📝 Building Sphinx documentation..." >&2
      sphinx-build -b html docs ./docs/_build 2>/dev/null && echo "✅ Sphinx documentation built" >&2
    fi
  elif command -v sphinx-quickstart &> /dev/null; then
    echo "📝 Setting up Sphinx documentation..." >&2
    PROJECT_NAME=$(basename "$(pwd)")
    sphinx-quickstart -q -p "$PROJECT_NAME" -a "Claude" --ext-autodoc --makefile docs 2>/dev/null
    [ $? -eq 0 ] && echo "✅ Sphinx project initialized in docs/" >&2
  fi
fi

# Go projects
if [ -f "go.mod" ]; then
  echo "🐹 Go project detected" >&2

  if command -v go &> /dev/null; then
    echo "📝 Generating Go documentation..." >&2
    go doc -all > ./docs/api.txt 2>/dev/null && echo "✅ Go documentation generated" >&2

    # Try godoc if available
    if command -v godoc &> /dev/null; then
      echo "💡 Run 'godoc -http=:6060' to serve documentation locally" >&2
    fi
  fi
fi

# Rust projects
if [ -f "Cargo.toml" ]; then
  echo "🦀 Rust project detected" >&2

  if command -v cargo &> /dev/null; then
    echo "📝 Generating Rust documentation..." >&2
    cargo doc --no-deps --target-dir ./docs/rust 2>/dev/null && echo "✅ Rust documentation generated" >&2
  fi
fi

# Update CHANGELOG.md
echo "📝 Updating changelog..." >&2
CHANGELOG_ENTRY="## Session $SESSION_DATE at $SESSION_TIME\n\n- Files modified: $MODIFIED_COUNT\n- Documentation updated automatically\n- Session completed\n\n"

if [ -f "CHANGELOG.md" ]; then
  # Prepend to existing changelog
  echo -e "$CHANGELOG_ENTRY$(cat CHANGELOG.md)" > CHANGELOG.md.tmp && mv CHANGELOG.md.tmp CHANGELOG.md
else
  # Create new changelog
  echo -e "# Changelog\n\n$CHANGELOG_ENTRY" > CHANGELOG.md
fi

echo "✅ Changelog updated" >&2

# Generate or update README.md if it doesn't exist
if [ ! -f "README.md" ]; then
  echo "📝 Creating basic README.md..." >&2
  PROJECT_NAME=$(basename "$(pwd)")
  cat > README.md << EOF
# $PROJECT_NAME

Project documentation generated automatically.

## Documentation

API documentation can be found in the \`docs/\` directory.

## Last Updated

$TIMESTAMP
EOF
  echo "✅ README.md created" >&2
fi

# Create documentation index
echo "📋 Creating documentation index..." >&2
cat > ./docs/index.md << EOF
# Project Documentation

Generated on: $TIMESTAMP

## Available Documentation

EOF

# List available documentation files
find ./docs -name "*.md" -o -name "*.html" -o -name "index.html" 2>/dev/null | while read -r file; do
  echo "- [$(basename "$file")]($(basename "$file"))" >> ./docs/index.md
done

echo "" >&2
echo "📚 Documentation generation completed!" >&2
echo "📁 Check the ./docs/ directory for generated documentation" >&2
echo "📋 Documentation index available at ./docs/index.md" >&2

exit 0

Examples

Documentation Auto Generator Hook Script

Complete hook script that performs automatic documentation generation when session ends

#!/usr/bin/env bash
echo "Starting documentation generation..." >&2
mkdir -p ./docs
SESSION_DATE=$(date +"%Y-%m-%d")
SESSION_TIME=$(date +"%H:%M:%S")
MODIFIED_COUNT=0
if command -v git &> /dev/null && git rev-parse --git-dir > /dev/null 2>&1; then
  MODIFIED_COUNT=$(git diff --name-only 2>/dev/null | wc -l | xargs)
fi
echo "Session summary: $MODIFIED_COUNT files modified" >&2
if [ -f "package.json" ]; then
  if ls *.ts src/**/*.ts 2>/dev/null | head -1 > /dev/null; then
    if command -v npx &> /dev/null && npx typedoc --version &> /dev/null 2>&1; then
      echo "Generating TypeDoc documentation..." >&2
      npx typedoc --out ./docs/api src 2>/dev/null && echo "TypeDoc documentation generated" >&2
    fi
  fi
fi
echo "Documentation generation completed!" >&2
exit 0

TypeDoc Documentation Generation

Enhanced hook script using TypeDoc 0.26.0+ with entry points and configuration options

#!/usr/bin/env bash
INPUT=$(cat)
if [ -f "package.json" ]; then
  if ls *.ts src/**/*.ts 2>/dev/null | head -1 > /dev/null; then
    if command -v npx &> /dev/null && npx typedoc --version &> /dev/null 2>&1; then
      echo "Generating TypeDoc documentation..." >&2
      npx typedoc --entryPoints "./src/index.ts" --out ./docs/api --readme README.md --excludePrivate --excludeInternal 2>/dev/null && echo "TypeDoc documentation generated" >&2
    fi
  fi
fi
exit 0

Python pdoc Documentation Generation

Enhanced hook script using pdoc 14.0+ for Python project documentation generation

#!/usr/bin/env bash
if [ -f "setup.py" ] || [ -f "pyproject.toml" ]; then
  if command -v pdoc &> /dev/null; then
    echo "Generating pdoc documentation..." >&2
    pdoc --html --output-dir ./docs . 2>/dev/null && echo "pdoc documentation generated" >&2
  elif command -v python &> /dev/null; then
    if python -c "import pdoc" 2>/dev/null; then
      echo "Generating pdoc documentation..." >&2
      python -m pdoc --html --output-dir ./docs . 2>/dev/null && echo "pdoc documentation generated" >&2
    fi
  fi
fi
exit 0

Changelog Auto-Update with Session Tracking

Enhanced hook script for automatic changelog updates with session summaries and file modification tracking

#!/usr/bin/env bash
SESSION_DATE=$(date +"%Y-%m-%d")
SESSION_TIME=$(date +"%H:%M:%S")
MODIFIED_COUNT=0
if command -v git &> /dev/null && git rev-parse --git-dir > /dev/null 2>&1; then
  MODIFIED_COUNT=$(git diff --name-only 2>/dev/null | wc -l | xargs)
fi
CHANGELOG_ENTRY="## Session $SESSION_DATE at $SESSION_TIME\n\n- Files modified: $MODIFIED_COUNT\n- Documentation updated automatically\n- Session completed\n\n"
if [ -f "CHANGELOG.md" ]; then
  echo -e "$CHANGELOG_ENTRY$(cat CHANGELOG.md)" > CHANGELOG.md.tmp && mv CHANGELOG.md.tmp CHANGELOG.md
else
  echo -e "# Changelog\n\n$CHANGELOG_ENTRY" > CHANGELOG.md
fi
echo "Changelog updated" >&2
exit 0

Troubleshooting

TypeDoc generation fails with 'unable to resolve entry point' configuration error

Create tsconfig.json with explicit include paths or add 'entryPoints' to typedoc.json config. Use 'npx typedoc --entryPoints src/index.ts' to specify entry point directly in command. Verify TypeScript project structure and ensure entry points exist. Check TypeDoc version is 0.26.0+ for latest features.

CHANGELOG.md grows unbounded as every session appends duplicate timestamp entries

Implement changelog rotation by keeping only last 50 entries or use date-based sections. Archive old entries to CHANGELOG.archive.md when main file exceeds size threshold like 10KB. Use date-based grouping to consolidate multiple sessions per day. Consider using semantic versioning for changelog organization.

Documentation generation completes but docs directory remains empty after stop hook

Check documentation tool exit codes and stderr output for generation failures. Ensure write permissions on docs directory and verify sufficient disk space for generated HTML and asset files. Verify documentation generator is installed and accessible. Check for errors in documentation generator output.

Sphinx autodoc fails to import modules during documentation build process

Add project root to PYTHONPATH in hook script: 'export PYTHONPATH="${PYTHONPATH}:$(pwd)"'. Install project dependencies in documentation build environment before running sphinx-build command. Verify Sphinx version is 7.0+ for latest features. Check sphinx configuration in docs/conf.py.

Hook execution timeout when building large documentation sets on session stop

Move heavy documentation builds to separate CI job instead of stop hook. Use lightweight generators like pdoc 14.0+ for stop hook, reserving Sphinx or comprehensive builds for scheduled documentation updates. Set timeout limits for documentation generation. Consider incremental documentation updates.

JSDoc generation fails with 'Cannot find module' errors

Verify JSDoc version is 4.0.0+ and project dependencies are installed. Check jsdoc.json configuration file exists and is valid. Ensure source files are accessible and paths in configuration are correct. Install missing npm dependencies: npm install.

pdoc fails to generate documentation for Python packages

Verify pdoc version is 14.0+ and Python environment is correct. Check Python package structure and ensure init.py files exist. Verify module imports work correctly: python -c 'import your_module'. Use --html flag for HTML output: pdoc --html --output-dir ./docs .

Multiple documentation generators conflict or generate duplicate content

Configure hook to use only one documentation generator per project type. Check project type detection logic and ensure appropriate generator is selected. Use conditional logic to prevent multiple generators from running. Verify documentation output directories are separate for each generator.

Source citations

Add this badge to your README

Show that Doc Auto Generator is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/hooks/documentation-auto-generator-on-stop.svg)](https://heyclau.de/entry/hooks/documentation-auto-generator-on-stop)

How it compares

Doc Auto Generator side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

Field

Automatically generates or updates project documentation when session ends.

Open dossier

Automatically generates and updates project documentation from code comments, README files, and API definitions. This PostToolUse hook provides real-time documentation generation when code files are modified, supporting multiple programming languages and documentation formats.

Open dossier

PostToolUse hook that extracts JSDoc and pydoc comments from modified API endpoint files and generates OpenAPI 3.1.0-compatible YAML documentation on every save.

Open dossier

Automatically commits all changes with a summary when Claude Code session ends.

Open dossier
Next steps
Trust
Review statusReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewed
Package trustPackage not verifiedPackage not verifiedPackage not verifiedPackage not verified
Source provenanceSource-backedSource-backedSource-backedSource-backed
Submitter
Install riskReview firstReview firstReview firstReview first
Notes Safety Privacy Safety Privacy Safety Privacy Safety Privacy
Brand
Categoryhookshookshookshooks
Sourcesource-backedsource-backedsource-backedsource-backed
AuthorJSONboredJSONboredJSONboredJSONbored
Added2025-09-192025-09-162025-09-192025-09-19
Platforms
Claude Code
Claude Code
Claude Code
Claude Code
Source repo
Safety notesRuns automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.Runs automatically after write/edit tool use and may invoke local documentation generators such as npx jsdoc, jsdoc2md, typedoc, pdoc, pydoc, go doc, or cargo doc. Can write generated documentation under ./docs and may be slow on large source files or projects with expensive documentation tooling.Runs automatically after write or edit tool calls on route, controller, and API files. Invokes npx swagger-jsdoc or npx jsdoc to generate docs; executes python -m pydoc for Python files. Writes generated documentation files to ./docs/api/ in the project directory.Runs automatically at session end and stages all unignored repository changes with git add -A. Creates a local commit when changes are present unless SKIP_AUTO_COMMIT=true is set. Only warns on sensitive-looking filenames and does not block the commit by default.
Privacy notesReceives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.Reads modified source, README, Markdown, and package metadata files to count comments, links, functions, classes, and documentation sections. Generated documentation may include source comments, API details, project names, and README content from the local workspace.Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.Reads git status, branch name, staged diff statistics, and changed file names to build the commit message. Can commit newly created or modified local files, including private work, when they are not excluded by .gitignore. Commit metadata uses the locally configured git user name and email.
Prerequisites— none listed— none listed— none listed— none listed
Install
mkdir -p .claude/hooks && touch .claude/hooks/documentation-auto-generator-on-stop.sh && chmod +x .claude/hooks/documentation-auto-generator-on-stop.sh
mkdir -p .claude/hooks && touch .claude/hooks/documentation-generator.sh && chmod +x .claude/hooks/documentation-generator.sh
mkdir -p .claude/hooks && touch .claude/hooks/api-endpoint-documentation-generator.sh && chmod +x .claude/hooks/api-endpoint-documentation-generator.sh
mkdir -p .claude/hooks && touch .claude/hooks/git-auto-commit-on-stop.sh && chmod +x .claude/hooks/git-auto-commit-on-stop.sh
Config
{
  "hooks": {
    "stop": {
      "script": "./.claude/hooks/documentation-auto-generator-on-stop.sh"
    }
  }
}
{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/documentation-generator.sh",
      "matchers": [
        "write",
        "edit"
      ]
    }
  }
}
{
  "hooks": {
    "postToolUse": {
      "script": "./.claude/hooks/api-endpoint-documentation-generator.sh",
      "matchers": [
        "write",
        "edit"
      ]
    }
  }
}
{
  "hooks": {
    "stop": {
      "script": "./.claude/hooks/git-auto-commit-on-stop.sh"
    }
  }
}
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed
Open 4 picks in the interactive comparison tool

Related guides

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.