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 Rules Tracker Hook.
Fires after Claude writes or edits a TypeScript file. Finds .claude/rules/
entries whose 'paths:' frontmatter matches the modified file and persists them
to a per-session state file so the Prompt hook can pick them up.
Hook event: PostToolUse (Write | Edit | MultiEdit)
Input: JSON via stdin with tool_name and tool_input
Output: always Exit 0 — side effect only (writes state file)
Zero external dependencies — pure Python 3 standard library only.
"""
import hashlib
import json
import os
import sys
from pathlib import Path
from typing import Optional
# State directory lives under $CLAUDE_CWD/.claude/ (project-local, not world-readable)
_STATE_FILENAME_PREFIX = ".ts-rules-pending-"
TS_EXTENSIONS: tuple[str, ...] = (".ts", ".tsx", ".js", ".jsx")
# ─── Minimal YAML Frontmatter Parser ─────────────────────────────────────────
def _parse_frontmatter(text: str) -> tuple[dict, str]:
"""Return (frontmatter_dict, body). Handles only the simple subset used in
.claude/rules files: top-level key:value pairs and list items (- value)."""
lines = text.splitlines()
if not lines or lines[0].strip() != "---":
return {}, text
end: Optional[int] = None
for i, line in enumerate(lines[1:], start=1):
if line.strip() == "---":
end = i
break
if end is None:
return {}, text
fm: dict = {}
current_key: Optional[str] = None
for line in lines[1:end]:
stripped = line.strip()
if stripped.startswith("- "):
val = stripped[2:].strip().strip("\"'")
if current_key is not None and isinstance(fm.get(current_key), list):
fm[current_key].append(val)
elif ":" in stripped:
key, _, val = stripped.partition(":")
key, val = key.strip(), val.strip().strip("\"'")
if val:
fm[key] = val
current_key = None
else:
fm[key] = []
current_key = key
return fm, "\n".join(lines[end + 1 :]).strip()
# ─── Path Matching ────────────────────────────────────────────────────────────
def _matches_any(file_path: str, patterns: list[str]) -> bool:
p = Path(file_path)
rel = Path(p.as_posix().lstrip("/"))
return any(p.match(pat) or rel.match(pat) for pat in patterns)
# ─── State File ───────────────────────────────────────────────────────────────
def _session_key() -> str:
cwd = os.environ.get("CLAUDE_CWD", os.getcwd())
return hashlib.sha256(cwd.encode()).hexdigest()[:12]
def _state_path() -> Path:
cwd = Path(os.environ.get("CLAUDE_CWD", os.getcwd()))
state_dir = cwd / ".claude"
state_dir.mkdir(parents=True, exist_ok=True)
return state_dir / f"{_STATE_FILENAME_PREFIX}{_session_key()}.json"
def _load_state() -> list[dict]:
sp = _state_path()
if sp.exists():
try:
return json.loads(sp.read_text(encoding="utf-8"))
except Exception:
pass
return []
def _save_state(entries: list[dict]) -> None:
try:
sp = _state_path()
sp.write_text(json.dumps(entries, indent=2), encoding="utf-8")
os.chmod(sp, 0o600)
except OSError:
pass
# ─── Entry Point ─────────────────────────────────────────────────────────────
def main() -> None:
try:
data = json.load(sys.stdin)
except (json.JSONDecodeError, ValueError):
sys.exit(0)
if data.get("tool_name") not in ("Write", "Edit", "MultiEdit"):
sys.exit(0)
file_path: str = data.get("tool_input", {}).get("file_path", "")
if not file_path or not any(file_path.endswith(ext) for ext in TS_EXTENSIONS):
sys.exit(0)
cwd = Path(os.environ.get("CLAUDE_CWD", os.getcwd()))
rules_dir = cwd / ".claude" / "rules"
if not rules_dir.is_dir():
sys.exit(0)
matched: list[dict] = []
for rule_file in sorted(rules_dir.glob("*.md")):
try:
raw = rule_file.read_text(encoding="utf-8")
except OSError:
continue
fm, body = _parse_frontmatter(raw)
paths = fm.get("paths", [])
if not paths:
continue
if isinstance(paths, str):
paths = [paths]
if not _matches_any(file_path, paths):
continue
# Extract H1 title from body
title = rule_file.stem.replace("-", " ").title()
for line in body.splitlines():
heading = line.lstrip("#").strip()
if heading:
title = heading
break
matched.append(
{
"file": rule_file.name,
"title": title,
"body": body[:2000],
}
)
if not matched:
sys.exit(0)
# Append to state (avoid duplicates for the same file)
state = _load_state()
existing_files = {e["written_file"] for e in state}
if file_path not in existing_files:
state.append({"written_file": file_path, "rules": matched})
_save_state(state)
sys.exit(0) # Always non-blocking — Prompt hook does the actual verification
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