Comprehensive developer toolkit providing reusable skills for Java/Spring Boot, TypeScript/NestJS/React/Next.js, Python, PHP, AWS CloudFormation, AI/RAG, DevOps, and more.
89
89%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Risky
Do not use without reviewing
#!/usr/bin/env python3
"""TypeScript Dev Server Guard Hook.
Intercepts long-running dev server commands (npm run dev, nest start, etc.)
and automatically wraps them in a named tmux session so they run detached,
logs are preserved, and Claude Code is not blocked.
Hook event: PreToolUse (Bash)
Input: JSON via stdin { "tool_name": "Bash", "tool_input": { "command": "..." } }
Output:
- Modified JSON (command wrapped in tmux) → stdout + exit 0
- Advisory message → stdout + exit 1 (tmux not found)
- Pass-through → no output + exit 0 (not a dev server)
Zero external dependencies — pure Python 3 standard library only.
"""
import json
import os
import re
import shutil
import sys
from pathlib import Path
# ─── Dev Server Command Detection ────────────────────────────────────────────
_DEV_SERVER_RE = re.compile(
r"(?:^|&&|\||\s)" # start, chain, or whitespace
r"\s*(?:"
r"npm\s+run\s+(?:dev|start|watch)"
r"|npm\s+start"
r"|pnpm\s+(?:run\s+)?(?:dev|start|watch)"
r"|yarn\s+(?:run\s+)?(?:dev|start|watch)"
r"|bun\s+run\s+(?:dev|start)"
r"|nest\s+start(?:\s+--watch)?"
r"|ts-node(?:-dev)?\s+src/main"
r")\b",
re.IGNORECASE,
)
# ─── Helpers ──────────────────────────────────────────────────────────────────
def _in_tmux() -> bool:
"""Return True if the current process is already running inside tmux."""
return bool(os.environ.get("TMUX", ""))
def _tmux_available() -> bool:
"""Return True if tmux is installed on this system."""
return shutil.which("tmux") is not None
def _sanitize_session_name(name: str) -> str:
"""Create a safe tmux session name from a directory name."""
sanitized = re.sub(r"[^a-zA-Z0-9_-]", "_", name)
return sanitized[:32] or "dev"
def _escape_for_single_quotes(s: str) -> str:
"""Escape a string for safe use inside single-quoted shell arguments."""
return s.replace("'", "'\\''")
# ─── Entry Point ─────────────────────────────────────────────────────────────
def main() -> None:
try:
data = json.load(sys.stdin)
except (json.JSONDecodeError, ValueError):
sys.exit(0)
if data.get("tool_name") != "Bash":
sys.exit(0)
cmd: str = data.get("tool_input", {}).get("command", "")
if not cmd or not _DEV_SERVER_RE.search(cmd):
sys.exit(0)
# Already inside a tmux session — pass through unchanged
if _in_tmux():
sys.exit(0)
# Tmux not installed — show advisory so Claude can decide
if not _tmux_available():
message = (
"⚠️ Dev server detected outside tmux. Logs may be lost when the session ends.\n"
" To preserve logs, install tmux (brew install tmux / apt install tmux)\n"
" then re-run the command. Proceeding without tmux."
)
# Output JSON format for advisory
output = {
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"additionalContext": message
}
}
print(json.dumps(output))
sys.exit(0)
# ── Transform: wrap command in a named tmux session ────────────────────
cwd = os.environ.get("CLAUDE_CWD", os.getcwd())
session_name = _sanitize_session_name(Path(cwd).name)
escaped_cmd = _escape_for_single_quotes(cmd)
tmux_cmd = (
f'SESSION="{session_name}"; '
f"tmux kill-session -t \"$SESSION\" 2>/dev/null || true; "
f"tmux new-session -d -s \"$SESSION\" '{escaped_cmd}' && "
f"echo \"[Dev Server] Started in tmux session '{session_name}'. "
f"View logs: tmux attach -t {session_name} | "
f"tail: tmux capture-pane -t {session_name} -p -S -100\""
)
data["tool_input"]["command"] = tmux_cmd
print(json.dumps(data))
sys.exit(0)
if __name__ == "__main__":
main()docs
plugins
developer-kit-ai
developer-kit-aws
agents
docs
skills
aws
aws-cli-beast
aws-cost-optimization
aws-drawio-architecture-diagrams
aws-sam-bootstrap
aws-cloudformation
aws-cloudformation-auto-scaling
aws-cloudformation-bedrock
aws-cloudformation-cloudfront
aws-cloudformation-cloudwatch
aws-cloudformation-dynamodb
aws-cloudformation-ec2
aws-cloudformation-ecs
aws-cloudformation-elasticache
references
aws-cloudformation-iam
references
aws-cloudformation-lambda
aws-cloudformation-rds
aws-cloudformation-s3
aws-cloudformation-security
aws-cloudformation-task-ecs-deploy-gh
aws-cloudformation-vpc
references
developer-kit-core
agents
commands
skills
developer-kit-devops
developer-kit-java
agents
commands
docs
skills
aws-lambda-java-integration
aws-rds-spring-boot-integration
aws-sdk-java-v2-bedrock
aws-sdk-java-v2-core
aws-sdk-java-v2-dynamodb
aws-sdk-java-v2-kms
aws-sdk-java-v2-lambda
aws-sdk-java-v2-messaging
aws-sdk-java-v2-rds
aws-sdk-java-v2-s3
aws-sdk-java-v2-secrets-manager
clean-architecture
graalvm-native-image
langchain4j-ai-services-patterns
references
langchain4j-mcp-server-patterns
references
langchain4j-rag-implementation-patterns
references
langchain4j-spring-boot-integration
langchain4j-testing-strategies
langchain4j-tool-function-calling-patterns
langchain4j-vector-stores-configuration
references
qdrant
references
spring-ai-mcp-server-patterns
spring-boot-actuator
spring-boot-cache
spring-boot-crud-patterns
spring-boot-dependency-injection
spring-boot-event-driven-patterns
spring-boot-openapi-documentation
spring-boot-project-creator
spring-boot-resilience4j
spring-boot-rest-api-standards
spring-boot-saga-pattern
spring-boot-security-jwt
assets
references
scripts
spring-boot-test-patterns
spring-data-jpa
references
spring-data-neo4j
references
unit-test-application-events
unit-test-bean-validation
unit-test-boundary-conditions
unit-test-caching
unit-test-config-properties
references
unit-test-controller-layer
unit-test-exception-handler
references
unit-test-json-serialization
unit-test-mapper-converter
references
unit-test-parameterized
unit-test-scheduled-async
references
unit-test-service-layer
references
unit-test-utility-methods
unit-test-wiremock-rest-api
references
developer-kit-php
developer-kit-project-management
developer-kit-python
developer-kit-specs
commands
docs
hooks
test-templates
tests
skills
developer-kit-tools
developer-kit-typescript
agents
docs
hooks
rules
skills
aws-cdk
aws-lambda-typescript-integration
better-auth
clean-architecture
drizzle-orm-patterns
dynamodb-toolbox-patterns
references
nestjs
nestjs-best-practices
nestjs-code-review
nestjs-drizzle-crud-generator
nextjs-app-router
nextjs-authentication
nextjs-code-review
nextjs-data-fetching
nextjs-deployment
nextjs-performance
nx-monorepo
react-code-review
react-patterns
shadcn-ui
tailwind-css-patterns
tailwind-design-system
references
turborepo-monorepo
typescript-docs
typescript-security-review
zod-validation-utilities
references
github-spec-kit