Install command
Provided
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 the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
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
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Safety & privacy surface
3 safety and 1 privacy notes across 2 risk areas. Review closely: credentials & tokens.
#!/usr/bin/env bash
# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
# Check if it's an API-related file
if [[ "$FILE_PATH" == *routes/* ]] || [[ "$FILE_PATH" == *controllers/* ]] || [[ "$FILE_PATH" == *api/* ]]; then
echo "📚 Generating API documentation for $FILE_PATH..."
# Get file extension
EXT="${FILE_PATH##*.}"
case "$EXT" in
js|jsx|ts|tsx)
# JavaScript/TypeScript API files
if command -v swagger-jsdoc &> /dev/null && [ -f "swaggerDef.js" ]; then
echo "Generating Swagger documentation..."
npx swagger-jsdoc -d swaggerDef.js -o ./docs/api.json "$FILE_PATH" 2>/dev/null
echo "✅ Swagger documentation updated" >&2
elif command -v npx &> /dev/null; then
echo "Generating JSDoc documentation..."
npx jsdoc "$FILE_PATH" -d ./docs/api/ 2>/dev/null
echo "✅ JSDoc documentation updated" >&2
fi
;;
py)
# Python API files
if command -v pydoc &> /dev/null; then
echo "Generating Python API documentation..."
python -m pydoc -w "$FILE_PATH" 2>/dev/null
echo "✅ Python documentation updated" >&2
fi
;;
esac
else
echo "File not in API directory, skipping documentation generation" >&2
fi
exit 0{
"hooks": {
"postToolUse": {
"script": "./.claude/hooks/api-endpoint-documentation-generator.sh",
"matchers": [
"write",
"edit"
]
}
}
}.claude/settings.local.json~/.claude/settings.json.claude/settings.json{
"hooks": {
"postToolUse": {
"script": "./.claude/hooks/api-endpoint-documentation-generator.sh",
"matchers": ["write", "edit"]
}
}
}
#!/usr/bin/env bash
# Read the tool input from stdin
INPUT=$(cat)
TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name')
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
if [ -z "$FILE_PATH" ]; then
exit 0
fi
# Check if it's an API-related file
if [[ "$FILE_PATH" == *routes/* ]] || [[ "$FILE_PATH" == *controllers/* ]] || [[ "$FILE_PATH" == *api/* ]]; then
echo "📚 Generating API documentation for $FILE_PATH..."
# Get file extension
EXT="${FILE_PATH##*.}"
case "$EXT" in
js|jsx|ts|tsx)
# JavaScript/TypeScript API files
if command -v swagger-jsdoc &> /dev/null && [ -f "swaggerDef.js" ]; then
echo "Generating Swagger documentation..."
npx swagger-jsdoc -d swaggerDef.js -o ./docs/api.json "$FILE_PATH" 2>/dev/null
echo "✅ Swagger documentation updated" >&2
elif command -v npx &> /dev/null; then
echo "Generating JSDoc documentation..."
npx jsdoc "$FILE_PATH" -d ./docs/api/ 2>/dev/null
echo "✅ JSDoc documentation updated" >&2
fi
;;
py)
# Python API files
if command -v pydoc &> /dev/null; then
echo "Generating Python API documentation..."
python -m pydoc -w "$FILE_PATH" 2>/dev/null
echo "✅ Python documentation updated" >&2
fi
;;
esac
else
echo "File not in API directory, skipping documentation generation" >&2
fi
exit 0
Complete hook script that generates API documentation for JavaScript, TypeScript, and Python API files using swagger-jsdoc, JSDoc, or FastAPI
#!/usr/bin/env bash
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | jq -r ".tool_input.file_path // .tool_input.path // \"\"")
if [ -z "$FILE_PATH" ]; then exit 0; fi
if [[ "$FILE_PATH" == *routes/* ]] || [[ "$FILE_PATH" == *controllers/* ]] || [[ "$FILE_PATH" == *api/* ]]; then
echo "Generating API documentation for $FILE_PATH..." >&2
EXT="${FILE_PATH##*.}"
case "$EXT" in
js|jsx|ts|tsx)
if command -v swagger-jsdoc &> /dev/null && [ -f "swaggerDef.js" ]; then
npx swagger-jsdoc -d swaggerDef.js -o ./docs/api.json "$FILE_PATH" 2>/dev/null
echo "OpenAPI documentation updated" >&2
elif command -v npx &> /dev/null; then
npx jsdoc "$FILE_PATH" -d ./docs/api/ 2>/dev/null
echo "JSDoc documentation updated" >&2
fi
;;
py)
if command -v python &> /dev/null && python -c "import fastapi" 2>/dev/null; then
echo "FastAPI OpenAPI docs available at /docs and /redoc endpoints" >&2
fi
;;
esac
fi
exit 0
Complete hook configuration for .claude/settings.json to enable automatic API documentation generation on file writes and edits
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "./.claude/hooks/api-endpoint-documentation-generator.sh"
}
]
}
]
}
}
Example swagger-jsdoc configuration for generating OpenAPI 3.1.0 specification with validation enabled
const swaggerJsdoc = require("swagger-jsdoc");
const options = {
definition: {
openapi: "3.1.0",
info: {
title: "My API",
version: "1.0.0",
},
},
apis: ["./src/routes/*.js"],
failOnErrors: true,
};
const openapiSpecification = swaggerJsdoc(options);
Example JSDoc annotation for OpenAPI 3.1.0 endpoint documentation using @openapi tag
/**
* @openapi
* /users:
* get:
* summary: Get all users
* responses:
* 200:
* description: List of users
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: '#/components/schemas/User'
*/
app.get("/users", (req, res) => {
res.json([]);
});
Example FastAPI application with automatic OpenAPI 3.1.0 documentation generation
from fastapi import FastAPI
app = FastAPI(
title="My API",
version="1.0.0",
openapi_version="3.1.0"
)
@app.get("/users/")
async def get_users():
return []
# OpenAPI docs automatically available at /docs and /redoc
Debug path detection: echo "$FILE_PATH" | grep -E 'routes|controllers|api'. Verify directory structure matches expected patterns. Add custom paths to case statement. Check file extension extraction: EXT="${FILE_PATH##*.}".
Install dependencies: npm i -D swagger-jsdoc@^6.0.0. Verify swaggerDef.js exists in project root. Check node_modules/.bin is in PATH. Use npx for local binaries: npx swagger-jsdoc. Verify package.json includes swagger-jsdoc as devDependency.
Create docs/api directory: mkdir -p ./docs/api. Verify write permissions on output paths. Check current working directory in hook context: pwd >&2. Use absolute paths for output: -o "$CLAUDE_PROJECT_DIR/docs/api.json".
Enhance path filtering in script. Use stricter regex: [["$FILE_PATH" =~ (routes|api)/.*.(ts|js)$]]. Add early exit for non-matching paths. Check file extension before processing: if [["$EXT" != "js" && "$EXT" != "ts" && "$EXT" != "py"]]; then exit 0; fi.
Remove 2>/dev/null to see actual errors. Add timeout wrapper: timeout 30s npx swagger-jsdoc. Check for hanging processes: ps aux | grep jsdoc. Verify npm registry access: npm ping. Check network connectivity for package downloads.
Enable failOnErrors in swagger-jsdoc options: failOnErrors: true. Check JSDoc annotation syntax matches OpenAPI 3.1.0 format. Verify swaggerDef.js uses openapi: '3.1.0'. Review validation errors in output for specific issues.
FastAPI generates OpenAPI schema at runtime - restart FastAPI server to see changes. Use auto-reload: uvicorn main:app --reload. Verify FastAPI version supports OpenAPI 3.1.0: pip show fastapi. Check /openapi.json endpoint for current schema.
Verify JSDoc annotations use correct @openapi or @swagger tags. Check apis array includes correct file patterns: apis: ['./src/routes/*.js']. Ensure swaggerDef.js configuration is correct. Test with single file first: npx swagger-jsdoc -d swaggerDef.js route.js.
Show that API Doc Generator is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/hooks/api-endpoint-documentation-generator)API Doc Generator side by side with its closest alternative on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
| Field | 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 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 |
|---|---|---|
| Next steps | ||
| Trust | ||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed |
| Submitter | — | — |
| Install risk | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — |
| Category | hooks | hooks |
| Source | source-backed | source-backed |
| Author | JSONbored | JSONbored |
| Added | 2025-09-19 | 2025-09-16 |
| Platforms | Claude Code | Claude Code |
| Source repo | — | — |
| Safety notes | ✓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 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. |
| 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. | ✓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. |
| Prerequisites | — none listed | — none listed |
| Install | | |
| Config | | |
| Citations | ||
| Claim | Unclaimed | Unclaimed |
Source-backed guides for putting this to work.
Set autoMode.hard_deny rules to block risky actions in auto mode.
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.