Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 87 additions & 13 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,99 @@
- Use the SUCCESS framework for communication style
- Only push the specific branch you're working on

## Tool Priority (CRITICAL)

Always prefer dedicated tools over Bash for these operations:

| Operation | Use This | NOT This |
|-----------|----------|----------|
| Read files | `Read` | `cat`, `head`, `tail`, `sed` |
| Edit files | `Edit` / `Write` | `sed`, `awk`, echo redirect |
| Find files | `Glob` | `find`, `ls` |
| Search text | `Grep` | `grep`, `rg` |
| Search code (structural) | `ast-grep` (`sg`) via Bash | `grep` for code patterns |
| Web search | `WebSearch` | — |
| Fetch URLs | `WebFetch` / `mcp__read-website-fast__read_website` | `curl` |

Reserve `Bash` exclusively for: git operations, running tests/commands, and system operations with no dedicated tool.

**Missing tools**: If a required CLI tool is not installed, use `WebSearch` to find the correct Homebrew formula, then install it with `brew install <formula>`. Use the `homebrew` skill for guidance.

## Code Editing

- Use the serena MCP server for editing when possible
- Prefer `Edit` / `Write` tools for file changes
- Use the serena MCP server for complex multi-file structural edits when available

---

## Skills Index

Skills auto-activate based on task context. All skills located in `~/.claude/skills/`.

| Skill | Triggers When |
|-------|---------------|
| `python-development` | Writing, reviewing, or debugging Python code |
| `prompt-engineering` | Creating prompts, agents, commands, or system instructions |
| `research-workflow` | Multi-step research, fact-finding, or web search tasks |
| `knowledge-synthesis` | Synthesizing knowledge, creating Zettelkasten notes |
| `model-selection` | Choosing Claude models for agents or tasks |
| `code-refactoring` | AST-based multi-file refactoring with gritql |
| `infrastructure-testing` | TestKube/PGBouncer on Kubernetes clusters |
| `docker-build-test` | Docker build/test with validation pipeline |
| `java-api-discovery` | Discovering Java API endpoints in codebases |
| `markdown-confluence-sync` | Syncing markdown content with Confluence |
### Development & Code Quality

| Skill | Invoke When | Examples |
|-------|------------|----------|
| `python-development` | Writing, reviewing, or debugging Python code; applying PEP 8, type annotations, uv package management, Pydantic DTOs, Typer CLIs, pytest patterns | "Write a Python CLI", "Add type hints to this module", "Fix this pytest failure" |
| `ast-grep` | Searching code by structure/syntax — function calls, class definitions, imports, decorators; any search where text matching isn't precise enough | "Find all callers of this method", "Find all async functions", "Search for usages of this decorator" |
| `gritql` | AST-based multi-file code transformations: rename methods/classes, migrate APIs, modernize patterns; always dry-run first | "Rename this method everywhere", "Migrate this API across the codebase", "Update all import paths" |
| `code-refactoring` | Orchestrating large structural refactors combining search (ast-grep) and transformation (gritql) with quality gates | "Refactor error handling across all controllers", "Rename method consistently throughout codebase" |
| `java-api-discovery` | Discovering actual Java API signatures from compiled JARs; encountering unknown methods, pagination patterns, union types, or compilation errors | "What methods does this AWS SDK class have?", "Find the correct signature for this Java API" |

### Version Control & Git Operations

| Skill | Invoke When | Examples |
|-------|------------|----------|
| `git/worktrees` | Starting new feature branches needing isolation; working on multiple features simultaneously; requiring clean dependency states or avoiding merge conflicts | "Create a worktree for auth feature", "Set up isolated workspace", "Work on feature without switching branches" |
| `jj-version-control` | Using Jujutsu (jj) commands; working with revsets, bookmarks, anonymous branches; splitting/squashing commits; editing history; pushing to git remotes | "Commit with jj", "Split this change into multiple commits", "Rebase using jj", "Create bookmark" |
| `github-pr` | Working with GitHub pull requests; reviewing PRs, creating PRs, checking PR status, viewing comments, analyzing CI failures; using gh CLI commands | "Create a PR for this branch", "Review PR #123", "Check why CI failed", "List open PRs" |

### Infrastructure & DevOps

| Skill | Invoke When | Examples |
|-------|------------|----------|
| `homebrew` | Installing or managing macOS CLI tools or apps; a required tool is missing; troubleshooting formula conflicts or taps | "Install ast-grep", "Tool not found", "Upgrade all packages", "Add a Homebrew tap" |
| `infrastructure-testing` | Running TestKube or PGBouncer tests on Kubernetes clusters; requires mandatory context verification to prevent wrong-cluster operations | "Run TestKube tests on staging", "Verify PGBouncer config", "Test database connection pooling" |
| `docker-build-test` | Building and testing Docker images locally; validating before pushing; preventing CI/CD failures with pre-push checklist | "Build Docker image", "Test container locally before push", "Validate Dockerfile changes" |
| `fbg-terraform-changes` | Navigating or modifying FBG's shared Terraform infrastructure; adding services, modifying configs, extending modules | "Add new service to Terraform", "Update RDS config", "Extend EKS module" |

### Documentation & Knowledge Management

| Skill | Invoke When | Examples |
|-------|------------|----------|
| `knowledge-synthesis` | Synthesizing knowledge from multiple sources into Zettelkasten notes; creating wiki pages with [[links]] and #[[tags]]; integrating academic research | "Synthesize this article into Zettel", "Create wiki page for concept", "Integrate research notes" |
| `markdown-confluence-sync` | Publishing markdown to Confluence; crawling/downloading Confluence pages; syncing bidirectionally; checking sync status; resolving conflicts; managing comments; validating links; troubleshooting page issues | "Publish docs to Confluence", "Crawl Confluence page", "Download this Confluence page", "Check sync status", "Resolve Confluence conflicts", "Validate Confluence links" |

### Browser Automation

| Skill | Invoke When | Examples |
|-------|------------|----------|
| `playwright-skill` | Browser automation, web testing, screenshotting pages, testing login flows, checking responsive design, validating links, or automating any browser interaction; auto-detects local dev servers | "Test this page", "Screenshot this URL", "Check for broken links", "Test the login flow", "Automate this form" |

### Debugging & Investigation

| Skill | Invoke When | Examples |
|-------|------------|----------|
| `root-cause-analysis` | Investigating errors with stack traces; debugging incidents or outages; finding historical context for similar issues; searching for past solutions in wiki | "Why is this failing?", "Find similar errors in wiki", "Debug this stack trace", "What caused this incident before?" |
| `debugging` | Systematic debugging with proven frameworks; encountering bugs, test failures, or unexpected behavior; needs root-cause tracing, defense-in-depth validation, or verification before claiming a fix is complete | "Debug this failure", "Find root cause", "Verify this fix works", "Test is failing" |
| `code-review` | Receiving or requesting code review; before claiming a task is complete; before committing or creating PRs; when feedback seems technically questionable; after fixing complex bugs | "Review this code", "Is this ready to commit?", "I got this review comment", "Check my fix before I push" |

### Tooling & Meta-Development

| Skill | Invoke When | Examples |
|-------|------------|----------|
| `prompt-engineering` | Creating or improving prompts, agents, commands, system instructions, SKILL.md files; applying XML tags, multishot examples, chain-of-thought, response prefilling | "Create a new agent", "Improve this prompt", "Add examples to SKILL.md", "Optimize context usage" |
| `model-selection` | Choosing appropriate Claude model (Opus 4.5, Sonnet, Haiku) for agents, commands, or Task tool invocations based on complexity, reasoning depth, cost/speed | "Which model should I use for this agent?", "Optimize agent model selection", "Choose model for complex reasoning task" |
| `research-workflow` | Performing multi-step research, fact-finding, web searches, verification tasks; using Brave Search, Puppeteer, or synthesizing information from sources | "Research best practices for X", "Find documentation for Y", "Verify claims about Z", "Search and synthesize findings" |
| `claude-technique-evaluator` | Evaluating new Claude/Claude Code techniques, tools, features, or workflow changes for adoption value; assessing blog posts, release notes, community tips against Anthropic best practices and current workflow fit | "Evaluate this Claude technique", "Is this prompting pattern worth adopting?", "Assess this new Claude Code feature", "Should I use extended thinking?" |
| `context-engineering` | Designing agent architectures; debugging context failures; optimizing token usage; implementing memory systems; building multi-agent coordination; evaluating agent performance | "Optimize context for this agent", "Why is my agent losing context?", "Design memory system", "Reduce token usage" |

### Skill Usage Patterns

**Auto-activation**: Skills automatically activate when Claude detects relevant task context from your request.

**Explicit invocation**: You can explicitly reference a skill by name (e.g., "Use the python-development skill to...").

**Skill chaining**: Skills can invoke other skills (e.g., git/worktrees may use python-development for Python projects).

**Progressive disclosure**: Skills load context progressively - core instructions first, detailed references only when needed.
38 changes: 0 additions & 38 deletions .claude/agents/code-refactoring.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,6 @@
---
name: code-refactoring
description: Use this agent to refactor code following established software engineering principles, design patterns, and best practices from authoritative literature. This agent uses AST-based tools (gritql) for safe, validated structural transformations and should be invoked when you need to improve existing code structure, apply design patterns, implement SOLID principles, or modernize code using language-specific idioms while preserving behavior and enhancing maintainability.

Examples:
- <example>
Context: The user has code that violates SOLID principles or contains code smells.
user: "This service class is doing too much - it handles database access, business logic, and API responses"
assistant: "I'll use the code-refactoring agent to apply Single Responsibility Principle and separate concerns using appropriate patterns"
<commentary>
Since this requires systematic application of SOLID principles, identification of code smells from Fowler's catalog, and restructuring using design patterns, the code-refactoring agent is the appropriate choice.
</commentary>
</example>

- <example>
Context: Legacy code needs modernization without changing behavior.
user: "This legacy payment processing module needs refactoring to use modern Java patterns and Spring Boot best practices"
assistant: "I'll use the code-refactoring agent to modernize the code while preserving behavior, applying Clean Code principles and contemporary patterns"
<commentary>
This requires deep knowledge of refactoring techniques from Fowler's catalog, language-specific idioms, and behavior-preserving transformations that the code-refactoring agent specializes in.
</commentary>
</example>

- <example>
Context: Code has high cyclomatic complexity and poor maintainability.
user: "This method has nested conditionals and is 200 lines long. It's hard to test and maintain"
assistant: "I'll use the code-refactoring agent to decompose this method using Extract Method, Replace Conditional with Polymorphism, and other refactorings"
<commentary>
This requires systematic application of refactoring techniques, complexity reduction strategies, and pattern application that the code-refactoring agent excels at.
</commentary>
</example>

- <example>
Context: After implementing new code, the user wants to improve its design.
user: "I've just finished implementing the user authentication service. Can you review and refactor it?"
assistant: "I'll use the code-refactoring agent to analyze the implementation and apply design patterns and SOLID principles to improve its structure"
<commentary>
Post-implementation refactoring to improve design quality is a core specialty of the code-refactoring agent.
</commentary>
</example>

tools: Read, Edit, MultiEdit, Write, Bash, Grep, Glob, TodoWrite
model: opus
---
Expand Down
34 changes: 4 additions & 30 deletions .claude/agents/doc-quality-analyzer.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,7 @@
---
name: doc-quality-analyzer
description: Use this agent to analyze documentation for freshness, accuracy, completeness, and structural quality using the Diataxis framework. This agent should be invoked when you need to audit documentation quality, consolidate scattered information, identify outdated content, or restructure documentation for better usability.

Examples:
- <example>
Context: A project has accumulated many documentation files over time and needs a comprehensive quality audit.
user: "Can you review our documentation and identify what's outdated or needs consolidation?"
assistant: "I'll use the doc-quality-analyzer agent to perform a comprehensive documentation quality audit"
<commentary>
Since this requires systematic documentation analysis with expertise in information architecture and the Diataxis framework, the doc-quality-analyzer agent is the appropriate choice.
</commentary>
</example>
- <example>
Context: Documentation has grown organically and information is scattered across multiple files.
user: "We have duplicate information in several places - can you help consolidate our docs?"
assistant: "I'll use the doc-quality-analyzer agent to identify duplicate content and recommend consolidation"
<commentary>
The agent specializes in detecting information redundancy and applying structured documentation principles.
</commentary>
</example>
- <example>
Context: Team wants to apply the Diataxis framework to improve documentation structure.
user: "Help us organize our documentation following the Diataxis framework"
assistant: "I'll use the doc-quality-analyzer agent to restructure your documentation using Diataxis principles"
<commentary>
The agent has deep knowledge of the Diataxis framework and can systematically apply it to documentation.
</commentary>
</example>

tools: [Read, Glob, Grep, Task, TodoWrite, WebFetch, mcp__brave-search__brave_web_search]
tools: Read, Glob, Grep, Task, TodoWrite, WebFetch, mcp__brave-search__brave_web_search
model: sonnet
---

Expand Down Expand Up @@ -145,7 +118,8 @@ Auditing sentence quality to identify systematic clarity problems.
## Methodology

### **Phase 1: Discovery and Inventory**
1. **Scan all documentation files** using Glob to identify all `.md`, `.txt`, and documentation files
1. **Handle [[Needs Processing]] tags**: When encountering this tag in documentation, recursively process all child bullet points and nested content to ensure full context is captured for analysis.
2. **Scan all documentation files** using Glob to identify all `.md`, `.txt`, and documentation files
2. **Create an inventory** of documentation assets with:
- File paths and names
- Apparent purpose and content type
Expand Down Expand Up @@ -270,4 +244,4 @@ Prioritized list of tasks with:
- Estimated effort
- Priority level

Remember: Documentation is a living artifact that reflects the system it describes. Your goal is to make it accurate, accessible, and aligned with documentation best practices while respecting the existing knowledge and structure the team has built.
Remember: Documentation is a living artifact that reflects the system it describes. Your goal is to make it accurate, accessible, and aligned with documentation best practices while respecting the existing knowledge and structure the team has built.
137 changes: 137 additions & 0 deletions .claude/agents/docker-build-test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
description: Docker build and test workflow with mandatory pre-push validation checklist
to prevent CI/CD failures
mode: subagent
temperature: 0.1
tools: []
name: docker-build-test
---

# Docker Build & Test

Local Docker testing workflow to prevent CI/CD failures. **CRITICAL**: Always run `make validate` before pushing.

## Pre-Push Checklist (MANDATORY)

Before pushing ANY Docker-related changes:

- [ ] `make validate` passes completely
- [ ] No build errors or warnings
- [ ] Smoke tests pass
- [ ] Image sizes verified
- [ ] Clean validation from scratch

## Quick Start

```bash
# Complete validation (ALWAYS run before push)
make validate

# Build and test everything
make all

# Clean and rebuild
make clean && make validate
```

## Build Commands

```bash
# Build both images
make build

# Build individual images
make build-healthcheck
make build-pgbouncer
```

## Test Commands

```bash
# Test both images
make test

# Test individual images
make test-healthcheck
make test-pgbouncer
```

## Validation Pipeline

```bash
# 1. Complete validation (recommended)
make validate

# 2. Check for errors
make build 2>&1 | grep -i error

# 3. Verify functionality
make test

# 4. Check image sizes
make info

# 5. Clean validation
make clean && make validate
```

## Manual Docker Commands (Fallback)

```bash
# Build
docker build -f Dockerfile.healthcheck -t pgbouncer-healthcheck:latest .
docker build -f Dockerfile.pgbouncer -t pgbouncer:latest .

# Test
docker run --rm pgbouncer-healthcheck:latest /usr/local/bin/healthcheck-unified.py --help
docker run --rm pgbouncer:latest /usr/local/bin/pgbouncer --version

# Check sizes
docker images | grep -E "(pgbouncer-healthcheck|pgbouncer)"
```

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Docker daemon not running | Start Docker Desktop |
| Permission denied | Verify Docker access: `docker info` |
| Build failures | Use `make debug` for verbose output |
| Disk space | Use `make clean-all` |

### Debug Commands

```bash
# Verbose debugging
make debug

# Check prerequisites
make check

# Build with no cache
docker build --no-cache -f Dockerfile.pgbouncer -t pgbouncer:debug .

# Check layers
docker history pgbouncer:latest
```

## Command Reference

| Command | Purpose |
|---------|---------|
| `make validate` | Complete validation pipeline |
| `make all` | Build and test everything |
| `make build` | Build both images |
| `make test` | Test both images |
| `make info` | Show image information |
| `make clean` | Remove local images |
| `make debug` | Build with verbose output |
| `make check` | Check prerequisites |
| `make push` | Push to ECR (requires AWS auth) |

## Key Principles

- ✅ **Simple and reliable** - standard Docker + Make workflow
- ✅ **No complex tooling** - just Docker + Make (built-in)
- ✅ **Easy debugging** - familiar Docker commands
- ✅ **CI/CD compatible** - same commands locally and in pipelines
Loading