feat: add MkDocs Material docs site with 170 auto-generated skill pages
- mkdocs.yml: Material theme with dark/light mode, search, tabs, sitemap - scripts/generate-docs.py: auto-generates docs from all SKILL.md files - docs/index.md: landing page with domain overview and quick install - docs/getting-started.md: installation guide for Claude Code, Codex, OpenClaw - docs/skills/: 170 skill pages + 9 domain index pages - .github/workflows/static.yml: MkDocs build + GitHub Pages deploy - .gitignore: exclude site/ build output Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
50
.github/workflows/static.yml
vendored
50
.github/workflows/static.yml
vendored
@@ -1,43 +1,57 @@
|
||||
# Simple workflow for deploying static content to GitHub Pages
|
||||
name: Deploy static content to Pages
|
||||
name: Deploy Documentation to Pages
|
||||
|
||||
on:
|
||||
# Runs on pushes targeting the default branch
|
||||
push:
|
||||
branches: ["main"]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
||||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
# Single deploy job since we're just deploying
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Install MkDocs Material
|
||||
run: pip install mkdocs-material
|
||||
|
||||
- name: Generate skill pages
|
||||
run: python scripts/generate-docs.py
|
||||
|
||||
- name: Build docs
|
||||
run: mkdocs build
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: site/
|
||||
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
# Upload entire repository
|
||||
path: '.'
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -34,3 +34,6 @@ GITHUB_ISSUE_RESPONSES.md
|
||||
|
||||
# Archive folder (historical/backup files)
|
||||
archive/
|
||||
|
||||
# MkDocs build output
|
||||
site/
|
||||
|
||||
131
docs/getting-started.md
Normal file
131
docs/getting-started.md
Normal file
@@ -0,0 +1,131 @@
|
||||
---
|
||||
title: Getting Started with Claude Code Skills
|
||||
description: "How to install and use Claude Code skills and plugins for Claude Code, OpenAI Codex, and OpenClaw."
|
||||
---
|
||||
|
||||
# Getting Started
|
||||
|
||||
## Installation
|
||||
|
||||
### Claude Code (Recommended)
|
||||
|
||||
```bash
|
||||
# Step 1: Add the marketplace
|
||||
/plugin marketplace add alirezarezvani/claude-skills
|
||||
|
||||
# Step 2: Install the skills you need
|
||||
/plugin install engineering-skills@claude-code-skills
|
||||
```
|
||||
|
||||
### OpenAI Codex
|
||||
|
||||
```bash
|
||||
npx agent-skills-cli add alirezarezvani/claude-skills --agent codex
|
||||
# Or: git clone + ./scripts/codex-install.sh
|
||||
```
|
||||
|
||||
### OpenClaw
|
||||
|
||||
```bash
|
||||
bash <(curl -s https://raw.githubusercontent.com/alirezarezvani/claude-skills/main/scripts/openclaw-install.sh)
|
||||
```
|
||||
|
||||
### Manual Installation
|
||||
|
||||
```bash
|
||||
git clone https://github.com/alirezarezvani/claude-skills.git
|
||||
# Copy any skill folder to ~/.claude/skills/ (Claude Code) or ~/.codex/skills/ (Codex)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Available Skill Bundles
|
||||
|
||||
| Bundle | Command | Skills |
|
||||
|--------|---------|--------|
|
||||
| Engineering Core | `/plugin install engineering-skills@claude-code-skills` | 23 |
|
||||
| Engineering POWERFUL | `/plugin install engineering-advanced-skills@claude-code-skills` | 25 |
|
||||
| Product | `/plugin install product-skills@claude-code-skills` | 8 |
|
||||
| Marketing | `/plugin install marketing-skills@claude-code-skills` | 42 |
|
||||
| Regulatory & Quality | `/plugin install ra-qm-skills@claude-code-skills` | 12 |
|
||||
| Project Management | `/plugin install pm-skills@claude-code-skills` | 6 |
|
||||
| C-Level Advisory | `/plugin install c-level-skills@claude-code-skills` | 28 |
|
||||
| Business & Growth | `/plugin install business-growth-skills@claude-code-skills` | 4 |
|
||||
| Finance | `/plugin install finance-skills@claude-code-skills` | 1 |
|
||||
|
||||
---
|
||||
|
||||
## Using Skills
|
||||
|
||||
Once installed, skills are available as slash commands or contextual expertise:
|
||||
|
||||
### Slash Command Example
|
||||
```
|
||||
/pw:generate # Generate Playwright tests
|
||||
/si:review # Review auto-memory health
|
||||
/cs:board # Trigger a C-suite board meeting
|
||||
```
|
||||
|
||||
### Contextual Example
|
||||
```
|
||||
Using the senior-architect skill, review our microservices architecture
|
||||
and identify the top 3 scalability risks.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Python Tools
|
||||
|
||||
All 160+ Python tools use the standard library only (zero pip installs). Run them directly:
|
||||
|
||||
```bash
|
||||
# Security audit
|
||||
python3 engineering/skill-security-auditor/scripts/skill_security_auditor.py /path/to/skill/
|
||||
|
||||
# Brand voice analysis
|
||||
python3 marketing-skill/content-creator/scripts/brand_voice_analyzer.py article.txt
|
||||
|
||||
# RICE prioritization
|
||||
python3 product-team/product-manager-toolkit/scripts/rice_prioritizer.py features.csv
|
||||
|
||||
# Tech debt scoring
|
||||
python3 c-level-advisor/cto-advisor/scripts/tech_debt_analyzer.py /path/to/codebase
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Security
|
||||
|
||||
Before installing third-party skills, audit them:
|
||||
|
||||
```bash
|
||||
python3 engineering/skill-security-auditor/scripts/skill_security_auditor.py /path/to/skill/
|
||||
```
|
||||
|
||||
Returns **PASS / WARN / FAIL** with remediation guidance. Scans for command injection, data exfiltration, prompt injection, and more.
|
||||
|
||||
---
|
||||
|
||||
## Creating Your Own Skills
|
||||
|
||||
Each skill is a folder with:
|
||||
|
||||
- `SKILL.md` — frontmatter + instructions + workflows
|
||||
- `scripts/` — Python CLI tools (optional)
|
||||
- `references/` — domain knowledge (optional)
|
||||
- `assets/` — templates (optional)
|
||||
|
||||
See the [Skills & Agents Factory](https://github.com/alirezarezvani/claude-code-skills-agents-factory) for a step-by-step guide.
|
||||
|
||||
---
|
||||
|
||||
## FAQ
|
||||
|
||||
**Do I need API keys?**
|
||||
No. Skills work locally with no external API calls. Python tools use stdlib only.
|
||||
|
||||
**Can I install individual skills?**
|
||||
Yes. Use `/plugin install skill-name@claude-code-skills` for any single skill.
|
||||
|
||||
**Do skills conflict with each other?**
|
||||
No. Each skill is self-contained with no cross-dependencies.
|
||||
87
docs/index.md
Normal file
87
docs/index.md
Normal file
@@ -0,0 +1,87 @@
|
||||
---
|
||||
title: Claude Code Skills & Plugins - Documentation
|
||||
description: "169 production-ready skills and plugins for Claude Code, OpenAI Codex, and OpenClaw. Reusable expertise bundles for engineering, product, marketing, compliance, and more."
|
||||
---
|
||||
|
||||
# Claude Code Skills & Plugins
|
||||
|
||||
**169 production-ready skills** that transform AI coding agents into specialized professionals across engineering, product, marketing, compliance, and more.
|
||||
|
||||
Works natively with **Claude Code**, **OpenAI Codex**, and **OpenClaw**.
|
||||
|
||||
---
|
||||
|
||||
## Quick Install
|
||||
|
||||
```bash
|
||||
# Add the marketplace
|
||||
/plugin marketplace add alirezarezvani/claude-skills
|
||||
|
||||
# Install by domain
|
||||
/plugin install engineering-skills@claude-code-skills # 23 core engineering
|
||||
/plugin install engineering-advanced-skills@claude-code-skills # 25 POWERFUL-tier
|
||||
/plugin install product-skills@claude-code-skills # 8 product skills
|
||||
/plugin install marketing-skills@claude-code-skills # 42 marketing skills
|
||||
/plugin install ra-qm-skills@claude-code-skills # 12 regulatory/quality
|
||||
/plugin install pm-skills@claude-code-skills # 6 project management
|
||||
/plugin install c-level-skills@claude-code-skills # 28 C-level advisory
|
||||
/plugin install business-growth-skills@claude-code-skills # 4 business & growth
|
||||
/plugin install finance-skills@claude-code-skills # 1 finance
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Skills by Domain
|
||||
|
||||
| Domain | Skills | Highlights |
|
||||
|--------|--------|------------|
|
||||
| [**Engineering - Core**](skills/engineering-team/) | 23 | Architecture, frontend, backend, fullstack, QA, DevOps, SecOps, AI/ML, data, Playwright, self-improving agent |
|
||||
| [**Engineering - POWERFUL**](skills/engineering/) | 25 | Agent designer, RAG architect, database designer, CI/CD builder, security auditor, MCP builder |
|
||||
| [**Product**](skills/product-team/) | 8 | Product manager, agile PO, strategist, UX researcher, UI design, landing pages, SaaS scaffolder |
|
||||
| [**Marketing**](skills/marketing-skill/) | 42 | Content, SEO, CRO, Channels, Growth, Intelligence, Sales pods with 27 Python tools |
|
||||
| [**Project Management**](skills/project-management/) | 6 | Senior PM, scrum master, Jira, Confluence, Atlassian admin |
|
||||
| [**C-Level Advisory**](skills/c-level-advisor/) | 28 | Full C-suite (10 roles) + orchestration + board meetings + culture |
|
||||
| [**Regulatory & Quality**](skills/ra-qm-team/) | 12 | ISO 13485, MDR 2017/745, FDA, ISO 27001, GDPR, CAPA, risk management |
|
||||
| [**Business & Growth**](skills/business-growth/) | 4 | Customer success, sales engineer, revenue ops, contracts & proposals |
|
||||
| [**Finance**](skills/finance/) | 1 | Financial analyst (DCF, budgeting, forecasting) |
|
||||
|
||||
---
|
||||
|
||||
## Key Features
|
||||
|
||||
- **160+ Python CLI tools** — all stdlib-only, zero pip installs required
|
||||
- **250+ reference guides** — embedded domain expertise
|
||||
- **Plugin marketplace** — one-command install for any skill bundle
|
||||
- **Multi-platform** — Claude Code, OpenAI Codex, OpenClaw
|
||||
- **Security auditor** — scan skills for malicious code before installation
|
||||
- **Self-improving agent** — auto-memory curation and pattern promotion
|
||||
|
||||
---
|
||||
|
||||
## How Skills Work
|
||||
|
||||
Each skill is a self-contained package:
|
||||
|
||||
```
|
||||
skill-name/
|
||||
SKILL.md # Instructions + workflows
|
||||
scripts/ # Python CLI tools
|
||||
references/ # Expert knowledge bases
|
||||
assets/ # Templates
|
||||
```
|
||||
|
||||
Knowledge flows from `references/` into `SKILL.md` workflows, executed via `scripts/`, applied using `assets/` templates.
|
||||
|
||||
---
|
||||
|
||||
## Links
|
||||
|
||||
- [GitHub Repository](https://github.com/alirezarezvani/claude-skills)
|
||||
- [Getting Started](getting-started.md)
|
||||
- [Contributing](https://github.com/alirezarezvani/claude-skills/blob/main/CONTRIBUTING.md)
|
||||
- [Skills & Agents Factory](https://github.com/alirezarezvani/claude-code-skills-agents-factory) — methodology for building skills at scale
|
||||
- [Claude Code Tresor](https://github.com/alirezarezvani/claude-code-tresor) — productivity toolkit with 60+ prompt templates
|
||||
|
||||
---
|
||||
|
||||
**Built by [Alireza Rezvani](https://alirezarezvani.com)** | [Medium](https://alirezarezvani.medium.com) | [Twitter](https://twitter.com/nginitycloud)
|
||||
428
docs/skills/business-growth/contract-and-proposal-writer.md
Normal file
428
docs/skills/business-growth/contract-and-proposal-writer.md
Normal file
@@ -0,0 +1,428 @@
|
||||
---
|
||||
title: "Contract & Proposal Writer"
|
||||
description: "Contract & Proposal Writer - Claude Code skill from the Business & Growth domain."
|
||||
---
|
||||
|
||||
# Contract & Proposal Writer
|
||||
|
||||
**Domain:** Business & Growth | **Skill:** `contract-and-proposal-writer` | **Source:** [`business-growth/contract-and-proposal-writer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/business-growth/contract-and-proposal-writer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Business Growth
|
||||
**Domain:** Legal Documents, Business Development, Client Relations
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Generate professional, jurisdiction-aware business documents: freelance contracts, project proposals, SOWs, NDAs, and MSAs. Outputs structured Markdown with docx conversion instructions. Covers US (Delaware), EU (GDPR), UK, and DACH (German law) jurisdictions.
|
||||
|
||||
**Not a substitute for legal counsel.** Use these templates as strong starting points; review with an attorney for high-value or complex engagements.
|
||||
|
||||
---
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- Freelance development contracts (fixed-price & hourly)
|
||||
- Project proposals with timeline/budget breakdown
|
||||
- Statements of Work (SOW) with deliverables matrix
|
||||
- NDAs (mutual & one-way)
|
||||
- Master Service Agreements (MSA)
|
||||
- Jurisdiction-specific clauses (US/EU/UK/DACH)
|
||||
- GDPR Data Processing Addenda (EU/DACH)
|
||||
|
||||
---
|
||||
|
||||
## Key Clauses Reference
|
||||
|
||||
| Clause | Options |
|
||||
|--------|---------|
|
||||
| Payment terms | Net-30, milestone-based, monthly retainer |
|
||||
| IP ownership | Work-for-hire (US), assignment (EU/UK), license-back |
|
||||
| Liability cap | 1x contract value (standard), 3x (high-risk) |
|
||||
| Termination | For cause (14-day cure), convenience (30/60/90-day notice) |
|
||||
| Confidentiality | 2-5 year term, perpetual for trade secrets |
|
||||
| Warranty | "As-is" disclaimer, limited 30/90-day fix warranty |
|
||||
| Dispute resolution | Arbitration (AAA/ICC), courts (jurisdiction-specific) |
|
||||
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
- Starting a new client engagement and need a contract fast
|
||||
- Client asks for a proposal with pricing and timeline
|
||||
- Partnership or vendor relationship requiring an MSA
|
||||
- Protecting IP or confidential information with an NDA
|
||||
- EU/DACH project requiring GDPR-compliant data clauses
|
||||
|
||||
---
|
||||
|
||||
## Workflow
|
||||
|
||||
### 1. Gather Requirements
|
||||
|
||||
Ask the user:
|
||||
|
||||
1. Document type? (contract / proposal / SOW / NDA / MSA)
|
||||
2. Jurisdiction? (US-Delaware / EU / UK / DACH)
|
||||
3. Engagement type? (fixed-price / hourly / retainer)
|
||||
4. Parties? (names, roles, business addresses)
|
||||
5. Scope summary? (1-3 sentences)
|
||||
6. Total value or hourly rate?
|
||||
7. Start date / end date or duration?
|
||||
8. Special requirements? (IP assignment, white-label, subcontractors)
|
||||
|
||||
### 2. Select Template
|
||||
|
||||
| Type | Jurisdiction | Template |
|
||||
|------|-------------|----------|
|
||||
| Dev contract fixed | Any | Template A |
|
||||
| Consulting retainer | Any | Template B |
|
||||
| SaaS partnership | Any | Template C |
|
||||
| NDA mutual | US/EU/UK/DACH | NDA-M |
|
||||
| NDA one-way | US/EU/UK/DACH | NDA-OW |
|
||||
| SOW | Any | SOW base |
|
||||
|
||||
### 3. Generate & Fill
|
||||
|
||||
Fill all [BRACKETED] placeholders. Flag missing data as "REQUIRED".
|
||||
|
||||
### 4. Convert to DOCX
|
||||
|
||||
```bash
|
||||
# Install pandoc
|
||||
brew install pandoc # macOS
|
||||
apt install pandoc # Ubuntu
|
||||
|
||||
# Basic conversion
|
||||
pandoc contract.md -o contract.docx \
|
||||
--reference-doc=reference.docx \
|
||||
-V geometry:margin=1in
|
||||
|
||||
# With numbered sections (legal style)
|
||||
pandoc contract.md -o contract.docx \
|
||||
--number-sections \
|
||||
-V documentclass=article \
|
||||
-V fontsize=11pt
|
||||
|
||||
# With custom company template
|
||||
pandoc contract.md -o contract.docx \
|
||||
--reference-doc=company-template.docx
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Jurisdiction Notes
|
||||
|
||||
### US (Delaware)
|
||||
- Governing law: State of Delaware
|
||||
- Work-for-hire doctrine applies (Copyright Act 101)
|
||||
- Arbitration: AAA Commercial Rules
|
||||
- Non-compete: enforceable with reasonable scope/time
|
||||
|
||||
### EU (GDPR)
|
||||
- Must include Data Processing Addendum if handling personal data
|
||||
- IP assignment requires separate written deed in some member states
|
||||
- Arbitration: ICC or local chamber
|
||||
|
||||
### UK (post-Brexit)
|
||||
- Governed by English law
|
||||
- IP: Patents Act 1977 / CDPA 1988
|
||||
- Arbitration: LCIA Rules
|
||||
- Data: UK GDPR (post-Brexit equivalent)
|
||||
|
||||
### DACH (Germany / Austria / Switzerland)
|
||||
- BGB (Buergerliches Gesetzbuch) governs contracts
|
||||
- Written form requirement for certain clauses (para 126 BGB)
|
||||
- IP: Author always retains moral rights; must explicitly transfer Nutzungsrechte
|
||||
- Non-competes: max 2 years, compensation required (para 74 HGB)
|
||||
- Jurisdiction: German courts (Landgericht) or DIS arbitration
|
||||
- DSGVO (GDPR implementation) mandatory for personal data processing
|
||||
- Kuendigungsfristen: statutory notice periods apply
|
||||
|
||||
---
|
||||
|
||||
## Template A: Web Dev Fixed-Price Contract
|
||||
|
||||
```markdown
|
||||
# SOFTWARE DEVELOPMENT AGREEMENT
|
||||
|
||||
**Effective Date:** [DATE]
|
||||
**Client:** [CLIENT LEGAL NAME], [ADDRESS] ("Client")
|
||||
**Developer:** [YOUR LEGAL NAME / COMPANY], [ADDRESS] ("Developer")
|
||||
|
||||
---
|
||||
|
||||
## 1. SERVICES
|
||||
|
||||
Developer agrees to design, develop, and deliver:
|
||||
|
||||
**Project:** [PROJECT NAME]
|
||||
**Description:** [1-3 sentence scope]
|
||||
|
||||
**Deliverables:**
|
||||
- [Deliverable 1] due [DATE]
|
||||
- [Deliverable 2] due [DATE]
|
||||
- [Deliverable 3] due [DATE]
|
||||
|
||||
## 2. PAYMENT
|
||||
|
||||
**Total Fee:** [CURRENCY] [AMOUNT]
|
||||
|
||||
| Milestone | Amount | Due |
|
||||
|-----------|--------|-----|
|
||||
| Contract signing | 50% | Upon execution |
|
||||
| Beta delivery | 25% | [DATE] |
|
||||
| Final acceptance | 25% | Within 5 days of acceptance |
|
||||
|
||||
Late payments accrue interest at 1.5% per month.
|
||||
Client has [10] business days to accept or reject deliverables in writing.
|
||||
|
||||
## 3. INTELLECTUAL PROPERTY
|
||||
|
||||
Upon receipt of full payment, Developer assigns all right, title, and interest in the
|
||||
Work Product to Client as a work made for hire (US) / by assignment of future copyright (EU/UK).
|
||||
|
||||
Developer retains the right to display Work Product in portfolio unless Client
|
||||
requests confidentiality in writing within [30] days of delivery.
|
||||
|
||||
Pre-existing IP (tools, libraries, frameworks) remains Developer's property.
|
||||
Developer grants Client a perpetual, royalty-free license to use pre-existing IP
|
||||
as embedded in the Work Product.
|
||||
|
||||
## 4. CONFIDENTIALITY
|
||||
|
||||
Each party keeps confidential all non-public information received from the other.
|
||||
This obligation survives termination for [3] years.
|
||||
|
||||
## 5. WARRANTIES
|
||||
|
||||
Developer warrants Work Product will substantially conform to specifications for
|
||||
[90] days post-delivery. Developer will fix material defects at no charge during
|
||||
this period. EXCEPT AS STATED, WORK PRODUCT IS PROVIDED "AS IS."
|
||||
|
||||
## 6. LIABILITY
|
||||
|
||||
Developer's total liability shall not exceed total fees paid under this Agreement.
|
||||
Neither party liable for indirect, incidental, or consequential damages.
|
||||
|
||||
## 7. TERMINATION
|
||||
|
||||
For Cause: Either party may terminate if the other materially breaches and fails
|
||||
to cure within [14] days of written notice.
|
||||
|
||||
For Convenience: Client may terminate with [30] days written notice and pay for
|
||||
all work completed plus [10%] of remaining contract value.
|
||||
|
||||
## 8. DISPUTE RESOLUTION
|
||||
|
||||
US: Binding arbitration under AAA Commercial Rules, [CITY], Delaware law.
|
||||
EU/DACH: ICC / DIS arbitration, [CITY]. German / English law.
|
||||
UK: LCIA Rules, London. English law.
|
||||
|
||||
## 9. GENERAL
|
||||
|
||||
- Entire Agreement: Supersedes all prior discussions.
|
||||
- Amendments: Must be in writing, signed by both parties.
|
||||
- Independent Contractor: Developer is not an employee of Client.
|
||||
|
||||
---
|
||||
|
||||
CLIENT: _________________________ Date: _________
|
||||
[CLIENT NAME], [TITLE]
|
||||
|
||||
DEVELOPER: _________________________ Date: _________
|
||||
[YOUR NAME], [TITLE]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Template B: Monthly Consulting Retainer
|
||||
|
||||
```markdown
|
||||
# CONSULTING RETAINER AGREEMENT
|
||||
|
||||
**Effective Date:** [DATE]
|
||||
**Client:** [CLIENT LEGAL NAME] ("Client")
|
||||
**Consultant:** [YOUR NAME / COMPANY] ("Consultant")
|
||||
|
||||
---
|
||||
|
||||
## 1. SERVICES
|
||||
|
||||
Consultant provides [DOMAIN, e.g., "CTO advisory and technical architecture"] services.
|
||||
|
||||
**Monthly Hours:** Up to [X] hours/month
|
||||
**Rollover:** Unused hours [do / do not] roll over (max [X] hours banked)
|
||||
**Overflow Rate:** [CURRENCY] [RATE]/hr for hours exceeding retainer
|
||||
|
||||
## 2. FEES
|
||||
|
||||
**Monthly Retainer:** [CURRENCY] [AMOUNT], due on the 1st of each month.
|
||||
**Payment Method:** Bank transfer / Stripe / SEPA direct debit
|
||||
**Late Payment:** 2% monthly interest after [10]-day grace period.
|
||||
|
||||
## 3. TERM AND TERMINATION
|
||||
|
||||
**Initial Term:** [3] months starting [DATE]
|
||||
**Renewal:** Auto-renews monthly unless either party gives [30] days written notice.
|
||||
**Immediate termination:** For material breach uncured after [7] days notice.
|
||||
|
||||
On termination, Consultant delivers all work in progress within [5] business days.
|
||||
|
||||
## 4. INTELLECTUAL PROPERTY
|
||||
|
||||
Work product created under this Agreement belongs to [Client / Consultant / jointly].
|
||||
Advisory output (recommendations, analyses) are Client property upon full payment.
|
||||
|
||||
## 5. EXCLUSIVITY
|
||||
|
||||
[OPTION A - Non-exclusive:]
|
||||
This Agreement is non-exclusive. Consultant may work with other clients.
|
||||
|
||||
[OPTION B - Partial exclusivity:]
|
||||
Consultant will not work with direct competitors of Client during the term
|
||||
and [90] days thereafter.
|
||||
|
||||
## 6. CONFIDENTIALITY AND DATA PROTECTION
|
||||
|
||||
EU/DACH: If Consultant processes personal data on behalf of Client, the parties
|
||||
shall execute a Data Processing Agreement (DPA) per Art. 28 GDPR.
|
||||
|
||||
## 7. LIABILITY
|
||||
|
||||
Consultant's aggregate liability is capped at [3x] the fees paid in the [3] months
|
||||
preceding the claim.
|
||||
|
||||
---
|
||||
|
||||
Signatures as above.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Template C: SaaS Partnership Agreement
|
||||
|
||||
```markdown
|
||||
# SAAS PARTNERSHIP AGREEMENT
|
||||
|
||||
**Effective Date:** [DATE]
|
||||
**Provider:** [NAME], [ADDRESS]
|
||||
**Partner:** [NAME], [ADDRESS]
|
||||
|
||||
---
|
||||
|
||||
## 1. PURPOSE
|
||||
|
||||
Provider grants Partner [reseller / referral / white-label / integration] rights to
|
||||
Provider's [PRODUCT NAME] ("Software") subject to this Agreement.
|
||||
|
||||
## 2. PARTNERSHIP TYPE
|
||||
|
||||
[ ] Referral: Partner refers customers; earns [X%] of first-year ARR per referral.
|
||||
[ ] Reseller: Partner resells licenses; earns [X%] discount off list price.
|
||||
[ ] White-label: Partner rebrands Software; pays [AMOUNT]/month platform fee.
|
||||
[ ] Integration: Partner integrates Software via API; terms in Exhibit A.
|
||||
|
||||
## 3. REVENUE SHARE
|
||||
|
||||
| Tier | Monthly ARR Referred | Commission |
|
||||
|------|---------------------|------------|
|
||||
| Bronze | < $10,000 | [X]% |
|
||||
| Silver | $10,000-$50,000 | [X]% |
|
||||
| Gold | > $50,000 | [X]% |
|
||||
|
||||
Payout: Net-30 after month close, minimum $[500] threshold.
|
||||
|
||||
## 4. INTELLECTUAL PROPERTY
|
||||
|
||||
Each party retains all IP in its own products. No implied licenses.
|
||||
Partner may use Provider's marks per Provider's Brand Guidelines (Exhibit B).
|
||||
|
||||
## 5. DATA AND PRIVACY
|
||||
|
||||
Each party is an independent data controller for its own customers.
|
||||
Joint processing requires a separate DPA (Exhibit C - EU/DACH projects).
|
||||
|
||||
## 6. TERM
|
||||
|
||||
Initial: [12] months. Renews annually unless [90]-day written notice given.
|
||||
Termination for Cause: [30]-day cure period for material breach.
|
||||
|
||||
## 7. LIMITATION OF LIABILITY
|
||||
|
||||
Each party's liability capped at [1x] fees paid/received in prior [12] months.
|
||||
Mutual indemnification for IP infringement claims from own products.
|
||||
|
||||
---
|
||||
|
||||
Signatures, exhibits, and governing law per applicable jurisdiction.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## GDPR Data Processing Addendum (EU/DACH Clause Block)
|
||||
|
||||
```markdown
|
||||
## DATA PROCESSING ADDENDUM (Art. 28 GDPR)
|
||||
|
||||
Controller: [CLIENT NAME]
|
||||
Processor: [CONTRACTOR NAME]
|
||||
|
||||
### Subject Matter
|
||||
Processor processes personal data on behalf of Controller solely to perform services
|
||||
under the main Agreement.
|
||||
|
||||
### Categories of Data Subjects
|
||||
[e.g., end users, employees, customers]
|
||||
|
||||
### Categories of Personal Data
|
||||
[e.g., names, email addresses, usage data]
|
||||
|
||||
### Processing Duration
|
||||
For the term of the main Agreement; deletion within [30] days of termination.
|
||||
|
||||
### Processor Obligations
|
||||
- Process data only on Controller's documented instructions
|
||||
- Ensure persons authorized to process have committed to confidentiality
|
||||
- Implement technical and organizational measures per Art. 32 GDPR
|
||||
- Assist Controller with data subject rights requests
|
||||
- Not engage sub-processors without prior written consent
|
||||
- Delete or return all personal data upon termination
|
||||
|
||||
### Sub-processors (current as of Effective Date)
|
||||
| Sub-processor | Location | Purpose |
|
||||
|--------------|----------|---------|
|
||||
| [AWS / GCP / Azure] | [Region] | Cloud hosting |
|
||||
| [Other] | [Location] | [Purpose] |
|
||||
|
||||
### Cross-border Transfers
|
||||
Data transfers outside EEA covered by: [ ] SCCs [ ] Adequacy Decision [ ] BCRs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
1. **Missing IP assignment language** - "work for hire" alone is insufficient in EU; need explicit assignment of Nutzungsrechte in DACH
|
||||
2. **Vague acceptance criteria** - Always define what "accepted" means (written sign-off, X days to reject)
|
||||
3. **No change order process** - Scope creep kills fixed-price projects; add a clause for out-of-scope work
|
||||
4. **Jurisdiction mismatch** - Choosing Delaware law for a German-only project creates enforcement problems
|
||||
5. **Missing limitation of liability** - Without a cap, one bug could mean unlimited damages
|
||||
6. **Oral amendments** - Contracts modified verbally are hard to enforce; always require written amendments
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Use **milestone payments** over net-30 for projects >$10K - reduces cash flow risk
|
||||
- For EU/DACH: always check if a DPA is needed (any personal data = yes)
|
||||
- For DACH: include a **Schriftformklausel** (written form clause) explicitly
|
||||
- Add a **force majeure** clause for anything over 3 months
|
||||
- For retainers: define response time SLAs (e.g., 4h urgent / 24h normal)
|
||||
- Keep templates in version control; track changes with `git diff`
|
||||
- Review annually - laws change, especially GDPR enforcement interpretations
|
||||
- For NDAs: always specify the return/destruction of confidential materials on termination
|
||||
321
docs/skills/business-growth/customer-success-manager.md
Normal file
321
docs/skills/business-growth/customer-success-manager.md
Normal file
@@ -0,0 +1,321 @@
|
||||
---
|
||||
title: "Customer Success Manager"
|
||||
description: "Customer Success Manager - Claude Code skill from the Business & Growth domain."
|
||||
---
|
||||
|
||||
# Customer Success Manager
|
||||
|
||||
**Domain:** Business & Growth | **Skill:** `customer-success-manager` | **Source:** [`business-growth/customer-success-manager/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/business-growth/customer-success-manager/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Customer Success Manager
|
||||
|
||||
Production-grade customer success analytics with multi-dimensional health scoring, churn risk prediction, and expansion opportunity identification. Three Python CLI tools provide deterministic, repeatable analysis using standard library only -- no external dependencies, no API calls, no ML models.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Capabilities](#capabilities)
|
||||
- [Input Requirements](#input-requirements)
|
||||
- [Output Formats](#output-formats)
|
||||
- [How to Use](#how-to-use)
|
||||
- [Scripts](#scripts)
|
||||
- [Reference Guides](#reference-guides)
|
||||
- [Templates](#templates)
|
||||
- [Best Practices](#best-practices)
|
||||
- [Limitations](#limitations)
|
||||
|
||||
---
|
||||
|
||||
## Capabilities
|
||||
|
||||
- **Customer Health Scoring**: Multi-dimensional weighted scoring across usage, engagement, support, and relationship dimensions with Red/Yellow/Green classification
|
||||
- **Churn Risk Analysis**: Behavioral signal detection with tier-based intervention playbooks and time-to-renewal urgency multipliers
|
||||
- **Expansion Opportunity Scoring**: Adoption depth analysis, whitespace mapping, and revenue opportunity estimation with effort-vs-impact prioritization
|
||||
- **Segment-Aware Benchmarking**: Configurable thresholds for Enterprise, Mid-Market, and SMB customer segments
|
||||
- **Trend Analysis**: Period-over-period comparison to detect improving or declining trajectories
|
||||
- **Executive Reporting**: QBR templates, success plans, and executive business review templates
|
||||
|
||||
---
|
||||
|
||||
## Input Requirements
|
||||
|
||||
All scripts accept a JSON file as positional input argument. See `assets/sample_customer_data.json` for complete examples.
|
||||
|
||||
### Health Score Calculator
|
||||
|
||||
```json
|
||||
{
|
||||
"customers": [
|
||||
{
|
||||
"customer_id": "CUST-001",
|
||||
"name": "Acme Corp",
|
||||
"segment": "enterprise",
|
||||
"arr": 120000,
|
||||
"usage": {
|
||||
"login_frequency": 85,
|
||||
"feature_adoption": 72,
|
||||
"dau_mau_ratio": 0.45
|
||||
},
|
||||
"engagement": {
|
||||
"support_ticket_volume": 3,
|
||||
"meeting_attendance": 90,
|
||||
"nps_score": 8,
|
||||
"csat_score": 4.2
|
||||
},
|
||||
"support": {
|
||||
"open_tickets": 2,
|
||||
"escalation_rate": 0.05,
|
||||
"avg_resolution_hours": 18
|
||||
},
|
||||
"relationship": {
|
||||
"executive_sponsor_engagement": 80,
|
||||
"multi_threading_depth": 4,
|
||||
"renewal_sentiment": "positive"
|
||||
},
|
||||
"previous_period": {
|
||||
"usage_score": 70,
|
||||
"engagement_score": 65,
|
||||
"support_score": 75,
|
||||
"relationship_score": 60
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Churn Risk Analyzer
|
||||
|
||||
```json
|
||||
{
|
||||
"customers": [
|
||||
{
|
||||
"customer_id": "CUST-001",
|
||||
"name": "Acme Corp",
|
||||
"segment": "enterprise",
|
||||
"arr": 120000,
|
||||
"contract_end_date": "2026-06-30",
|
||||
"usage_decline": {
|
||||
"login_trend": -15,
|
||||
"feature_adoption_change": -10,
|
||||
"dau_mau_change": -0.08
|
||||
},
|
||||
"engagement_drop": {
|
||||
"meeting_cancellations": 2,
|
||||
"response_time_days": 5,
|
||||
"nps_change": -3
|
||||
},
|
||||
"support_issues": {
|
||||
"open_escalations": 1,
|
||||
"unresolved_critical": 0,
|
||||
"satisfaction_trend": "declining"
|
||||
},
|
||||
"relationship_signals": {
|
||||
"champion_left": false,
|
||||
"sponsor_change": false,
|
||||
"competitor_mentions": 1
|
||||
},
|
||||
"commercial_factors": {
|
||||
"contract_type": "annual",
|
||||
"pricing_complaints": false,
|
||||
"budget_cuts_mentioned": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Expansion Opportunity Scorer
|
||||
|
||||
```json
|
||||
{
|
||||
"customers": [
|
||||
{
|
||||
"customer_id": "CUST-001",
|
||||
"name": "Acme Corp",
|
||||
"segment": "enterprise",
|
||||
"arr": 120000,
|
||||
"contract": {
|
||||
"licensed_seats": 100,
|
||||
"active_seats": 95,
|
||||
"plan_tier": "professional",
|
||||
"available_tiers": ["professional", "enterprise", "enterprise_plus"]
|
||||
},
|
||||
"product_usage": {
|
||||
"core_platform": {"adopted": true, "usage_pct": 85},
|
||||
"analytics_module": {"adopted": true, "usage_pct": 60},
|
||||
"integrations_module": {"adopted": false, "usage_pct": 0},
|
||||
"api_access": {"adopted": true, "usage_pct": 40},
|
||||
"advanced_reporting": {"adopted": false, "usage_pct": 0}
|
||||
},
|
||||
"departments": {
|
||||
"current": ["engineering", "product"],
|
||||
"potential": ["marketing", "sales", "support"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Output Formats
|
||||
|
||||
All scripts support two output formats via the `--format` flag:
|
||||
|
||||
- **`text`** (default): Human-readable formatted output for terminal viewing
|
||||
- **`json`**: Machine-readable JSON output for integrations and pipelines
|
||||
|
||||
---
|
||||
|
||||
## How to Use
|
||||
|
||||
### Quick Start
|
||||
|
||||
```bash
|
||||
# Health scoring
|
||||
python scripts/health_score_calculator.py assets/sample_customer_data.json
|
||||
python scripts/health_score_calculator.py assets/sample_customer_data.json --format json
|
||||
|
||||
# Churn risk analysis
|
||||
python scripts/churn_risk_analyzer.py assets/sample_customer_data.json
|
||||
python scripts/churn_risk_analyzer.py assets/sample_customer_data.json --format json
|
||||
|
||||
# Expansion opportunity scoring
|
||||
python scripts/expansion_opportunity_scorer.py assets/sample_customer_data.json
|
||||
python scripts/expansion_opportunity_scorer.py assets/sample_customer_data.json --format json
|
||||
```
|
||||
|
||||
### Workflow Integration
|
||||
|
||||
```bash
|
||||
# 1. Score customer health across portfolio
|
||||
python scripts/health_score_calculator.py customer_portfolio.json --format json > health_results.json
|
||||
|
||||
# 2. Identify at-risk accounts
|
||||
python scripts/churn_risk_analyzer.py customer_portfolio.json --format json > risk_results.json
|
||||
|
||||
# 3. Find expansion opportunities in healthy accounts
|
||||
python scripts/expansion_opportunity_scorer.py customer_portfolio.json --format json > expansion_results.json
|
||||
|
||||
# 4. Prepare QBR using templates
|
||||
# Reference: assets/qbr_template.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Scripts
|
||||
|
||||
### 1. health_score_calculator.py
|
||||
|
||||
**Purpose:** Multi-dimensional customer health scoring with trend analysis and segment-aware benchmarking.
|
||||
|
||||
**Dimensions and Weights:**
|
||||
| Dimension | Weight | Metrics |
|
||||
|-----------|--------|---------|
|
||||
| Usage | 30% | Login frequency, feature adoption, DAU/MAU ratio |
|
||||
| Engagement | 25% | Support ticket volume, meeting attendance, NPS/CSAT |
|
||||
| Support | 20% | Open tickets, escalation rate, avg resolution time |
|
||||
| Relationship | 25% | Executive sponsor engagement, multi-threading depth, renewal sentiment |
|
||||
|
||||
**Classification:**
|
||||
- Green (75-100): Healthy -- customer achieving value
|
||||
- Yellow (50-74): Needs attention -- monitor closely
|
||||
- Red (0-49): At risk -- immediate intervention required
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
python scripts/health_score_calculator.py customer_data.json
|
||||
python scripts/health_score_calculator.py customer_data.json --format json
|
||||
```
|
||||
|
||||
### 2. churn_risk_analyzer.py
|
||||
|
||||
**Purpose:** Identify at-risk accounts with behavioral signal detection and tier-based intervention recommendations.
|
||||
|
||||
**Risk Signal Weights:**
|
||||
| Signal Category | Weight | Indicators |
|
||||
|----------------|--------|------------|
|
||||
| Usage Decline | 30% | Login trend, feature adoption change, DAU/MAU change |
|
||||
| Engagement Drop | 25% | Meeting cancellations, response time, NPS change |
|
||||
| Support Issues | 20% | Open escalations, unresolved critical, satisfaction trend |
|
||||
| Relationship Signals | 15% | Champion left, sponsor change, competitor mentions |
|
||||
| Commercial Factors | 10% | Contract type, pricing complaints, budget cuts |
|
||||
|
||||
**Risk Tiers:**
|
||||
- Critical (80-100): Immediate executive escalation
|
||||
- High (60-79): Urgent CSM intervention
|
||||
- Medium (40-59): Proactive outreach
|
||||
- Low (0-39): Standard monitoring
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
python scripts/churn_risk_analyzer.py customer_data.json
|
||||
python scripts/churn_risk_analyzer.py customer_data.json --format json
|
||||
```
|
||||
|
||||
### 3. expansion_opportunity_scorer.py
|
||||
|
||||
**Purpose:** Identify upsell, cross-sell, and expansion opportunities with revenue estimation and priority ranking.
|
||||
|
||||
**Expansion Types:**
|
||||
- **Upsell**: Upgrade to higher tier or more of existing product
|
||||
- **Cross-sell**: Add new product modules
|
||||
- **Expansion**: Additional seats or departments
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
python scripts/expansion_opportunity_scorer.py customer_data.json
|
||||
python scripts/expansion_opportunity_scorer.py customer_data.json --format json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Reference Guides
|
||||
|
||||
| Reference | Description |
|
||||
|-----------|-------------|
|
||||
| `references/health-scoring-framework.md` | Complete health scoring methodology, dimension definitions, weighting rationale, threshold calibration |
|
||||
| `references/cs-playbooks.md` | Intervention playbooks for each risk tier, onboarding, renewal, expansion, and escalation procedures |
|
||||
| `references/cs-metrics-benchmarks.md` | Industry benchmarks for NRR, GRR, churn rates, health scores, expansion rates by segment and industry |
|
||||
|
||||
---
|
||||
|
||||
## Templates
|
||||
|
||||
| Template | Purpose |
|
||||
|----------|---------|
|
||||
| `assets/qbr_template.md` | Quarterly Business Review presentation structure |
|
||||
| `assets/success_plan_template.md` | Customer success plan with goals, milestones, and metrics |
|
||||
| `assets/onboarding_checklist_template.md` | 90-day onboarding checklist with phase gates |
|
||||
| `assets/executive_business_review_template.md` | Executive stakeholder review for strategic accounts |
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Score regularly**: Run health scoring weekly for Enterprise, bi-weekly for Mid-Market, monthly for SMB
|
||||
2. **Act on trends, not snapshots**: A declining Green is more urgent than a stable Yellow
|
||||
3. **Combine signals**: Use all three scripts together for a complete customer picture
|
||||
4. **Calibrate thresholds**: Adjust segment benchmarks based on your product and industry
|
||||
5. **Document interventions**: Track what actions you took and outcomes for playbook refinement
|
||||
6. **Prepare with data**: Run scripts before every QBR and executive meeting
|
||||
|
||||
---
|
||||
|
||||
## Limitations
|
||||
|
||||
- **No real-time data**: Scripts analyze point-in-time snapshots from JSON input files
|
||||
- **No CRM integration**: Data must be exported manually from your CRM/CS platform
|
||||
- **Deterministic only**: No predictive ML -- scoring is algorithmic based on weighted signals
|
||||
- **Threshold tuning**: Default thresholds are industry-standard but may need calibration for your business
|
||||
- **Revenue estimates**: Expansion revenue estimates are approximations based on usage patterns
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** February 2026
|
||||
**Tools:** 3 Python CLI tools
|
||||
**Dependencies:** Python 3.7+ standard library only
|
||||
15
docs/skills/business-growth/index.md
Normal file
15
docs/skills/business-growth/index.md
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: "Business & Growth Skills"
|
||||
description: "All Business & Growth skills for Claude Code, OpenAI Codex, and OpenClaw."
|
||||
---
|
||||
|
||||
# Business & Growth Skills
|
||||
|
||||
4 skills in this domain.
|
||||
|
||||
| Skill | Description |
|
||||
|-------|-------------|
|
||||
| [Contract & Proposal Writer](contract-and-proposal-writer.md) | `contract-and-proposal-writer` |
|
||||
| [Customer Success Manager](customer-success-manager.md) | `customer-success-manager` |
|
||||
| [Revenue Operations](revenue-operations.md) | `revenue-operations` |
|
||||
| [Sales Engineer Skill](sales-engineer.md) | `sales-engineer` |
|
||||
293
docs/skills/business-growth/revenue-operations.md
Normal file
293
docs/skills/business-growth/revenue-operations.md
Normal file
@@ -0,0 +1,293 @@
|
||||
---
|
||||
title: "Revenue Operations"
|
||||
description: "Revenue Operations - Claude Code skill from the Business & Growth domain."
|
||||
---
|
||||
|
||||
# Revenue Operations
|
||||
|
||||
**Domain:** Business & Growth | **Skill:** `revenue-operations` | **Source:** [`business-growth/revenue-operations/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/business-growth/revenue-operations/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Revenue Operations
|
||||
|
||||
Pipeline analysis, forecast accuracy tracking, and GTM efficiency measurement for SaaS revenue teams.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Quick Start](#quick-start)
|
||||
- [Tools Overview](#tools-overview)
|
||||
- [Pipeline Analyzer](#1-pipeline-analyzer)
|
||||
- [Forecast Accuracy Tracker](#2-forecast-accuracy-tracker)
|
||||
- [GTM Efficiency Calculator](#3-gtm-efficiency-calculator)
|
||||
- [Revenue Operations Workflows](#revenue-operations-workflows)
|
||||
- [Weekly Pipeline Review](#weekly-pipeline-review)
|
||||
- [Forecast Accuracy Review](#forecast-accuracy-review)
|
||||
- [GTM Efficiency Audit](#gtm-efficiency-audit)
|
||||
- [Quarterly Business Review](#quarterly-business-review)
|
||||
- [Reference Documentation](#reference-documentation)
|
||||
- [Templates](#templates)
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Analyze pipeline health and coverage
|
||||
python scripts/pipeline_analyzer.py --input assets/sample_pipeline_data.json --format text
|
||||
|
||||
# Track forecast accuracy over multiple periods
|
||||
python scripts/forecast_accuracy_tracker.py assets/sample_forecast_data.json --format text
|
||||
|
||||
# Calculate GTM efficiency metrics
|
||||
python scripts/gtm_efficiency_calculator.py assets/sample_gtm_data.json --format text
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tools Overview
|
||||
|
||||
### 1. Pipeline Analyzer
|
||||
|
||||
Analyzes sales pipeline health including coverage ratios, stage conversion rates, deal velocity, aging risks, and concentration risks.
|
||||
|
||||
**Input:** JSON file with deals, quota, and stage configuration
|
||||
**Output:** Coverage ratios, conversion rates, velocity metrics, aging flags, risk assessment
|
||||
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
# Text report (human-readable)
|
||||
python scripts/pipeline_analyzer.py --input pipeline.json --format text
|
||||
|
||||
# JSON output (for dashboards/integrations)
|
||||
python scripts/pipeline_analyzer.py --input pipeline.json --format json
|
||||
```
|
||||
|
||||
**Key Metrics Calculated:**
|
||||
- **Pipeline Coverage Ratio** -- Total pipeline value / quota target (healthy: 3-4x)
|
||||
- **Stage Conversion Rates** -- Stage-to-stage progression rates
|
||||
- **Sales Velocity** -- (Opportunities x Avg Deal Size x Win Rate) / Avg Sales Cycle
|
||||
- **Deal Aging** -- Flags deals exceeding 2x average cycle time per stage
|
||||
- **Concentration Risk** -- Warns when >40% of pipeline is in a single deal
|
||||
- **Coverage Gap Analysis** -- Identifies quarters with insufficient pipeline
|
||||
|
||||
**Input Schema:**
|
||||
|
||||
```json
|
||||
{
|
||||
"quota": 500000,
|
||||
"stages": ["Discovery", "Qualification", "Proposal", "Negotiation", "Closed Won"],
|
||||
"average_cycle_days": 45,
|
||||
"deals": [
|
||||
{
|
||||
"id": "D001",
|
||||
"name": "Acme Corp",
|
||||
"stage": "Proposal",
|
||||
"value": 85000,
|
||||
"age_days": 32,
|
||||
"close_date": "2025-03-15",
|
||||
"owner": "rep_1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Forecast Accuracy Tracker
|
||||
|
||||
Tracks forecast accuracy over time using MAPE, detects systematic bias, analyzes trends, and provides category-level breakdowns.
|
||||
|
||||
**Input:** JSON file with forecast periods and optional category breakdowns
|
||||
**Output:** MAPE score, bias analysis, trends, category breakdown, accuracy rating
|
||||
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
# Track forecast accuracy
|
||||
python scripts/forecast_accuracy_tracker.py forecast_data.json --format text
|
||||
|
||||
# JSON output for trend analysis
|
||||
python scripts/forecast_accuracy_tracker.py forecast_data.json --format json
|
||||
```
|
||||
|
||||
**Key Metrics Calculated:**
|
||||
- **MAPE** -- Mean Absolute Percentage Error: mean(|actual - forecast| / |actual|) x 100
|
||||
- **Forecast Bias** -- Over-forecasting (positive) vs under-forecasting (negative) tendency
|
||||
- **Weighted Accuracy** -- MAPE weighted by deal value for materiality
|
||||
- **Period Trends** -- Improving, stable, or declining accuracy over time
|
||||
- **Category Breakdown** -- Accuracy by rep, product, segment, or any custom dimension
|
||||
|
||||
**Accuracy Ratings:**
|
||||
| Rating | MAPE Range | Interpretation |
|
||||
|--------|-----------|----------------|
|
||||
| Excellent | <10% | Highly predictable, data-driven process |
|
||||
| Good | 10-15% | Reliable forecasting with minor variance |
|
||||
| Fair | 15-25% | Needs process improvement |
|
||||
| Poor | >25% | Significant forecasting methodology gaps |
|
||||
|
||||
**Input Schema:**
|
||||
|
||||
```json
|
||||
{
|
||||
"forecast_periods": [
|
||||
{"period": "2025-Q1", "forecast": 480000, "actual": 520000},
|
||||
{"period": "2025-Q2", "forecast": 550000, "actual": 510000}
|
||||
],
|
||||
"category_breakdowns": {
|
||||
"by_rep": [
|
||||
{"category": "Rep A", "forecast": 200000, "actual": 210000},
|
||||
{"category": "Rep B", "forecast": 280000, "actual": 310000}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3. GTM Efficiency Calculator
|
||||
|
||||
Calculates core SaaS GTM efficiency metrics with industry benchmarking, ratings, and improvement recommendations.
|
||||
|
||||
**Input:** JSON file with revenue, cost, and customer metrics
|
||||
**Output:** Magic Number, LTV:CAC, CAC Payback, Burn Multiple, Rule of 40, NDR with ratings
|
||||
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
# Calculate all GTM efficiency metrics
|
||||
python scripts/gtm_efficiency_calculator.py gtm_data.json --format text
|
||||
|
||||
# JSON output for dashboards
|
||||
python scripts/gtm_efficiency_calculator.py gtm_data.json --format json
|
||||
```
|
||||
|
||||
**Key Metrics Calculated:**
|
||||
|
||||
| Metric | Formula | Target |
|
||||
|--------|---------|--------|
|
||||
| Magic Number | Net New ARR / Prior Period S&M Spend | >0.75 |
|
||||
| LTV:CAC | (ARPA x Gross Margin / Churn Rate) / CAC | >3:1 |
|
||||
| CAC Payback | CAC / (ARPA x Gross Margin) months | <18 months |
|
||||
| Burn Multiple | Net Burn / Net New ARR | <2x |
|
||||
| Rule of 40 | Revenue Growth % + FCF Margin % | >40% |
|
||||
| Net Dollar Retention | (Begin ARR + Expansion - Contraction - Churn) / Begin ARR | >110% |
|
||||
|
||||
**Input Schema:**
|
||||
|
||||
```json
|
||||
{
|
||||
"revenue": {
|
||||
"current_arr": 5000000,
|
||||
"prior_arr": 3800000,
|
||||
"net_new_arr": 1200000,
|
||||
"arpa_monthly": 2500,
|
||||
"revenue_growth_pct": 31.6
|
||||
},
|
||||
"costs": {
|
||||
"sales_marketing_spend": 1800000,
|
||||
"cac": 18000,
|
||||
"gross_margin_pct": 78,
|
||||
"total_operating_expense": 6500000,
|
||||
"net_burn": 1500000,
|
||||
"fcf_margin_pct": 8.4
|
||||
},
|
||||
"customers": {
|
||||
"beginning_arr": 3800000,
|
||||
"expansion_arr": 600000,
|
||||
"contraction_arr": 100000,
|
||||
"churned_arr": 300000,
|
||||
"annual_churn_rate_pct": 8
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Revenue Operations Workflows
|
||||
|
||||
### Weekly Pipeline Review
|
||||
|
||||
Use this workflow for your weekly pipeline inspection cadence.
|
||||
|
||||
1. **Generate pipeline report:**
|
||||
```bash
|
||||
python scripts/pipeline_analyzer.py --input current_pipeline.json --format text
|
||||
```
|
||||
|
||||
2. **Review key indicators:**
|
||||
- Pipeline coverage ratio (is it above 3x quota?)
|
||||
- Deals aging beyond threshold (which deals need intervention?)
|
||||
- Concentration risk (are we over-reliant on a few large deals?)
|
||||
- Stage distribution (is there a healthy funnel shape?)
|
||||
|
||||
3. **Document using template:** Use `assets/pipeline_review_template.md`
|
||||
|
||||
4. **Action items:** Address aging deals, redistribute pipeline concentration, fill coverage gaps
|
||||
|
||||
### Forecast Accuracy Review
|
||||
|
||||
Use monthly or quarterly to evaluate and improve forecasting discipline.
|
||||
|
||||
1. **Generate accuracy report:**
|
||||
```bash
|
||||
python scripts/forecast_accuracy_tracker.py forecast_history.json --format text
|
||||
```
|
||||
|
||||
2. **Analyze patterns:**
|
||||
- Is MAPE trending down (improving)?
|
||||
- Which reps or segments have the highest error rates?
|
||||
- Is there systematic over- or under-forecasting?
|
||||
|
||||
3. **Document using template:** Use `assets/forecast_report_template.md`
|
||||
|
||||
4. **Improvement actions:** Coach high-bias reps, adjust methodology, improve data hygiene
|
||||
|
||||
### GTM Efficiency Audit
|
||||
|
||||
Use quarterly or during board prep to evaluate go-to-market efficiency.
|
||||
|
||||
1. **Calculate efficiency metrics:**
|
||||
```bash
|
||||
python scripts/gtm_efficiency_calculator.py quarterly_data.json --format text
|
||||
```
|
||||
|
||||
2. **Benchmark against targets:**
|
||||
- Magic Number signals GTM spend efficiency
|
||||
- LTV:CAC validates unit economics
|
||||
- CAC Payback shows capital efficiency
|
||||
- Rule of 40 balances growth and profitability
|
||||
|
||||
3. **Document using template:** Use `assets/gtm_dashboard_template.md`
|
||||
|
||||
4. **Strategic decisions:** Adjust spend allocation, optimize channels, improve retention
|
||||
|
||||
### Quarterly Business Review
|
||||
|
||||
Combine all three tools for a comprehensive QBR analysis.
|
||||
|
||||
1. Run pipeline analyzer for forward-looking coverage
|
||||
2. Run forecast tracker for backward-looking accuracy
|
||||
3. Run GTM calculator for efficiency benchmarks
|
||||
4. Cross-reference pipeline health with forecast accuracy
|
||||
5. Align GTM efficiency metrics with growth targets
|
||||
|
||||
---
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
| Reference | Description |
|
||||
|-----------|-------------|
|
||||
| [RevOps Metrics Guide](references/revops-metrics-guide.md) | Complete metrics hierarchy, definitions, formulas, and interpretation |
|
||||
| [Pipeline Management Framework](references/pipeline-management-framework.md) | Pipeline best practices, stage definitions, conversion benchmarks |
|
||||
| [GTM Efficiency Benchmarks](references/gtm-efficiency-benchmarks.md) | SaaS benchmarks by stage, industry standards, improvement strategies |
|
||||
|
||||
---
|
||||
|
||||
## Templates
|
||||
|
||||
| Template | Use Case |
|
||||
|----------|----------|
|
||||
| [Pipeline Review Template](assets/pipeline_review_template.md) | Weekly/monthly pipeline inspection documentation |
|
||||
| [Forecast Report Template](assets/forecast_report_template.md) | Forecast accuracy reporting and trend analysis |
|
||||
| [GTM Dashboard Template](assets/gtm_dashboard_template.md) | GTM efficiency dashboard for leadership review |
|
||||
| [Sample Pipeline Data](assets/sample_pipeline_data.json) | Example input for pipeline_analyzer.py |
|
||||
| [Expected Output](assets/expected_output.json) | Reference output from pipeline_analyzer.py |
|
||||
254
docs/skills/business-growth/sales-engineer.md
Normal file
254
docs/skills/business-growth/sales-engineer.md
Normal file
@@ -0,0 +1,254 @@
|
||||
---
|
||||
title: "Sales Engineer Skill"
|
||||
description: "Sales Engineer Skill - Claude Code skill from the Business & Growth domain."
|
||||
---
|
||||
|
||||
# Sales Engineer Skill
|
||||
|
||||
**Domain:** Business & Growth | **Skill:** `sales-engineer` | **Source:** [`business-growth/sales-engineer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/business-growth/sales-engineer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Sales Engineer Skill
|
||||
|
||||
A production-ready skill package for pre-sales engineering that bridges technical expertise and sales execution. Provides automated analysis for RFP/RFI responses, competitive positioning, and proof-of-concept planning.
|
||||
|
||||
## Overview
|
||||
|
||||
**Role:** Sales Engineer / Solutions Architect
|
||||
**Domain:** Pre-Sales Engineering, Solution Design, Technical Demos, Proof of Concepts
|
||||
**Business Type:** SaaS / Pre-Sales Engineering
|
||||
|
||||
### What This Skill Does
|
||||
|
||||
- **RFP/RFI Response Analysis** - Score requirement coverage, identify gaps, generate bid/no-bid recommendations
|
||||
- **Competitive Technical Positioning** - Build feature comparison matrices, identify differentiators and vulnerabilities
|
||||
- **POC Planning** - Generate timelines, resource plans, success criteria, and evaluation scorecards
|
||||
- **Demo Preparation** - Structure demo scripts with talking points and objection handling
|
||||
- **Technical Proposal Creation** - Framework for solution architecture and implementation planning
|
||||
- **Win/Loss Analysis** - Data-driven competitive assessment for deal strategy
|
||||
|
||||
### Key Metrics
|
||||
|
||||
| Metric | Description | Target |
|
||||
|--------|-------------|--------|
|
||||
| Win Rate | Deals won / total opportunities | >30% |
|
||||
| Sales Cycle Length | Average days from discovery to close | <90 days |
|
||||
| POC Conversion Rate | POCs resulting in closed deals | >60% |
|
||||
| Customer Engagement Score | Stakeholder participation in evaluation | >75% |
|
||||
| RFP Coverage Score | Requirements fully addressed | >80% |
|
||||
|
||||
## 5-Phase Workflow
|
||||
|
||||
### Phase 1: Discovery & Research
|
||||
|
||||
**Objective:** Understand customer requirements, technical environment, and business drivers.
|
||||
|
||||
**Activities:**
|
||||
1. Conduct technical discovery calls with stakeholders
|
||||
2. Map customer's current architecture and pain points
|
||||
3. Identify integration requirements and constraints
|
||||
4. Document security and compliance requirements
|
||||
5. Assess competitive landscape for this opportunity
|
||||
|
||||
**Tools:** Use `rfp_response_analyzer.py` to score initial requirement alignment.
|
||||
|
||||
**Output:** Technical discovery document, requirement map, initial coverage assessment.
|
||||
|
||||
### Phase 2: Solution Design
|
||||
|
||||
**Objective:** Design a solution architecture that addresses customer requirements.
|
||||
|
||||
**Activities:**
|
||||
1. Map product capabilities to customer requirements
|
||||
2. Design integration architecture
|
||||
3. Identify customization needs and development effort
|
||||
4. Build competitive differentiation strategy
|
||||
5. Create solution architecture diagrams
|
||||
|
||||
**Tools:** Use `competitive_matrix_builder.py` to identify differentiators and vulnerabilities.
|
||||
|
||||
**Output:** Solution architecture, competitive positioning, technical differentiation strategy.
|
||||
|
||||
### Phase 3: Demo Preparation & Delivery
|
||||
|
||||
**Objective:** Deliver compelling technical demonstrations tailored to stakeholder priorities.
|
||||
|
||||
**Activities:**
|
||||
1. Build demo environment matching customer's use case
|
||||
2. Create demo script with talking points per stakeholder role
|
||||
3. Prepare objection handling responses
|
||||
4. Rehearse failure scenarios and recovery paths
|
||||
5. Collect feedback and adjust approach
|
||||
|
||||
**Templates:** Use `demo_script_template.md` for structured demo preparation.
|
||||
|
||||
**Output:** Customized demo, stakeholder-specific talking points, feedback capture.
|
||||
|
||||
### Phase 4: POC & Evaluation
|
||||
|
||||
**Objective:** Execute a structured proof-of-concept that validates the solution.
|
||||
|
||||
**Activities:**
|
||||
1. Define POC scope, success criteria, and timeline
|
||||
2. Allocate resources and set up environment
|
||||
3. Execute phased testing (core, advanced, edge cases)
|
||||
4. Track progress against success criteria
|
||||
5. Generate evaluation scorecard
|
||||
|
||||
**Tools:** Use `poc_planner.py` to generate the complete POC plan.
|
||||
|
||||
**Templates:** Use `poc_scorecard_template.md` for evaluation tracking.
|
||||
|
||||
**Output:** POC plan, evaluation scorecard, go/no-go recommendation.
|
||||
|
||||
### Phase 5: Proposal & Closing
|
||||
|
||||
**Objective:** Deliver a technical proposal that supports the commercial close.
|
||||
|
||||
**Activities:**
|
||||
1. Compile POC results and success metrics
|
||||
2. Create technical proposal with implementation plan
|
||||
3. Address outstanding objections with evidence
|
||||
4. Support pricing and packaging discussions
|
||||
5. Conduct win/loss analysis post-decision
|
||||
|
||||
**Templates:** Use `technical_proposal_template.md` for the proposal document.
|
||||
|
||||
**Output:** Technical proposal, implementation timeline, risk mitigation plan.
|
||||
|
||||
## Python Automation Tools
|
||||
|
||||
### 1. RFP Response Analyzer
|
||||
|
||||
**Script:** `scripts/rfp_response_analyzer.py`
|
||||
|
||||
**Purpose:** Parse RFP/RFI requirements, score coverage, identify gaps, and generate bid/no-bid recommendations.
|
||||
|
||||
**Coverage Categories:**
|
||||
- **Full (100%)** - Requirement fully met by current product
|
||||
- **Partial (50%)** - Requirement partially met, workaround or configuration needed
|
||||
- **Planned (25%)** - On product roadmap, not yet available
|
||||
- **Gap (0%)** - Not supported, no current plan
|
||||
|
||||
**Priority Weighting:**
|
||||
- Must-Have: 3x weight
|
||||
- Should-Have: 2x weight
|
||||
- Nice-to-Have: 1x weight
|
||||
|
||||
**Bid/No-Bid Logic:**
|
||||
- **Bid:** Coverage score >70% AND must-have gaps <=3
|
||||
- **Conditional Bid:** Coverage score 50-70% OR must-have gaps 2-3
|
||||
- **No-Bid:** Coverage score <50% OR must-have gaps >3
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Human-readable output
|
||||
python scripts/rfp_response_analyzer.py assets/sample_rfp_data.json
|
||||
|
||||
# JSON output
|
||||
python scripts/rfp_response_analyzer.py assets/sample_rfp_data.json --format json
|
||||
|
||||
# Help
|
||||
python scripts/rfp_response_analyzer.py --help
|
||||
```
|
||||
|
||||
**Input Format:** See `assets/sample_rfp_data.json` for the complete schema.
|
||||
|
||||
### 2. Competitive Matrix Builder
|
||||
|
||||
**Script:** `scripts/competitive_matrix_builder.py`
|
||||
|
||||
**Purpose:** Generate feature comparison matrices, calculate competitive scores, identify differentiators and vulnerabilities.
|
||||
|
||||
**Feature Scoring:**
|
||||
- **Full (3)** - Complete feature support
|
||||
- **Partial (2)** - Partial or limited feature support
|
||||
- **Limited (1)** - Minimal or basic feature support
|
||||
- **None (0)** - Feature not available
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Human-readable output
|
||||
python scripts/competitive_matrix_builder.py competitive_data.json
|
||||
|
||||
# JSON output
|
||||
python scripts/competitive_matrix_builder.py competitive_data.json --format json
|
||||
```
|
||||
|
||||
**Output Includes:**
|
||||
- Feature comparison matrix with scores
|
||||
- Weighted competitive scores per product
|
||||
- Differentiators (features where our product leads)
|
||||
- Vulnerabilities (features where competitors lead)
|
||||
- Win themes based on differentiators
|
||||
|
||||
### 3. POC Planner
|
||||
|
||||
**Script:** `scripts/poc_planner.py`
|
||||
|
||||
**Purpose:** Generate structured POC plans with timeline, resource allocation, success criteria, and evaluation scorecards.
|
||||
|
||||
**Default Phase Breakdown:**
|
||||
- **Week 1:** Setup - Environment provisioning, data migration, configuration
|
||||
- **Weeks 2-3:** Core Testing - Primary use cases, integration testing
|
||||
- **Week 4:** Advanced Testing - Edge cases, performance, security
|
||||
- **Week 5:** Evaluation - Scorecard completion, stakeholder review, go/no-go
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Human-readable output
|
||||
python scripts/poc_planner.py poc_data.json
|
||||
|
||||
# JSON output
|
||||
python scripts/poc_planner.py poc_data.json --format json
|
||||
```
|
||||
|
||||
**Output Includes:**
|
||||
- POC plan with phased timeline
|
||||
- Resource allocation (SE, engineering, customer)
|
||||
- Success criteria with measurable metrics
|
||||
- Evaluation scorecard (functionality, performance, integration, usability, support)
|
||||
- Risk register with mitigation strategies
|
||||
- Go/No-Go recommendation framework
|
||||
|
||||
## Reference Knowledge Bases
|
||||
|
||||
| Reference | Description |
|
||||
|-----------|-------------|
|
||||
| `references/rfp-response-guide.md` | RFP/RFI response best practices, compliance matrix, bid/no-bid framework |
|
||||
| `references/competitive-positioning-framework.md` | Competitive analysis methodology, battlecard creation, objection handling |
|
||||
| `references/poc-best-practices.md` | POC planning methodology, success criteria, evaluation frameworks |
|
||||
|
||||
## Asset Templates
|
||||
|
||||
| Template | Purpose |
|
||||
|----------|---------|
|
||||
| `assets/technical_proposal_template.md` | Technical proposal with executive summary, solution architecture, implementation plan |
|
||||
| `assets/demo_script_template.md` | Demo script with agenda, talking points, objection handling |
|
||||
| `assets/poc_scorecard_template.md` | POC evaluation scorecard with weighted scoring |
|
||||
| `assets/sample_rfp_data.json` | Sample RFP data for testing the analyzer |
|
||||
| `assets/expected_output.json` | Expected output from rfp_response_analyzer.py |
|
||||
|
||||
## Communication Style
|
||||
|
||||
- **Technical yet accessible** - Translate complex concepts for business stakeholders
|
||||
- **Confident and consultative** - Position as trusted advisor, not vendor
|
||||
- **Evidence-based** - Back every claim with data, demos, or case studies
|
||||
- **Stakeholder-aware** - Tailor depth and focus to audience (CTO vs. end user vs. procurement)
|
||||
|
||||
## Integration Points
|
||||
|
||||
- **Marketing Skills** - Leverage competitive intelligence and messaging frameworks from `../../marketing-skill/`
|
||||
- **Product Team** - Coordinate on roadmap items flagged as "Planned" in RFP analysis from `../../product-team/`
|
||||
- **C-Level Advisory** - Escalate strategic deals requiring executive engagement from `../../c-level-advisor/`
|
||||
- **Customer Success** - Hand off POC results and success criteria to CSM from `../customer-success-manager/`
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** February 2026
|
||||
**Status:** Production-ready
|
||||
**Tools:** 3 Python automation scripts
|
||||
**References:** 3 knowledge base documents
|
||||
**Templates:** 5 asset files
|
||||
417
docs/skills/c-level-advisor/agent-protocol.md
Normal file
417
docs/skills/c-level-advisor/agent-protocol.md
Normal file
@@ -0,0 +1,417 @@
|
||||
---
|
||||
title: "Inter-Agent Protocol"
|
||||
description: "Inter-Agent Protocol - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Inter-Agent Protocol
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `agent-protocol` | **Source:** [`c-level-advisor/agent-protocol/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/agent-protocol/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Inter-Agent Protocol
|
||||
|
||||
How C-suite agents talk to each other. Rules that prevent chaos, loops, and circular reasoning.
|
||||
|
||||
## Keywords
|
||||
agent protocol, inter-agent communication, agent invocation, agent orchestration, multi-agent, c-suite coordination, agent chain, loop prevention, agent isolation, board meeting protocol
|
||||
|
||||
## Invocation Syntax
|
||||
|
||||
Any agent can query another using:
|
||||
|
||||
```
|
||||
[INVOKE:role|question]
|
||||
```
|
||||
|
||||
**Examples:**
|
||||
```
|
||||
[INVOKE:cfo|What's the burn rate impact of hiring 5 engineers in Q3?]
|
||||
[INVOKE:cto|Can we realistically ship this feature by end of quarter?]
|
||||
[INVOKE:chro|What's our typical time-to-hire for senior engineers?]
|
||||
[INVOKE:cro|What does our pipeline look like for the next 90 days?]
|
||||
```
|
||||
|
||||
**Valid roles:** `ceo`, `cfo`, `cro`, `cmo`, `cpo`, `cto`, `chro`, `coo`, `ciso`
|
||||
|
||||
## Response Format
|
||||
|
||||
Invoked agents respond using this structure:
|
||||
|
||||
```
|
||||
[RESPONSE:role]
|
||||
Key finding: [one line — the actual answer]
|
||||
Supporting data:
|
||||
- [data point 1]
|
||||
- [data point 2]
|
||||
- [data point 3 — optional]
|
||||
Confidence: [high | medium | low]
|
||||
Caveat: [one line — what could make this wrong]
|
||||
[/RESPONSE]
|
||||
```
|
||||
|
||||
**Example:**
|
||||
```
|
||||
[RESPONSE:cfo]
|
||||
Key finding: Hiring 5 engineers in Q3 extends runway from 14 to 9 months at current burn.
|
||||
Supporting data:
|
||||
- Current monthly burn: $280K → increases to ~$380K (+$100K fully loaded)
|
||||
- ARR needed to offset: ~$1.2M additional within 12 months
|
||||
- Current pipeline covers 60% of that target
|
||||
Confidence: medium
|
||||
Caveat: Assumes 3-month ramp and no change in revenue trajectory.
|
||||
[/RESPONSE]
|
||||
```
|
||||
|
||||
## Loop Prevention (Hard Rules)
|
||||
|
||||
These rules are enforced unconditionally. No exceptions.
|
||||
|
||||
### Rule 1: No Self-Invocation
|
||||
An agent cannot invoke itself.
|
||||
```
|
||||
❌ CFO → [INVOKE:cfo|...] — BLOCKED
|
||||
```
|
||||
|
||||
### Rule 2: Maximum Depth = 2
|
||||
Chains can go A→B→C. The third hop is blocked.
|
||||
```
|
||||
✅ CRO → CFO → COO (depth 2)
|
||||
❌ CRO → CFO → COO → CHRO (depth 3 — BLOCKED)
|
||||
```
|
||||
|
||||
### Rule 3: No Circular Calls
|
||||
If agent A called agent B, agent B cannot call agent A in the same chain.
|
||||
```
|
||||
✅ CRO → CFO → CMO
|
||||
❌ CRO → CFO → CRO (circular — BLOCKED)
|
||||
```
|
||||
|
||||
### Rule 4: Chain Tracking
|
||||
Each invocation carries its call chain. Format:
|
||||
```
|
||||
[CHAIN: cro → cfo → coo]
|
||||
```
|
||||
Agents check this chain before responding with another invocation.
|
||||
|
||||
**When blocked:** Return this instead of invoking:
|
||||
```
|
||||
[BLOCKED: cannot invoke cfo — circular call detected in chain cro→cfo]
|
||||
State assumption used instead: [explicit assumption the agent is making]
|
||||
```
|
||||
|
||||
## Isolation Rules
|
||||
|
||||
### Board Meeting Phase 2 (Independent Analysis)
|
||||
**NO invocations allowed.** Each role forms independent views before cross-pollination.
|
||||
- Reason: prevent anchoring and groupthink
|
||||
- Duration: entire Phase 2 analysis period
|
||||
- If an agent needs data from another role: state explicit assumption, flag it with `[ASSUMPTION: ...]`
|
||||
|
||||
### Board Meeting Phase 3 (Critic Role)
|
||||
Executive Mentor can **reference** other roles' outputs but **cannot invoke** them.
|
||||
- Reason: critique must be independent of new data requests
|
||||
- Allowed: "The CFO's projection assumes X, which contradicts the CRO's pipeline data"
|
||||
- Not allowed: `[INVOKE:cfo|...]` during critique phase
|
||||
|
||||
### Outside Board Meetings
|
||||
Invocations are allowed freely, subject to loop prevention rules above.
|
||||
|
||||
## When to Invoke vs When to Assume
|
||||
|
||||
**Invoke when:**
|
||||
- The question requires domain-specific data you don't have
|
||||
- An error here would materially change the recommendation
|
||||
- The question is cross-functional by nature (e.g., hiring impact on both budget and capacity)
|
||||
|
||||
**Assume when:**
|
||||
- The data is directionally clear and precision isn't critical
|
||||
- You're in Phase 2 isolation (always assume, never invoke)
|
||||
- The chain is already at depth 2
|
||||
- The question is minor compared to your main analysis
|
||||
|
||||
**When assuming, always state it:**
|
||||
```
|
||||
[ASSUMPTION: runway ~12 months based on typical Series A burn profile — not verified with CFO]
|
||||
```
|
||||
|
||||
## Conflict Resolution
|
||||
|
||||
When two invoked agents give conflicting answers:
|
||||
|
||||
1. **Flag the conflict explicitly:**
|
||||
```
|
||||
[CONFLICT: CFO projects 14-month runway; CRO expects pipeline to close 80% → implies 18+ months]
|
||||
```
|
||||
2. **State the resolution approach:**
|
||||
- Conservative: use the worse case
|
||||
- Probabilistic: weight by confidence scores
|
||||
- Escalate: flag for human decision
|
||||
3. **Never silently pick one** — surface the conflict to the user.
|
||||
|
||||
## Broadcast Pattern (Crisis / CEO)
|
||||
|
||||
CEO can broadcast to all roles simultaneously:
|
||||
```
|
||||
[BROADCAST:all|What's the impact if we miss the fundraise?]
|
||||
```
|
||||
|
||||
Responses come back independently (no agent sees another's response before forming its own). Aggregate after all respond.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Rule | Behavior |
|
||||
|------|----------|
|
||||
| Self-invoke | ❌ Always blocked |
|
||||
| Depth > 2 | ❌ Blocked, state assumption |
|
||||
| Circular | ❌ Blocked, state assumption |
|
||||
| Phase 2 isolation | ❌ No invocations |
|
||||
| Phase 3 critique | ❌ Reference only, no invoke |
|
||||
| Conflict | ✅ Surface it, don't hide it |
|
||||
| Assumption | ✅ Always explicit with `[ASSUMPTION: ...]` |
|
||||
|
||||
## Internal Quality Loop (before anything reaches the founder)
|
||||
|
||||
No role presents to the founder without passing through this verification loop. The founder sees polished, verified output — not first drafts.
|
||||
|
||||
### Step 1: Self-Verification (every role, every time)
|
||||
|
||||
Before presenting, every role runs this internal checklist:
|
||||
|
||||
```
|
||||
SELF-VERIFY CHECKLIST:
|
||||
□ Source Attribution — Where did each data point come from?
|
||||
✅ "ARR is $2.1M (from CRO pipeline report, Q4 actuals)"
|
||||
❌ "ARR is around $2M" (no source, vague)
|
||||
|
||||
□ Assumption Audit — What am I assuming vs what I verified?
|
||||
Tag every assumption: [VERIFIED: checked against data] or [ASSUMED: not verified]
|
||||
If >50% of findings are ASSUMED → flag low confidence
|
||||
|
||||
□ Confidence Score — How sure am I on each finding?
|
||||
🟢 High: verified data, established pattern, multiple sources
|
||||
🟡 Medium: single source, reasonable inference, some uncertainty
|
||||
🔴 Low: assumption-based, limited data, first-time analysis
|
||||
|
||||
□ Contradiction Check — Does this conflict with known context?
|
||||
Check against company-context.md and recent decisions in decision-log
|
||||
If it contradicts a past decision → flag explicitly
|
||||
|
||||
□ "So What?" Test — Does every finding have a business consequence?
|
||||
If you can't answer "so what?" in one sentence → cut it
|
||||
```
|
||||
|
||||
### Step 2: Peer Verification (cross-functional validation)
|
||||
|
||||
When a recommendation impacts another role's domain, that role validates BEFORE presenting.
|
||||
|
||||
| If your recommendation involves... | Validate with... | They check... |
|
||||
|-------------------------------------|-------------------|---------------|
|
||||
| Financial numbers or budget | CFO | Math, runway impact, budget reality |
|
||||
| Revenue projections | CRO | Pipeline backing, historical accuracy |
|
||||
| Headcount or hiring | CHRO | Market reality, comp feasibility, timeline |
|
||||
| Technical feasibility or timeline | CTO | Engineering capacity, technical debt load |
|
||||
| Operational process changes | COO | Capacity, dependencies, scaling impact |
|
||||
| Customer-facing changes | CRO + CPO | Churn risk, product roadmap conflict |
|
||||
| Security or compliance claims | CISO | Actual posture, regulation requirements |
|
||||
| Market or positioning claims | CMO | Data backing, competitive reality |
|
||||
|
||||
**Peer validation format:**
|
||||
```
|
||||
[PEER-VERIFY:cfo]
|
||||
Validated: ✅ Burn rate calculation correct
|
||||
Adjusted: ⚠️ Hiring timeline should be Q3 not Q2 (budget constraint)
|
||||
Flagged: 🔴 Missing equity cost in total comp projection
|
||||
[/PEER-VERIFY]
|
||||
```
|
||||
|
||||
**Skip peer verification when:**
|
||||
- Single-domain question with no cross-functional impact
|
||||
- Time-sensitive proactive alert (send alert, verify after)
|
||||
- Founder explicitly asked for a quick take
|
||||
|
||||
### Step 3: Critic Pre-Screen (high-stakes decisions only)
|
||||
|
||||
For decisions that are **irreversible, high-cost, or bet-the-company**, the Executive Mentor pre-screens before the founder sees it.
|
||||
|
||||
**Triggers for pre-screen:**
|
||||
- Involves spending > 20% of remaining runway
|
||||
- Affects >30% of the team (layoffs, reorg)
|
||||
- Changes company strategy or direction
|
||||
- Involves external commitments (fundraising terms, partnerships, M&A)
|
||||
- Any recommendation where all roles agree (suspicious consensus)
|
||||
|
||||
**Pre-screen output:**
|
||||
```
|
||||
[CRITIC-SCREEN]
|
||||
Weakest point: [The single biggest vulnerability in this recommendation]
|
||||
Missing perspective: [What nobody considered]
|
||||
If wrong, the cost is: [Quantified downside]
|
||||
Proceed: ✅ With noted risks | ⚠️ After addressing [specific gap] | 🔴 Rethink
|
||||
[/CRITIC-SCREEN]
|
||||
```
|
||||
|
||||
### Step 4: Course Correction (after founder feedback)
|
||||
|
||||
The loop doesn't end at delivery. After the founder responds:
|
||||
|
||||
```
|
||||
FOUNDER FEEDBACK LOOP:
|
||||
1. Founder approves → log decision (Layer 2), assign actions
|
||||
2. Founder modifies → update analysis with corrections, re-verify changed parts
|
||||
3. Founder rejects → log rejection with DO_NOT_RESURFACE, understand WHY
|
||||
4. Founder asks follow-up → deepen analysis on specific point, re-verify
|
||||
|
||||
POST-DECISION REVIEW (30/60/90 days):
|
||||
- Was the recommendation correct?
|
||||
- What did we miss?
|
||||
- Update company-context.md with what we learned
|
||||
- If wrong → document the lesson, adjust future analysis
|
||||
```
|
||||
|
||||
### Verification Level by Stakes
|
||||
|
||||
| Stakes | Self-Verify | Peer-Verify | Critic Pre-Screen |
|
||||
|--------|-------------|-------------|-------------------|
|
||||
| Low (informational) | ✅ Required | ❌ Skip | ❌ Skip |
|
||||
| Medium (operational) | ✅ Required | ✅ Required | ❌ Skip |
|
||||
| High (strategic) | ✅ Required | ✅ Required | ✅ Required |
|
||||
| Critical (irreversible) | ✅ Required | ✅ Required | ✅ Required + board meeting |
|
||||
|
||||
### What Changes in the Output Format
|
||||
|
||||
The verified output adds confidence and source information:
|
||||
|
||||
```
|
||||
BOTTOM LINE
|
||||
[Answer] — Confidence: 🟢 High
|
||||
|
||||
WHAT
|
||||
• [Finding 1] [VERIFIED: Q4 actuals] 🟢
|
||||
• [Finding 2] [VERIFIED: CRO pipeline data] 🟢
|
||||
• [Finding 3] [ASSUMED: based on industry benchmarks] 🟡
|
||||
|
||||
PEER-VERIFIED BY: CFO (math ✅), CTO (timeline ⚠️ adjusted to Q3)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## User Communication Standard
|
||||
|
||||
All C-suite output to the founder follows ONE format. No exceptions. The founder is the decision-maker — give them results, not process.
|
||||
|
||||
### Standard Output (single-role response)
|
||||
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
📊 [ROLE] — [Topic]
|
||||
|
||||
BOTTOM LINE
|
||||
[One sentence. The answer. No preamble.]
|
||||
|
||||
WHAT
|
||||
• [Finding 1 — most critical]
|
||||
• [Finding 2]
|
||||
• [Finding 3]
|
||||
(Max 5 bullets. If more needed → reference doc.)
|
||||
|
||||
WHY THIS MATTERS
|
||||
[1-2 sentences. Business impact. Not theory — consequence.]
|
||||
|
||||
HOW TO ACT
|
||||
1. [Action] → [Owner] → [Deadline]
|
||||
2. [Action] → [Owner] → [Deadline]
|
||||
3. [Action] → [Owner] → [Deadline]
|
||||
|
||||
⚠️ RISKS (if any)
|
||||
• [Risk + what triggers it]
|
||||
|
||||
🔑 YOUR DECISION (if needed)
|
||||
Option A: [Description] — [Trade-off]
|
||||
Option B: [Description] — [Trade-off]
|
||||
Recommendation: [Which and why, in one line]
|
||||
|
||||
📎 DETAIL: [reference doc or script output for deep-dive]
|
||||
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
### Proactive Alert (unsolicited — triggered by context)
|
||||
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
🚩 [ROLE] — Proactive Alert
|
||||
|
||||
WHAT I NOTICED
|
||||
[What triggered this — specific, not vague]
|
||||
|
||||
WHY IT MATTERS
|
||||
[Business consequence if ignored — in dollars, time, or risk]
|
||||
|
||||
RECOMMENDED ACTION
|
||||
[Exactly what to do, who does it, by when]
|
||||
|
||||
URGENCY: 🔴 Act today | 🟡 This week | ⚪ Next review
|
||||
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
### Board Meeting Output (multi-role synthesis)
|
||||
|
||||
```
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
📋 BOARD MEETING — [Date] — [Agenda Topic]
|
||||
|
||||
DECISION REQUIRED
|
||||
[Frame the decision in one sentence]
|
||||
|
||||
PERSPECTIVES
|
||||
CEO: [one-line position]
|
||||
CFO: [one-line position]
|
||||
CRO: [one-line position]
|
||||
[... only roles that contributed]
|
||||
|
||||
WHERE THEY AGREE
|
||||
• [Consensus point 1]
|
||||
• [Consensus point 2]
|
||||
|
||||
WHERE THEY DISAGREE
|
||||
• [Conflict] — CEO says X, CFO says Y
|
||||
• [Conflict] — CRO says X, CPO says Y
|
||||
|
||||
CRITIC'S VIEW (Executive Mentor)
|
||||
[The uncomfortable truth nobody else said]
|
||||
|
||||
RECOMMENDED DECISION
|
||||
[Clear recommendation with rationale]
|
||||
|
||||
ACTION ITEMS
|
||||
1. [Action] → [Owner] → [Deadline]
|
||||
2. [Action] → [Owner] → [Deadline]
|
||||
3. [Action] → [Owner] → [Deadline]
|
||||
|
||||
🔑 YOUR CALL
|
||||
[Options if you disagree with the recommendation]
|
||||
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
```
|
||||
|
||||
### Communication Rules (non-negotiable)
|
||||
|
||||
1. **Bottom line first.** Always. The founder's time is the scarcest resource.
|
||||
2. **Results and decisions only.** No process narration ("First I analyzed..."). No thinking out loud.
|
||||
3. **What + Why + How.** Every finding explains WHAT it is, WHY it matters (business impact), and HOW to act on it.
|
||||
4. **Max 5 bullets per section.** Longer = reference doc.
|
||||
5. **Actions have owners and deadlines.** "We should consider" is banned. Who does what by when.
|
||||
6. **Decisions framed as options.** Not "what do you think?" — "Option A or B, here's the trade-off, here's my recommendation."
|
||||
7. **The founder decides.** Roles recommend. The founder approves, modifies, or rejects. Every output respects this hierarchy.
|
||||
8. **Risks are concrete.** Not "there might be risks" — "if X happens, Y breaks, costing $Z."
|
||||
9. **No jargon without explanation.** If you use a term, explain it on first use.
|
||||
10. **Silence is an option.** If there's nothing to report, don't fabricate updates.
|
||||
|
||||
## Reference
|
||||
- `references/invocation-patterns.md` — common cross-functional patterns with examples
|
||||
182
docs/skills/c-level-advisor/board-deck-builder.md
Normal file
182
docs/skills/c-level-advisor/board-deck-builder.md
Normal file
@@ -0,0 +1,182 @@
|
||||
---
|
||||
title: "Board Deck Builder"
|
||||
description: "Board Deck Builder - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Board Deck Builder
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `board-deck-builder` | **Source:** [`c-level-advisor/board-deck-builder/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/board-deck-builder/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Board Deck Builder
|
||||
|
||||
Build board decks that tell a story — not just show data. Every section has an owner, a narrative, and a "so what."
|
||||
|
||||
## Keywords
|
||||
board deck, investor update, board meeting, board pack, investor relations, quarterly review, board presentation, fundraising deck, investor deck, board narrative, QBR, quarterly business review
|
||||
|
||||
## Quick Start
|
||||
|
||||
```
|
||||
/board-deck [quarterly|monthly|fundraising] [stage: seed|seriesA|seriesB]
|
||||
```
|
||||
|
||||
Provide available metrics. The builder fills gaps with explicit placeholders — never invents numbers.
|
||||
|
||||
## Deck Structure (Standard Order)
|
||||
|
||||
Every section follows: **Headline → Data → Narrative → Ask/Next**
|
||||
|
||||
### 1. Executive Summary (CEO)
|
||||
**3 sentences. No more.**
|
||||
- Sentence 1: State of the business (where we are)
|
||||
- Sentence 2: Biggest thing that happened this period
|
||||
- Sentence 3: Where we're going next quarter
|
||||
|
||||
*Bad:* "We had a good quarter with lots of progress across all areas."
|
||||
*Good:* "We closed Q3 at $2.4M ARR (+22% QoQ), signed our largest enterprise contract, and enter Q4 with 14-month runway. The strategic shift to mid-market is working — ACV up 40% and sales cycle down 3 weeks. Q4 priority: close the $3M Series A and hit $2.8M ARR."
|
||||
|
||||
### 2. Key Metrics Dashboard (COO)
|
||||
**6-8 metrics max. Use a table.**
|
||||
|
||||
| Metric | This Period | Last Period | Target | Status |
|
||||
|--------|-------------|-------------|--------|--------|
|
||||
| ARR | $2.4M | $1.97M | $2.3M | ✅ |
|
||||
| MoM growth | 8.1% | 7.2% | 7.5% | ✅ |
|
||||
| Burn multiple | 1.8x | 2.1x | <2x | ✅ |
|
||||
| NRR | 112% | 108% | >110% | ✅ |
|
||||
| CAC payback | 11 months | 14 months | <12 months | ✅ |
|
||||
| Headcount | 24 | 21 | 25 | 🟡 |
|
||||
|
||||
Pick metrics the board actually tracks. Swap out anything they've said they don't care about.
|
||||
|
||||
### 3. Financial Update (CFO)
|
||||
- P&L summary: Revenue, COGS, Gross margin, OpEx, Net burn
|
||||
- Cash position and runway (months)
|
||||
- Burn multiple trend (3-quarter view)
|
||||
- Variance to plan (what was different and why)
|
||||
- Forecast update for next quarter
|
||||
|
||||
**One sentence on each variance.** Boards hate "revenue was below target" with no explanation. Say why.
|
||||
|
||||
### 4. Revenue & Pipeline (CRO)
|
||||
- ARR waterfall: starting → new → expansion → churn → ending
|
||||
- NRR and logo churn rates
|
||||
- Pipeline by stage (in $, not just count)
|
||||
- Forecast: next quarter with confidence level
|
||||
- Top 3 deals: name/amount/close date/risk
|
||||
|
||||
**The forecast must have a confidence level.** "We expect $2.8M" is weak. "High confidence $2.6M, upside to $2.9M if two late-stage deals close" is useful.
|
||||
|
||||
### 5. Product Update (CPO)
|
||||
- Shipped this quarter: 3-5 bullets, user impact for each
|
||||
- Shipping next quarter: 3-5 bullets with target dates
|
||||
- PMF signal: NPS trend, DAU/MAU ratio, feature adoption
|
||||
- One key learning from customer research
|
||||
|
||||
**No feature lists.** Only features with evidence of user impact.
|
||||
|
||||
### 6. Growth & Marketing (CMO)
|
||||
- CAC by channel (table)
|
||||
- Pipeline contribution by channel ($)
|
||||
- Brand/awareness metrics relevant to stage (traffic, share of voice)
|
||||
- What's working, what's being cut, what's being tested
|
||||
|
||||
### 7. Engineering & Technical (CTO)
|
||||
- Delivery velocity trend (last 4 quarters)
|
||||
- Tech debt ratio and plan
|
||||
- Infrastructure: uptime, incidents, cost trend
|
||||
- Security posture (one line, flag anything pending)
|
||||
|
||||
**Keep this short unless there's a material issue.** Boards don't need sprint details.
|
||||
|
||||
### 8. Team & People (CHRO)
|
||||
- Headcount: actual vs plan
|
||||
- Hiring: offers out, pipeline, time-to-fill trend
|
||||
- Attrition: regrettable vs non-regrettable
|
||||
- Engagement: last survey score, trend
|
||||
- Key hires this quarter, key open roles
|
||||
|
||||
### 9. Risk & Security (CISO)
|
||||
- Security posture: status of critical controls
|
||||
- Compliance: certifications in progress, deadlines
|
||||
- Incidents this quarter (if any): impact, resolution, prevention
|
||||
- Top 3 risks and mitigation status
|
||||
|
||||
### 10. Strategic Outlook (CEO)
|
||||
- Next quarter priorities: 3-5 items, ranked
|
||||
- Key decisions needed from the board
|
||||
- Asks: budget, introductions, advice, votes
|
||||
|
||||
**The "asks" slide is the most important.** Be specific. "We'd like 3 warm introductions to CFOs at Series B companies" beats "any help would be appreciated."
|
||||
|
||||
### 11. Appendix
|
||||
- Detailed financial model
|
||||
- Full pipeline data
|
||||
- Cohort retention charts
|
||||
- Customer case studies
|
||||
- Detailed headcount breakdown
|
||||
|
||||
---
|
||||
|
||||
## Narrative Framework
|
||||
|
||||
Boards see 10+ decks per quarter. Yours needs a through-line.
|
||||
|
||||
**The 4-Act Structure:**
|
||||
1. **Where we said we'd be** (last quarter's targets)
|
||||
2. **Where we actually are** (honest assessment)
|
||||
3. **Why the gap exists** (one cause per variance, not excuses)
|
||||
4. **What we're doing about it** (specific, dated actions)
|
||||
|
||||
This works for good news AND bad news. It's credible because it acknowledges reality.
|
||||
|
||||
**Opening frame:** Start with the one thing that matters most — the board should know the key message by slide 3, not slide 30.
|
||||
|
||||
---
|
||||
|
||||
## Delivering Bad News
|
||||
|
||||
Never bury it. Boards find out eventually. Finding out late makes it worse.
|
||||
|
||||
**Framework:**
|
||||
1. **State it plainly** — "We missed Q3 ARR target by $300K (12% gap)"
|
||||
2. **Own the cause** — "Primary driver was longer-than-expected sales cycle in enterprise segment"
|
||||
3. **Show you understand it** — "We analyzed 8 lost/stalled deals; the pattern is X"
|
||||
4. **Present the fix** — "We've made 3 changes: [specific, dated changes]"
|
||||
5. **Update the forecast** — "Revised Q4 target is $2.6M; here's the bottom-up build"
|
||||
|
||||
**What NOT to do:**
|
||||
- Don't lead with good news to soften bad news — boards notice and distrust the framing
|
||||
- Don't explain without owning — "market conditions" is not a cause, it's a context
|
||||
- Don't present a fix without data behind it
|
||||
- Don't show a revised forecast without showing your assumptions
|
||||
|
||||
---
|
||||
|
||||
## Common Board Deck Mistakes
|
||||
|
||||
| Mistake | Fix |
|
||||
|---------|-----|
|
||||
| Too many slides (>25) | Cut ruthlessly — if you can't explain it in the room, the slide is wrong |
|
||||
| Metrics without targets | Every metric needs a target and a status |
|
||||
| No narrative | Data without story forces boards to draw their own conclusions |
|
||||
| Burying bad news | Lead with it, own it, fix it |
|
||||
| Vague asks | Specific, actionable, person-assigned asks only |
|
||||
| No variance explanation | Every gap from target needs one-sentence cause |
|
||||
| Stale appendix | Appendix is only useful if it's current |
|
||||
| Designing for the reader, not the room | Decks are presented — they must work spoken aloud |
|
||||
|
||||
---
|
||||
|
||||
## Cadence Notes
|
||||
|
||||
**Quarterly (standard):** Full deck, all sections, 20-30 slides. Sent 48 hours in advance.
|
||||
**Monthly (for early-stage):** Condensed — metrics dashboard, financials, pipeline, top risks. 8-12 slides.
|
||||
**Fundraising:** Opens with market/vision, closes with ask. See `references/deck-frameworks.md` for Sequoia format.
|
||||
|
||||
## References
|
||||
- `references/deck-frameworks.md` — SaaS board pack format, Sequoia structure, investor tailoring
|
||||
- `templates/board-deck-template.md` — fill-in template for complete board decks
|
||||
145
docs/skills/c-level-advisor/board-meeting.md
Normal file
145
docs/skills/c-level-advisor/board-meeting.md
Normal file
@@ -0,0 +1,145 @@
|
||||
---
|
||||
title: "Board Meeting Protocol"
|
||||
description: "Board Meeting Protocol - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Board Meeting Protocol
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `board-meeting` | **Source:** [`c-level-advisor/board-meeting/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/board-meeting/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Board Meeting Protocol
|
||||
|
||||
Structured multi-agent deliberation that prevents groupthink, captures minority views, and produces clean, actionable decisions.
|
||||
|
||||
## Keywords
|
||||
board meeting, executive deliberation, strategic decision, C-suite, multi-agent, /cs:board, founder review, decision extraction, independent perspectives
|
||||
|
||||
## Invoke
|
||||
`/cs:board [topic]` — e.g. `/cs:board Should we expand to Spain in Q3?`
|
||||
|
||||
---
|
||||
|
||||
## The 6-Phase Protocol
|
||||
|
||||
### PHASE 1: Context Gathering
|
||||
1. Load `memory/company-context.md`
|
||||
2. Load `memory/board-meetings/decisions.md` **(Layer 2 ONLY — never raw transcripts)**
|
||||
3. Reset session state — no bleed from previous conversations
|
||||
4. Present agenda + activated roles → wait for founder confirmation
|
||||
|
||||
**Chief of Staff selects relevant roles** based on topic (not all 9 every time):
|
||||
| Topic | Activate |
|
||||
|-------|----------|
|
||||
| Market expansion | CEO, CMO, CFO, CRO, COO |
|
||||
| Product direction | CEO, CPO, CTO, CMO |
|
||||
| Hiring/org | CEO, CHRO, CFO, COO |
|
||||
| Pricing | CMO, CFO, CRO, CPO |
|
||||
| Technology | CTO, CPO, CFO, CISO |
|
||||
|
||||
---
|
||||
|
||||
### PHASE 2: Independent Contributions (ISOLATED)
|
||||
|
||||
**No cross-pollination. Each agent runs before seeing others' outputs.**
|
||||
|
||||
Order: Research (if needed) → CMO → CFO → CEO → CTO → COO → CHRO → CRO → CISO → CPO
|
||||
|
||||
**Reasoning techniques:** CEO: Tree of Thought (3 futures) | CFO: Chain of Thought (show the math) | CMO: Recursion of Thought (draft→critique→refine) | CPO: First Principles | CRO: Chain of Thought (pipeline math) | COO: Step by Step (process map) | CTO: ReAct (research→analyze→act) | CISO: Risk-Based (P×I) | CHRO: Empathy + Data
|
||||
|
||||
**Contribution format (max 5 key points, self-verified):**
|
||||
```
|
||||
## [ROLE] — [DATE]
|
||||
|
||||
Key points (max 5):
|
||||
• [Finding] — [VERIFIED/ASSUMED] — 🟢/🟡/🔴
|
||||
• [Finding] — [VERIFIED/ASSUMED] — 🟢/🟡/🔴
|
||||
|
||||
Recommendation: [clear position]
|
||||
Confidence: High / Medium / Low
|
||||
Source: [where the data came from]
|
||||
What would change my mind: [specific condition]
|
||||
```
|
||||
|
||||
Each agent self-verifies before contributing: source attribution, assumption audit, confidence scoring. No untagged claims.
|
||||
|
||||
---
|
||||
|
||||
### PHASE 3: Critic Analysis
|
||||
Executive Mentor receives ALL Phase 2 outputs simultaneously. Role: adversarial reviewer, not synthesizer.
|
||||
|
||||
Checklist:
|
||||
- Where did agents agree too easily? (suspicious consensus = red flag)
|
||||
- What assumptions are shared but unvalidated?
|
||||
- Who is missing from the room? (customer voice? front-line ops?)
|
||||
- What risk has nobody mentioned?
|
||||
- Which agent operated outside their domain?
|
||||
|
||||
---
|
||||
|
||||
### PHASE 4: Synthesis
|
||||
Chief of Staff delivers using the **Board Meeting Output** format (defined in `agent-protocol/SKILL.md`):
|
||||
- Decision Required (one sentence)
|
||||
- Perspectives (one line per contributing role)
|
||||
- Where They Agree / Where They Disagree
|
||||
- Critic's View (the uncomfortable truth)
|
||||
- Recommended Decision + Action Items (owners, deadlines)
|
||||
- Your Call (options if founder disagrees)
|
||||
|
||||
---
|
||||
|
||||
### PHASE 5: Human in the Loop ⏸️
|
||||
|
||||
**Full stop. Wait for the founder.**
|
||||
|
||||
```
|
||||
⏸️ FOUNDER REVIEW — [Paste synthesis]
|
||||
|
||||
Options: ✅ Approve | ✏️ Modify | ❌ Reject | ❓ Ask follow-up
|
||||
```
|
||||
|
||||
**Rules:**
|
||||
- User corrections OVERRIDE agent proposals. No pushback. No "but the CFO said..."
|
||||
- 30-min inactivity → auto-close as "pending review"
|
||||
- Reopen any time with `/cs:board resume`
|
||||
|
||||
---
|
||||
|
||||
### PHASE 6: Decision Extraction
|
||||
After founder approval:
|
||||
- **Layer 1:** Write full transcript → `memory/board-meetings/YYYY-MM-DD-raw.md`
|
||||
- **Layer 2:** Append approved decisions → `memory/board-meetings/decisions.md`
|
||||
- Mark rejected proposals `[DO_NOT_RESURFACE]`
|
||||
- Confirm to founder with count of decisions logged, actions tracked, flags added
|
||||
|
||||
---
|
||||
|
||||
## Memory Structure
|
||||
```
|
||||
memory/board-meetings/
|
||||
├── decisions.md # Layer 2 — founder-approved only (Phase 1 loads this)
|
||||
├── YYYY-MM-DD-raw.md # Layer 1 — full transcripts (never auto-loaded)
|
||||
└── archive/YYYY/ # Raw transcripts after 90 days
|
||||
```
|
||||
|
||||
**Future meetings load Layer 2 only.** Never Layer 1. This prevents hallucinated consensus.
|
||||
|
||||
---
|
||||
|
||||
## Failure Mode Quick Reference
|
||||
| Failure | Fix |
|
||||
|---------|-----|
|
||||
| Groupthink (all agree) | Re-run Phase 2 isolated; force "strongest argument against" |
|
||||
| Analysis paralysis | Cap at 5 points; force recommendation even with Low confidence |
|
||||
| Bikeshedding | Log as async action item; return to main agenda |
|
||||
| Role bleed (CFO making product calls) | Critic flags; exclude from synthesis |
|
||||
| Layer contamination | Phase 1 loads decisions.md only — hard rule |
|
||||
|
||||
---
|
||||
|
||||
## References
|
||||
- `templates/meeting-agenda.md` — agenda format
|
||||
- `templates/meeting-minutes.md` — final output format
|
||||
- `references/meeting-facilitation.md` — conflict handling, timing, failure modes
|
||||
52
docs/skills/c-level-advisor/c-level-advisor.md
Normal file
52
docs/skills/c-level-advisor/c-level-advisor.md
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
title: "C-Level Advisory Ecosystem"
|
||||
description: "C-Level Advisory Ecosystem - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# C-Level Advisory Ecosystem
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `c-level-advisor` | **Source:** [`c-level-advisor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# C-Level Advisory Ecosystem
|
||||
|
||||
A complete virtual board of directors for founders and executives.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```
|
||||
1. Run /cs:setup → creates company-context.md (all agents read this)
|
||||
2. Ask any strategic question → Chief of Staff routes to the right role
|
||||
3. For big decisions → /cs:board triggers a multi-role board meeting
|
||||
```
|
||||
|
||||
## What's Included
|
||||
|
||||
### 10 C-Suite Roles
|
||||
CEO, CTO, COO, CPO, CMO, CFO, CRO, CISO, CHRO, Executive Mentor
|
||||
|
||||
### 6 Orchestration Skills
|
||||
Founder Onboard, Chief of Staff (router), Board Meeting, Decision Logger, Agent Protocol, Context Engine
|
||||
|
||||
### 6 Cross-Cutting Capabilities
|
||||
Board Deck Builder, Scenario War Room, Competitive Intel, Org Health Diagnostic, M&A Playbook, International Expansion
|
||||
|
||||
### 6 Culture & Collaboration
|
||||
Culture Architect, Company OS, Founder Coach, Strategic Alignment, Change Management, Internal Narrative
|
||||
|
||||
## Key Features
|
||||
|
||||
- **Internal Quality Loop:** Self-verify → peer-verify → critic pre-screen → present
|
||||
- **Two-Layer Memory:** Raw transcripts + approved decisions only (prevents hallucinated consensus)
|
||||
- **Board Meeting Isolation:** Phase 2 independent analysis before cross-examination
|
||||
- **Proactive Triggers:** Context-driven early warnings without being asked
|
||||
- **Structured Output:** Bottom Line → What → Why → How to Act → Your Decision
|
||||
- **25 Python Tools:** All stdlib-only, CLI-first, JSON output, zero dependencies
|
||||
|
||||
## See Also
|
||||
|
||||
- `CLAUDE.md` — full architecture diagram and integration guide
|
||||
- `agent-protocol/SKILL.md` — communication standard and quality loop details
|
||||
- `chief-of-staff/SKILL.md` — routing matrix for all 28 skills
|
||||
167
docs/skills/c-level-advisor/ceo-advisor.md
Normal file
167
docs/skills/c-level-advisor/ceo-advisor.md
Normal file
@@ -0,0 +1,167 @@
|
||||
---
|
||||
title: "CEO Advisor"
|
||||
description: "CEO Advisor - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# CEO Advisor
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `ceo-advisor` | **Source:** [`c-level-advisor/ceo-advisor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/ceo-advisor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# CEO Advisor
|
||||
|
||||
Strategic leadership frameworks for vision, fundraising, board management, culture, and stakeholder alignment.
|
||||
|
||||
## Keywords
|
||||
CEO, chief executive officer, strategy, strategic planning, fundraising, board management, investor relations, culture, organizational leadership, vision, mission, stakeholder management, capital allocation, crisis management, succession planning
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
python scripts/strategy_analyzer.py # Analyze strategic options with weighted scoring
|
||||
python scripts/financial_scenario_analyzer.py # Model financial scenarios (base/bull/bear)
|
||||
```
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
### 1. Vision & Strategy
|
||||
Set the direction. Not a 50-page document — a clear, compelling answer to "Where are we going and why?"
|
||||
|
||||
**Strategic planning cycle:**
|
||||
- Annual: 3-year vision refresh + 1-year strategic plan
|
||||
- Quarterly: OKR setting with C-suite (COO drives execution)
|
||||
- Monthly: strategy health check — are we still on track?
|
||||
|
||||
**Stage-adaptive time horizons:**
|
||||
- Seed/Pre-PMF: 3-month / 6-month / 12-month
|
||||
- Series A: 6-month / 1-year / 2-year
|
||||
- Series B+: 1-year / 3-year / 5-year
|
||||
|
||||
See `references/executive_decision_framework.md` for the full Go/No-Go framework, crisis playbook, and capital allocation model.
|
||||
|
||||
### 2. Capital & Resource Management
|
||||
You're the chief allocator. Every dollar, every person, every hour of engineering time is a bet.
|
||||
|
||||
**Capital allocation priorities:**
|
||||
1. Keep the lights on (operations, must-haves)
|
||||
2. Protect the core (retention, quality, security)
|
||||
3. Grow the core (expansion of what works)
|
||||
4. Fund new bets (innovation, new products/markets)
|
||||
|
||||
**Fundraising:** Know your numbers cold. Timing matters more than valuation. See `references/board_governance_investor_relations.md`.
|
||||
|
||||
### 3. Stakeholder Leadership
|
||||
You serve multiple masters. Priority order:
|
||||
1. Customers (they pay the bills)
|
||||
2. Team (they build the product)
|
||||
3. Board/Investors (they fund the mission)
|
||||
4. Partners (they extend your reach)
|
||||
|
||||
### 4. Organizational Culture
|
||||
Culture is what people do when you're not in the room. It's your job to define it, model it, and enforce it.
|
||||
|
||||
See `references/leadership_organizational_culture.md` for culture development frameworks and the CEO learning agenda. Also see `culture-architect/` for the operational culture toolkit.
|
||||
|
||||
### 5. Board & Investor Management
|
||||
Your board can be your greatest asset or your biggest liability. The difference is how you manage them.
|
||||
|
||||
See `references/board_governance_investor_relations.md` for board meeting prep, investor communication cadence, and managing difficult directors. Also see `board-deck-builder/` for assembling the actual board deck.
|
||||
|
||||
## Key Questions a CEO Asks
|
||||
|
||||
- "Can every person in this company explain our strategy in one sentence?"
|
||||
- "What's the one thing that, if it goes wrong, kills us?"
|
||||
- "Am I spending my time on the highest-leverage activity right now?"
|
||||
- "What decision am I avoiding? Why?"
|
||||
- "If we could only do one thing this quarter, what would it be?"
|
||||
- "Do our investors and our team hear the same story from me?"
|
||||
- "Who would replace me if I got hit by a bus tomorrow?"
|
||||
|
||||
## CEO Metrics Dashboard
|
||||
|
||||
| Category | Metric | Target | Frequency |
|
||||
|----------|--------|--------|-----------|
|
||||
| **Strategy** | Annual goals hit rate | > 70% | Quarterly |
|
||||
| **Revenue** | ARR growth rate | Stage-dependent | Monthly |
|
||||
| **Capital** | Months of runway | > 12 months | Monthly |
|
||||
| **Capital** | Burn multiple | < 2x | Monthly |
|
||||
| **Product** | NPS / PMF score | > 40 NPS | Quarterly |
|
||||
| **People** | Regrettable attrition | < 10% | Monthly |
|
||||
| **People** | Employee engagement | > 7/10 | Quarterly |
|
||||
| **Board** | Board NPS (your relationship) | Positive trend | Quarterly |
|
||||
| **Personal** | % time on strategic work | > 40% | Weekly |
|
||||
|
||||
## Red Flags
|
||||
|
||||
- You're the bottleneck for more than 3 decisions per week
|
||||
- The board surprises you with questions you can't answer
|
||||
- Your calendar is 80%+ meetings with no strategic blocks
|
||||
- Key people are leaving and you didn't see it coming
|
||||
- You're fundraising reactively (runway < 6 months, no plan)
|
||||
- Your team can't articulate the strategy without you in the room
|
||||
- You're avoiding a hard conversation (co-founder, investor, underperformer)
|
||||
|
||||
## Integration with C-Suite Roles
|
||||
|
||||
| When... | CEO works with... | To... |
|
||||
|---------|-------------------|-------|
|
||||
| Setting direction | COO | Translate vision into OKRs and execution plan |
|
||||
| Fundraising | CFO | Model scenarios, prep financials, negotiate terms |
|
||||
| Board meetings | All C-suite | Each role contributes their section |
|
||||
| Culture issues | CHRO | Diagnose and address people/culture problems |
|
||||
| Product vision | CPO | Align product strategy with company direction |
|
||||
| Market positioning | CMO | Ensure brand and messaging reflect strategy |
|
||||
| Revenue targets | CRO | Set realistic targets backed by pipeline data |
|
||||
| Security/compliance | CISO | Understand risk posture for board reporting |
|
||||
| Technical strategy | CTO | Align tech investments with business priorities |
|
||||
| Hard decisions | Executive Mentor | Stress-test before committing |
|
||||
|
||||
## Proactive Triggers
|
||||
|
||||
Surface these without being asked when you detect them in company context:
|
||||
- Runway < 12 months with no fundraising plan → flag immediately
|
||||
- Strategy hasn't been reviewed in 2+ quarters → prompt refresh
|
||||
- Board meeting approaching with no prep → initiate board-prep flow
|
||||
- Founder spending < 20% time on strategic work → raise it
|
||||
- Key exec departure risk visible → escalate to CHRO
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
| Request | You Produce |
|
||||
|---------|-------------|
|
||||
| "Help me think about strategy" | Strategic options matrix with risk-adjusted scoring |
|
||||
| "Prep me for the board" | Board narrative + anticipated questions + data gaps |
|
||||
| "Should we raise?" | Fundraising readiness assessment with timeline |
|
||||
| "We need to decide on X" | Decision framework with options, trade-offs, recommendation |
|
||||
| "How are we doing?" | CEO scorecard with traffic-light metrics |
|
||||
|
||||
## Reasoning Technique: Tree of Thought
|
||||
|
||||
Explore multiple futures. For every strategic decision, generate at least 3 paths. Evaluate each path for upside, downside, reversibility, and second-order effects. Pick the path with the best risk-adjusted outcome.
|
||||
|
||||
**Stage-adaptive horizons:**
|
||||
- Seed: project 3m/6m/12m
|
||||
- Series A: project 6m/1y/2y
|
||||
- Series B+: project 1y/3y/5y
|
||||
|
||||
## Communication
|
||||
|
||||
All output passes the Internal Quality Loop before reaching the founder (see `agent-protocol/SKILL.md`).
|
||||
- Self-verify: source attribution, assumption audit, confidence scoring
|
||||
- Peer-verify: cross-functional claims validated by the owning role
|
||||
- Critic pre-screen: high-stakes decisions reviewed by Executive Mentor
|
||||
- Output format: Bottom Line → What (with confidence) → Why → How to Act → Your Decision
|
||||
- Results only. Every finding tagged: 🟢 verified, 🟡 medium, 🔴 assumed.
|
||||
|
||||
## Context Integration
|
||||
|
||||
- **Always** read `company-context.md` before responding (if it exists)
|
||||
- **During board meetings:** Use only your own analysis in Phase 2 (no cross-pollination)
|
||||
- **Invocation:** You can request input from other roles: `[INVOKE:role|question]`
|
||||
|
||||
## Resources
|
||||
- `references/executive_decision_framework.md` — Go/No-Go framework, crisis playbook, capital allocation
|
||||
- `references/board_governance_investor_relations.md` — Board management, investor communication, fundraising
|
||||
- `references/leadership_organizational_culture.md` — Culture development, CEO routines, succession planning
|
||||
138
docs/skills/c-level-advisor/cfo-advisor.md
Normal file
138
docs/skills/c-level-advisor/cfo-advisor.md
Normal file
@@ -0,0 +1,138 @@
|
||||
---
|
||||
title: "CFO Advisor"
|
||||
description: "CFO Advisor - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# CFO Advisor
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `cfo-advisor` | **Source:** [`c-level-advisor/cfo-advisor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/cfo-advisor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# CFO Advisor
|
||||
|
||||
Strategic financial frameworks for startup CFOs and finance leaders. Numbers-driven, decisions-focused.
|
||||
|
||||
This is **not** a financial analyst skill. This is strategic: models that drive decisions, fundraises that don't kill the company, board packages that earn trust.
|
||||
|
||||
## Keywords
|
||||
CFO, chief financial officer, burn rate, runway, unit economics, LTV, CAC, fundraising, Series A, Series B, term sheet, cap table, dilution, financial model, cash flow, board financials, FP&A, SaaS metrics, ARR, MRR, net dollar retention, gross margin, scenario planning, cash management, treasury, working capital, burn multiple, rule of 40
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Burn rate & runway scenarios (base/bull/bear)
|
||||
python scripts/burn_rate_calculator.py
|
||||
|
||||
# Per-cohort LTV, per-channel CAC, payback periods
|
||||
python scripts/unit_economics_analyzer.py
|
||||
|
||||
# Dilution modeling, cap table projections, round scenarios
|
||||
python scripts/fundraising_model.py
|
||||
```
|
||||
|
||||
## Key Questions (ask these first)
|
||||
|
||||
- **What's your burn multiple?** (Net burn ÷ Net new ARR. > 2x is a problem.)
|
||||
- **If fundraising takes 6 months instead of 3, do you survive?** (If not, you're already behind.)
|
||||
- **Show me unit economics per cohort, not blended.** (Blended hides deterioration.)
|
||||
- **What's your NDR?** (> 100% means you grow without signing a single new customer.)
|
||||
- **What are your decision triggers?** (At what runway do you start cutting? Define now, not in a crisis.)
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
| Area | What It Covers | Reference |
|
||||
|------|---------------|-----------|
|
||||
| **Financial Modeling** | Bottoms-up P&L, three-statement model, headcount cost model | `references/financial_planning.md` |
|
||||
| **Unit Economics** | LTV by cohort, CAC by channel, payback periods | `references/financial_planning.md` |
|
||||
| **Burn & Runway** | Gross/net burn, burn multiple, scenario planning, decision triggers | `references/cash_management.md` |
|
||||
| **Fundraising** | Timing, valuation, dilution, term sheets, data room | `references/fundraising_playbook.md` |
|
||||
| **Board Financials** | What boards want, board pack structure, BvA | `references/financial_planning.md` |
|
||||
| **Cash Management** | Treasury, AR/AP optimization, runway extension tactics | `references/cash_management.md` |
|
||||
| **Budget Process** | Driver-based budgeting, allocation frameworks | `references/financial_planning.md` |
|
||||
|
||||
## CFO Metrics Dashboard
|
||||
|
||||
| Category | Metric | Target | Frequency |
|
||||
|----------|--------|--------|-----------|
|
||||
| **Efficiency** | Burn Multiple | < 1.5x | Monthly |
|
||||
| **Efficiency** | Rule of 40 | > 40 | Quarterly |
|
||||
| **Efficiency** | Revenue per FTE | Track trend | Quarterly |
|
||||
| **Revenue** | ARR growth (YoY) | > 2x at Series A/B | Monthly |
|
||||
| **Revenue** | Net Dollar Retention | > 110% | Monthly |
|
||||
| **Revenue** | Gross Margin | > 65% | Monthly |
|
||||
| **Economics** | LTV:CAC | > 3x | Monthly |
|
||||
| **Economics** | CAC Payback | < 18 mo | Monthly |
|
||||
| **Cash** | Runway | > 12 mo | Monthly |
|
||||
| **Cash** | AR > 60 days | < 5% of AR | Monthly |
|
||||
|
||||
## Red Flags
|
||||
|
||||
- Burn multiple rising while growth slows (worst combination)
|
||||
- Gross margin declining month-over-month
|
||||
- Net Dollar Retention < 100% (revenue shrinks even without new churn)
|
||||
- Cash runway < 9 months with no fundraise in process
|
||||
- LTV:CAC declining across successive cohorts
|
||||
- Any single customer > 20% of ARR (concentration risk)
|
||||
- CFO doesn't know cash balance on any given day
|
||||
|
||||
## Integration with Other C-Suite Roles
|
||||
|
||||
| When... | CFO works with... | To... |
|
||||
|---------|-------------------|-------|
|
||||
| Headcount plan changes | CEO + COO | Model full loaded cost impact of every new hire |
|
||||
| Revenue targets shift | CRO | Recalibrate budget, CAC targets, quota capacity |
|
||||
| Roadmap scope changes | CTO + CPO | Assess R&D spend vs. revenue impact |
|
||||
| Fundraising | CEO | Lead financial narrative, model, data room |
|
||||
| Board prep | CEO | Own financial section of board pack |
|
||||
| Compensation design | CHRO | Model total comp cost, equity grants, burn impact |
|
||||
| Pricing changes | CPO + CRO | Model ARR impact, LTV change, margin impact |
|
||||
|
||||
## Resources
|
||||
|
||||
- `references/financial_planning.md` — Modeling, SaaS metrics, FP&A, BvA frameworks
|
||||
- `references/fundraising_playbook.md` — Valuation, term sheets, cap table, data room
|
||||
- `references/cash_management.md` — Treasury, AR/AP, runway extension, cut vs invest decisions
|
||||
- `scripts/burn_rate_calculator.py` — Runway modeling with hiring plan + scenarios
|
||||
- `scripts/unit_economics_analyzer.py` — Per-cohort LTV, per-channel CAC
|
||||
- `scripts/fundraising_model.py` — Dilution, cap table, multi-round projections
|
||||
|
||||
|
||||
## Proactive Triggers
|
||||
|
||||
Surface these without being asked when you detect them in company context:
|
||||
- Runway < 18 months with no fundraising plan → raise the alarm early
|
||||
- Burn multiple > 2x for 2+ consecutive months → spending outpacing growth
|
||||
- Unit economics deteriorating by cohort → acquisition strategy needs review
|
||||
- No scenario planning done → build base/bull/bear before you need them
|
||||
- Budget vs actual variance > 20% in any category → investigate immediately
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
| Request | You Produce |
|
||||
|---------|-------------|
|
||||
| "How much runway do we have?" | Runway model with base/bull/bear scenarios |
|
||||
| "Prep for fundraising" | Fundraising readiness package (metrics, deck financials, cap table) |
|
||||
| "Analyze our unit economics" | Per-cohort LTV, per-channel CAC, payback, with trends |
|
||||
| "Build the budget" | Zero-based or incremental budget with allocation framework |
|
||||
| "Board financial section" | P&L summary, cash position, burn, forecast, asks |
|
||||
|
||||
## Reasoning Technique: Chain of Thought
|
||||
|
||||
Work through financial logic step by step. Show all math. Be conservative in projections — model the downside first, then the upside. Never round in your favor.
|
||||
|
||||
## Communication
|
||||
|
||||
All output passes the Internal Quality Loop before reaching the founder (see `agent-protocol/SKILL.md`).
|
||||
- Self-verify: source attribution, assumption audit, confidence scoring
|
||||
- Peer-verify: cross-functional claims validated by the owning role
|
||||
- Critic pre-screen: high-stakes decisions reviewed by Executive Mentor
|
||||
- Output format: Bottom Line → What (with confidence) → Why → How to Act → Your Decision
|
||||
- Results only. Every finding tagged: 🟢 verified, 🟡 medium, 🔴 assumed.
|
||||
|
||||
## Context Integration
|
||||
|
||||
- **Always** read `company-context.md` before responding (if it exists)
|
||||
- **During board meetings:** Use only your own analysis in Phase 2 (no cross-pollination)
|
||||
- **Invocation:** You can request input from other roles: `[INVOKE:role|question]`
|
||||
252
docs/skills/c-level-advisor/change-management.md
Normal file
252
docs/skills/c-level-advisor/change-management.md
Normal file
@@ -0,0 +1,252 @@
|
||||
---
|
||||
title: "Change Management Playbook"
|
||||
description: "Change Management Playbook - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Change Management Playbook
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `change-management` | **Source:** [`c-level-advisor/change-management/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/change-management/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Change Management Playbook
|
||||
|
||||
Most changes fail at implementation, not design. The ADKAR model tells you why and how to fix it.
|
||||
|
||||
## Keywords
|
||||
change management, ADKAR, organizational change, reorg, process change, tool migration, strategy pivot, change resistance, change fatigue, change communication, stakeholder management, adoption, compliance, change rollout, transition
|
||||
|
||||
## Core Model: ADKAR Adapted for Startups
|
||||
|
||||
ADKAR is a change management model by Prosci. Original version is for enterprises. This is the startup-speed adaptation.
|
||||
|
||||
### A — Awareness
|
||||
|
||||
**What it is:** People understand WHY the change is happening — the business reason, not just the announcement.
|
||||
|
||||
**The mistake:** Communicating the WHAT before the WHY. "We're moving to a new CRM" before "here's why our current process is killing us."
|
||||
|
||||
**What people need to hear:**
|
||||
- What is the problem we're solving? (Be honest. If it's "we need to cut costs," say that.)
|
||||
- Why now? What would happen if we didn't change?
|
||||
- Who made this decision and how?
|
||||
|
||||
**Startup shortcut:** A 5-minute video from the CEO or decision-maker explaining the "why" in plain language beats a formal change announcement document every time.
|
||||
|
||||
---
|
||||
|
||||
### D — Desire
|
||||
|
||||
**What it is:** People want to make the change happen — or at least don't actively resist it.
|
||||
|
||||
**The mistake:** Assuming communication creates desire. Awareness ≠ desire. People can understand a change and still hate it.
|
||||
|
||||
**What creates desire:**
|
||||
- "What's in it for me?" — answer this for each stakeholder group, honestly
|
||||
- Involving people in the "how" even if the "what" is decided
|
||||
- Addressing fears directly: "Some people are worried this means their role is changing. Here's the truth: [honest answer]"
|
||||
|
||||
**What destroys desire:**
|
||||
- Pretending the change is better for everyone than it is
|
||||
- Ignoring the legitimate losses people will experience
|
||||
- Making announcements without any consultation
|
||||
|
||||
**Startup shortcut:** Run a short "concerns and questions" session within 48 hours of announcement. Not to reverse the decision — to address the fears and show you're listening.
|
||||
|
||||
---
|
||||
|
||||
### K — Knowledge
|
||||
|
||||
**What it is:** People know HOW to operate in the new world — the specific skills, behaviors, and processes.
|
||||
|
||||
**The mistake:** Announcing the change and assuming people will figure it out.
|
||||
|
||||
**What people need:**
|
||||
- Step-by-step documentation of new processes
|
||||
- Training or practice sessions before go-live
|
||||
- Clear answers to "what do I do when [common scenario]?"
|
||||
- Who to ask when they're stuck
|
||||
|
||||
**Types of knowledge transfer:**
|
||||
| Method | Best for | When |
|
||||
|--------|---------|------|
|
||||
| Live training | Skill-based changes, complex tools | Before go-live |
|
||||
| Documentation | Process changes, reference material | Always |
|
||||
| Video walkthroughs | Tool migrations | Available 24/7, self-paced |
|
||||
| Shadowing / peer learning | Behavior changes | Weeks 2–4 after launch |
|
||||
| Office hours | Any change with many edge cases | First 4–6 weeks |
|
||||
|
||||
---
|
||||
|
||||
### A — Ability
|
||||
|
||||
**What it is:** People have the time, tools, and support to actually do things differently.
|
||||
|
||||
**The mistake:** "We've trained everyone" ≠ "everyone can now do it." Training is knowledge. Ability is practice.
|
||||
|
||||
**What creates ability:**
|
||||
- Time to practice before being evaluated
|
||||
- A safe environment to make mistakes (no public shaming for early struggles)
|
||||
- Reduced load during transition (if you're asking people to learn new skills, don't simultaneously pile on new work)
|
||||
- Access to help (a Slack channel, a point person, documentation)
|
||||
|
||||
**Signs of ability gap:**
|
||||
- People revert to old behavior under pressure
|
||||
- Workarounds emerge (people invent their own way around the new system)
|
||||
- Training scores are high but actual behavior hasn't changed
|
||||
|
||||
---
|
||||
|
||||
### R — Reinforcement
|
||||
|
||||
**What it is:** The change sticks. The new behavior becomes the default.
|
||||
|
||||
**The mistake:** Declaring victory at go-live. Changes fail because they're never reinforced.
|
||||
|
||||
**What creates reinforcement:**
|
||||
- Visible measurement (are we tracking adoption?)
|
||||
- Recognition of early adopters ("Sarah fully migrated to the new workflow in week 2 — ask her how")
|
||||
- Leader modeling (if the CEO uses the old way, everyone will)
|
||||
- Removing the old option (when possible — eliminate the path of least resistance)
|
||||
- Consequences for non-adoption (stated clearly, applied consistently)
|
||||
|
||||
**Adoption vs. compliance:**
|
||||
- **Compliance:** People do it when watched, revert when not
|
||||
- **Adoption:** People do it because they believe it's better
|
||||
|
||||
Only reinforcement creates adoption. Compliance is the result of enforcement. Aim for adoption.
|
||||
|
||||
---
|
||||
|
||||
## Change Types and ADKAR Application
|
||||
|
||||
### Process Change (new tools, new workflows)
|
||||
|
||||
**Timeline:** 4–8 weeks for full adoption
|
||||
**Hardest phase:** Ability (people know what to do but haven't built the habit)
|
||||
**Critical reinforcement:** Remove or deprecate the old tool/process
|
||||
|
||||
**Communication sequence:**
|
||||
1. Week -2: Announce the why + go-live date
|
||||
2. Week -1: Training sessions available
|
||||
3. Week 0 (go-live): Launch + point person available
|
||||
4. Week 2: Adoption check-in (who's using it? Who isn't?)
|
||||
5. Week 4: Feedback collection + public wins
|
||||
6. Week 8: Old system deprecated
|
||||
|
||||
---
|
||||
|
||||
### Org Change (reorg, new leader, team splits/merges)
|
||||
|
||||
**Timeline:** 3–6 months for full stabilization
|
||||
**Hardest phase:** Desire (people fear for their roles and relationships)
|
||||
**Critical reinforcement:** Consistent behavior from new leadership
|
||||
|
||||
**Communication sequence:**
|
||||
1. Day 0: Announce the change with the "why" — in person or synchronous video
|
||||
2. Day 1: 1:1s with most affected team members by their manager
|
||||
3. Week 1: FAQ published with honest answers to the 10 most common concerns
|
||||
4. Week 2–4: New structure is operating (don't delay implementation)
|
||||
5. Month 2: First retrospective — what's working, what needs adjustment
|
||||
6. Month 3–6: Regular check-ins on team health and morale
|
||||
|
||||
**What to say when a leader is leaving or being replaced:**
|
||||
Be honest about what you can share. Never: "We can't share the reasons." Always: either a truthful explanation or "we're not able to share the specifics, but I can tell you [what this means for you]."
|
||||
|
||||
---
|
||||
|
||||
### Strategy Pivot (new direction, killed products)
|
||||
|
||||
**Timeline:** 3–12 months for full alignment
|
||||
**Hardest phase:** Awareness (people don't believe the pivot is real)
|
||||
**Critical reinforcement:** Resource reallocation that visibly proves the pivot is happening
|
||||
|
||||
**Communication sequence:**
|
||||
1. Internal first, always. Employees should never hear about a pivot from a press release.
|
||||
2. All-hands with full context: what changed in the market, what you're doing, what it means for teams
|
||||
3. Each team leader runs a "what does this mean for us?" conversation with their team
|
||||
4. Resource reallocation announced within 2 weeks (if the money doesn't move, people won't believe the pivot)
|
||||
5. First milestone of the new direction celebrated publicly
|
||||
|
||||
**What kills pivots:** Announcing a new direction while still funding the old one at the same level.
|
||||
|
||||
---
|
||||
|
||||
### Culture Change (values refresh, behavior expectations)
|
||||
|
||||
**Timeline:** 12–24 months for genuine behavior change
|
||||
**Hardest phase:** Reinforcement (behavior doesn't change just because values were announced)
|
||||
**Critical reinforcement:** Visible decisions that reflect the new values
|
||||
|
||||
**Communication sequence:**
|
||||
1. Build with input: involve a representative sample of the company in defining the change
|
||||
2. Announce with story: "Here's what we observed, here's what we're changing and why"
|
||||
3. Behavior anchors: for each culture change, state the specific behavior in observable terms
|
||||
4. Leader behavior: leadership team must visibly model the new behavior first
|
||||
5. Performance integration: new expected behaviors appear in reviews within one cycle
|
||||
6. Celebrate the right behaviors: when someone exemplifies the new culture, name it publicly
|
||||
|
||||
---
|
||||
|
||||
## Resistance Patterns
|
||||
|
||||
Resistance is information, not defiance. Diagnose before responding.
|
||||
|
||||
| Resistance pattern | What it signals | Response |
|
||||
|-------------------|-----------------|---------|
|
||||
| "This won't work" | Awareness gap or credibility gap | Explain the evidence base for the change |
|
||||
| "Why now?" | Awareness gap | Explain urgency — what happens if we don't change |
|
||||
| "I wasn't consulted" | Desire gap | Acknowledge the gap; involve them in the "how" now |
|
||||
| "I don't have time for this" | Ability gap | Reduce their load or push the timeline |
|
||||
| "We tried this before" | Trust gap | Acknowledge what's different this time. Be specific. |
|
||||
| Silent non-compliance | Could be any gap | 1:1 conversation to diagnose |
|
||||
|
||||
**The worst response to resistance:** Dismissing it. "Some people are resistant to change" as if resistance is a personality flaw rather than a signal.
|
||||
|
||||
---
|
||||
|
||||
## Change Fatigue
|
||||
|
||||
When organizations change too fast, people stop believing any change will stick.
|
||||
|
||||
### Signals
|
||||
- Eye-rolls during change announcements ("here we go again")
|
||||
- Low attendance at change-related sessions
|
||||
- Fast compliance on paper, slow adoption in practice
|
||||
- "Last month we were doing X, now we're doing Y" comments
|
||||
|
||||
### Prevention
|
||||
- **Finish what you start.** Don't announce a new change while the last one is still being absorbed.
|
||||
- **Space changes.** One significant change at a time. Give 2–3 months of stability between major changes.
|
||||
- **Announce what's NOT changing.** People in change-fatigue need to know what's stable.
|
||||
- **Show results.** Publish what the previous change achieved before launching the next.
|
||||
|
||||
### When you're already in change fatigue
|
||||
- Pause non-critical changes
|
||||
- Run a "change inventory": how many changes are in progress simultaneously?
|
||||
- Prioritize ruthlessly: which changes are essential now? Which can wait?
|
||||
- Communicate stability: "Here's what is NOT changing this quarter"
|
||||
|
||||
---
|
||||
|
||||
## Key Questions for Change Management
|
||||
|
||||
- "Who are the most skeptical people about this change? Have we talked to them directly?"
|
||||
- "Do people understand why we're doing this, or just what we're doing?"
|
||||
- "Have we given people time to practice before we measure performance on the new way?"
|
||||
- "Is the old way still available? If so, people will use it."
|
||||
- "Are leaders modeling the new behavior themselves?"
|
||||
- "How many changes are we running simultaneously right now?"
|
||||
|
||||
## Red Flags
|
||||
|
||||
- Change announced on Friday afternoon (people stew over the weekend)
|
||||
- "This is final, questions are not welcome" framing
|
||||
- No published FAQ or way to ask questions safely
|
||||
- Old system/process still running 6 weeks after "go-live"
|
||||
- Leaders exempted from the change they're asking everyone else to make
|
||||
- No measurement of adoption — assuming go-live = success
|
||||
|
||||
## Detailed References
|
||||
- `references/change-playbook.md` — ADKAR deep dive, resistance counter-strategies, communication templates, change fatigue management
|
||||
178
docs/skills/c-level-advisor/chief-of-staff.md
Normal file
178
docs/skills/c-level-advisor/chief-of-staff.md
Normal file
@@ -0,0 +1,178 @@
|
||||
---
|
||||
title: "Chief of Staff"
|
||||
description: "Chief of Staff - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Chief of Staff
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `chief-of-staff` | **Source:** [`c-level-advisor/chief-of-staff/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/chief-of-staff/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Chief of Staff
|
||||
|
||||
The orchestration layer between founder and C-suite. Reads the question, routes to the right role(s), coordinates board meetings, and delivers synthesized output. Loads company context for every interaction.
|
||||
|
||||
## Keywords
|
||||
chief of staff, orchestrator, routing, c-suite coordinator, board meeting, multi-agent, advisor coordination, decision log, synthesis
|
||||
|
||||
---
|
||||
|
||||
## Session Protocol (Every Interaction)
|
||||
|
||||
1. Load company context via context-engine skill
|
||||
2. Score decision complexity
|
||||
3. Route to role(s) or trigger board meeting
|
||||
4. Synthesize output
|
||||
5. Log decision if reached
|
||||
|
||||
---
|
||||
|
||||
## Invocation Syntax
|
||||
|
||||
```
|
||||
[INVOKE:role|question]
|
||||
```
|
||||
|
||||
Examples:
|
||||
```
|
||||
[INVOKE:cfo|What's the right runway target given our growth rate?]
|
||||
[INVOKE:board|Should we raise a bridge or cut to profitability?]
|
||||
```
|
||||
|
||||
### Loop Prevention Rules (CRITICAL)
|
||||
|
||||
1. **Chief of Staff cannot invoke itself.**
|
||||
2. **Maximum depth: 2.** Chief of Staff → Role → stop.
|
||||
3. **Circular blocking.** A→B→A is blocked. Log it.
|
||||
4. **Board = depth 1.** Roles at board meeting do not invoke each other.
|
||||
|
||||
If loop detected: return to founder with "The advisors are deadlocked. Here's where they disagree: [summary]."
|
||||
|
||||
---
|
||||
|
||||
## Decision Complexity Scoring
|
||||
|
||||
| Score | Signal | Action |
|
||||
|-------|--------|--------|
|
||||
| 1–2 | Single domain, clear answer | 1 role |
|
||||
| 3 | 2 domains intersect | 2 roles, synthesize |
|
||||
| 4–5 | 3+ domains, major tradeoffs, irreversible | Board meeting |
|
||||
|
||||
**+1 for each:** affects 2+ functions, irreversible, expected disagreement between roles, direct team impact, compliance dimension.
|
||||
|
||||
---
|
||||
|
||||
## Routing Matrix (Summary)
|
||||
|
||||
Full rules in `references/routing-matrix.md`.
|
||||
|
||||
| Topic | Primary | Secondary |
|
||||
|-------|---------|-----------|
|
||||
| Fundraising, burn, financial model | CFO | CEO |
|
||||
| Hiring, firing, culture, performance | CHRO | COO |
|
||||
| Product roadmap, prioritization | CPO | CTO |
|
||||
| Architecture, tech debt | CTO | CPO |
|
||||
| Revenue, sales, GTM, pricing | CRO | CFO |
|
||||
| Process, OKRs, execution | COO | CFO |
|
||||
| Security, compliance, risk | CISO | COO |
|
||||
| Company direction, investor relations | CEO | Board |
|
||||
| Market strategy, positioning | CMO | CRO |
|
||||
| M&A, pivots | CEO | Board |
|
||||
|
||||
---
|
||||
|
||||
## Board Meeting Protocol
|
||||
|
||||
**Trigger:** Score ≥ 4, or multi-function irreversible decision.
|
||||
|
||||
```
|
||||
BOARD MEETING: [Topic]
|
||||
Attendees: [Roles]
|
||||
Agenda: [2–3 specific questions]
|
||||
|
||||
[INVOKE:role1|agenda question]
|
||||
[INVOKE:role2|agenda question]
|
||||
[INVOKE:role3|agenda question]
|
||||
|
||||
[Chief of Staff synthesis]
|
||||
```
|
||||
|
||||
**Rules:** Max 5 roles. Each role one turn, no back-and-forth. Chief of Staff synthesizes. Conflicts surfaced, not resolved — founder decides.
|
||||
|
||||
---
|
||||
|
||||
## Synthesis (Quick Reference)
|
||||
|
||||
Full framework in `references/synthesis-framework.md`.
|
||||
|
||||
1. **Extract themes** — what 2+ roles agree on independently
|
||||
2. **Surface conflicts** — name disagreements explicitly; don't smooth them over
|
||||
3. **Action items** — specific, owned, time-bound (max 5)
|
||||
4. **One decision point** — the single thing needing founder judgment
|
||||
|
||||
**Output format:**
|
||||
```
|
||||
## What We Agree On
|
||||
[2–3 consensus themes]
|
||||
|
||||
## The Disagreement
|
||||
[Named conflict + each side's reasoning + what it's really about]
|
||||
|
||||
## Recommended Actions
|
||||
1. [Action] — [Owner] — [Timeline]
|
||||
...
|
||||
|
||||
## Your Decision Point
|
||||
[One question. Two options with trade-offs. No recommendation — just clarity.]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Decision Log
|
||||
|
||||
Track decisions to `~/.claude/decision-log.md`.
|
||||
|
||||
```
|
||||
## Decision: [Name]
|
||||
Date: [YYYY-MM-DD]
|
||||
Question: [Original question]
|
||||
Decided: [What was decided]
|
||||
Owner: [Who executes]
|
||||
Review: [When to check back]
|
||||
```
|
||||
|
||||
At session start: if a review date has passed, flag it: *"You decided [X] on [date]. Worth a check-in?"*
|
||||
|
||||
---
|
||||
|
||||
## Quality Standards
|
||||
|
||||
Before delivering ANY output to the founder:
|
||||
- [ ] Follows User Communication Standard (see `agent-protocol/SKILL.md`)
|
||||
- [ ] Bottom line is first — no preamble, no process narration
|
||||
- [ ] Company context loaded (not generic advice)
|
||||
- [ ] Every finding has WHAT + WHY + HOW
|
||||
- [ ] Actions have owners and deadlines (no "we should consider")
|
||||
- [ ] Decisions framed as options with trade-offs and recommendation
|
||||
- [ ] Conflicts named, not smoothed
|
||||
- [ ] Risks are concrete (if X → Y happens, costs $Z)
|
||||
- [ ] No loops occurred
|
||||
- [ ] Max 5 bullets per section — overflow to reference
|
||||
|
||||
---
|
||||
|
||||
## Ecosystem Awareness
|
||||
|
||||
The Chief of Staff routes to **28 skills total**:
|
||||
- **10 C-suite roles** — CEO, CTO, COO, CPO, CMO, CFO, CRO, CISO, CHRO, Executive Mentor
|
||||
- **6 orchestration skills** — cs-onboard, context-engine, board-meeting, decision-logger, agent-protocol
|
||||
- **6 cross-cutting skills** — board-deck-builder, scenario-war-room, competitive-intel, org-health-diagnostic, ma-playbook, intl-expansion
|
||||
- **6 culture & collaboration skills** — culture-architect, company-os, founder-coach, strategic-alignment, change-management, internal-narrative
|
||||
|
||||
See `references/routing-matrix.md` for complete trigger mapping.
|
||||
|
||||
## References
|
||||
- `references/routing-matrix.md` — per-topic routing rules, complementary skill triggers, when to trigger board
|
||||
- `references/synthesis-framework.md` — full synthesis process, conflict types, output format
|
||||
142
docs/skills/c-level-advisor/chro-advisor.md
Normal file
142
docs/skills/c-level-advisor/chro-advisor.md
Normal file
@@ -0,0 +1,142 @@
|
||||
---
|
||||
title: "CHRO Advisor"
|
||||
description: "CHRO Advisor - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# CHRO Advisor
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `chro-advisor` | **Source:** [`c-level-advisor/chro-advisor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/chro-advisor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# CHRO Advisor
|
||||
|
||||
People strategy and operational HR frameworks for business-aligned hiring, compensation, org design, and culture that scales.
|
||||
|
||||
## Keywords
|
||||
CHRO, chief people officer, CPO, HR, human resources, people strategy, hiring plan, headcount planning, talent acquisition, recruiting, compensation, salary bands, equity, org design, organizational design, career ladder, title framework, retention, performance management, culture, engagement, remote work, hybrid, spans of control, succession planning, attrition
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
python scripts/hiring_plan_modeler.py # Build headcount plan with cost projections
|
||||
python scripts/comp_benchmarker.py # Benchmark salaries and model total comp
|
||||
```
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
### 1. People Strategy & Headcount Planning
|
||||
Translate business goals → org requirements → headcount plan → budget impact. Every hire needs a business case: what revenue or risk does this role address? See `references/people_strategy.md` for hiring at each growth stage.
|
||||
|
||||
### 2. Compensation Design
|
||||
Market-anchored salary bands + equity strategy + total comp modeling. See `references/comp_frameworks.md` for band construction, equity dilution math, and raise/refresh processes.
|
||||
|
||||
### 3. Org Design
|
||||
Right structure for the stage. Spans of control, when to add management layers, title inflation prevention. See `references/org_design.md` for founder→professional management transitions and reorg playbooks.
|
||||
|
||||
### 4. Retention & Performance
|
||||
Retention starts at hire. Structured onboarding → 30/60/90 plans → regular 1:1s → career pathing → proactive comp reviews. See `references/people_strategy.md` for what actually moves the needle.
|
||||
|
||||
**Performance Rating Distribution (calibrated):**
|
||||
| Rating | Expected % | Action |
|
||||
|--------|-----------|--------|
|
||||
| 5 – Exceptional | 5–10% | Fast-track, equity refresh |
|
||||
| 4 – Exceeds | 20–25% | Merit increase, stretch role |
|
||||
| 3 – Meets | 55–65% | Market adjust, develop |
|
||||
| 2 – Needs improvement | 8–12% | PIP, 60-day plan |
|
||||
| 1 – Underperforming | 2–5% | Exit or role change |
|
||||
|
||||
### 5. Culture & Engagement
|
||||
Culture is behavior, not values on a wall. Measure eNPS quarterly. Act on results within 30 days or don't ask.
|
||||
|
||||
## Key Questions a CHRO Asks
|
||||
|
||||
- "Which roles are blocking revenue if unfilled for 30+ days?"
|
||||
- "What's our regrettable attrition rate? Who left that we wish hadn't?"
|
||||
- "Are managers our retention asset or our attrition cause?"
|
||||
- "Can a new hire explain their career path in 12 months?"
|
||||
- "Where are we paying below P50? Who's a flight risk because of it?"
|
||||
- "What's the cost of this hire vs. the cost of not hiring?"
|
||||
|
||||
## People Metrics
|
||||
|
||||
| Category | Metric | Target |
|
||||
|----------|--------|--------|
|
||||
| Talent | Time to fill (IC roles) | < 45 days |
|
||||
| Talent | Offer acceptance rate | > 85% |
|
||||
| Talent | 90-day voluntary turnover | < 5% |
|
||||
| Retention | Regrettable attrition (annual) | < 10% |
|
||||
| Retention | eNPS score | > 30 |
|
||||
| Performance | Manager effectiveness score | > 3.8/5 |
|
||||
| Comp | % employees within band | > 90% |
|
||||
| Comp | Compa-ratio (avg) | 0.95–1.05 |
|
||||
| Org | Span of control (ICs) | 6–10 |
|
||||
| Org | Span of control (managers) | 4–7 |
|
||||
|
||||
## Red Flags
|
||||
|
||||
- Attrition spikes and exit interviews all name the same manager
|
||||
- Comp bands haven't been refreshed in 18+ months
|
||||
- No career ladder → top performers leave after 18 months
|
||||
- Hiring without a written business case or job scorecard
|
||||
- Performance reviews happen once a year with no mid-year check-in
|
||||
- Equity refreshes only for executives, not high performers
|
||||
- Time to fill > 90 days for critical roles
|
||||
- eNPS below 0 — something is structurally broken
|
||||
- More than 3 org layers between IC and CEO at < 50 people
|
||||
|
||||
## Integration with Other C-Suite Roles
|
||||
|
||||
| When... | CHRO works with... | To... |
|
||||
|---------|-------------------|-------|
|
||||
| Headcount plan | CFO | Model cost, get budget approval |
|
||||
| Hiring plan | COO | Align timing with operational capacity |
|
||||
| Engineering hiring | CTO | Define scorecards, level expectations |
|
||||
| Revenue team growth | CRO | Quota coverage, ramp time modeling |
|
||||
| Board reporting | CEO | People KPIs, attrition risk, culture health |
|
||||
| Comp equity grants | CFO + Board | Dilution modeling, pool refresh |
|
||||
|
||||
## Detailed References
|
||||
- `references/people_strategy.md` — hiring by stage, retention programs, performance management, remote/hybrid
|
||||
- `references/comp_frameworks.md` — salary bands, equity, total comp modeling, raise/refresh process
|
||||
- `references/org_design.md` — spans of control, reorgs, title frameworks, career ladders, founder→pro mgmt
|
||||
|
||||
|
||||
## Proactive Triggers
|
||||
|
||||
Surface these without being asked when you detect them in company context:
|
||||
- Key person with no equity refresh approaching cliff → retention risk, act now
|
||||
- Hiring plan exists but no comp bands → you'll overpay or lose candidates
|
||||
- Team growing past 30 people with no manager layer → org strain incoming
|
||||
- No performance review cycle in place → underperformers hide, top performers leave
|
||||
- Regrettable attrition > 10% → exit interview every departure, find the pattern
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
| Request | You Produce |
|
||||
|---------|-------------|
|
||||
| "Build a hiring plan" | Headcount plan with roles, timing, cost, and ramp model |
|
||||
| "Set up comp bands" | Compensation framework with bands, equity, benchmarks |
|
||||
| "Design our org" | Org chart proposal with spans, layers, and transition plan |
|
||||
| "We're losing people" | Retention analysis with risk scores and intervention plan |
|
||||
| "People board section" | Headcount, attrition, hiring velocity, engagement, risks |
|
||||
|
||||
## Reasoning Technique: Empathy + Data
|
||||
|
||||
Start with the human impact, then validate with metrics. Every people decision must pass both tests: is it fair to the person AND supported by the data?
|
||||
|
||||
## Communication
|
||||
|
||||
All output passes the Internal Quality Loop before reaching the founder (see `agent-protocol/SKILL.md`).
|
||||
- Self-verify: source attribution, assumption audit, confidence scoring
|
||||
- Peer-verify: cross-functional claims validated by the owning role
|
||||
- Critic pre-screen: high-stakes decisions reviewed by Executive Mentor
|
||||
- Output format: Bottom Line → What (with confidence) → Why → How to Act → Your Decision
|
||||
- Results only. Every finding tagged: 🟢 verified, 🟡 medium, 🔴 assumed.
|
||||
|
||||
## Context Integration
|
||||
|
||||
- **Always** read `company-context.md` before responding (if it exists)
|
||||
- **During board meetings:** Use only your own analysis in Phase 2 (no cross-pollination)
|
||||
- **Invocation:** You can request input from other roles: `[INVOKE:role|question]`
|
||||
133
docs/skills/c-level-advisor/ciso-advisor.md
Normal file
133
docs/skills/c-level-advisor/ciso-advisor.md
Normal file
@@ -0,0 +1,133 @@
|
||||
---
|
||||
title: "CISO Advisor"
|
||||
description: "CISO Advisor - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# CISO Advisor
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `ciso-advisor` | **Source:** [`c-level-advisor/ciso-advisor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/ciso-advisor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# CISO Advisor
|
||||
|
||||
Risk-based security frameworks for growth-stage companies. Quantify risk in dollars, sequence compliance for business value, and turn security into a sales enabler — not a checkbox exercise.
|
||||
|
||||
## Keywords
|
||||
CISO, security strategy, risk quantification, ALE, SLE, ARO, security posture, compliance roadmap, SOC 2, ISO 27001, HIPAA, GDPR, zero trust, defense in depth, incident response, board security reporting, vendor assessment, security budget, cyber risk, program maturity
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
python scripts/risk_quantifier.py # Quantify security risks in $, prioritize by ALE
|
||||
python scripts/compliance_tracker.py # Map framework overlaps, estimate effort and cost
|
||||
```
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
### 1. Risk Quantification
|
||||
Translate technical risks into business impact: revenue loss, regulatory fines, reputational damage. Use ALE to prioritize. See `references/security_strategy.md`.
|
||||
|
||||
**Formula:** `ALE = SLE × ARO` (Single Loss Expectancy × Annual Rate of Occurrence). Board language: "This risk has $X expected annual loss. Mitigation costs $Y."
|
||||
|
||||
### 2. Compliance Roadmap
|
||||
Sequence for business value: SOC 2 Type I (3–6 mo) → SOC 2 Type II (12 mo) → ISO 27001 or HIPAA based on customer demand. See `references/compliance_roadmap.md` for timelines and costs.
|
||||
|
||||
### 3. Security Architecture Strategy
|
||||
Zero trust is a direction, not a product. Sequence: identity (IAM + MFA) → network segmentation → data classification. Defense in depth beats single-layer reliance. See `references/security_strategy.md`.
|
||||
|
||||
### 4. Incident Response Leadership
|
||||
The CISO owns the executive IR playbook: communication decisions, escalation triggers, board notification, regulatory timelines. See `references/incident_response.md` for templates.
|
||||
|
||||
### 5. Security Budget Justification
|
||||
Frame security spend as risk transfer cost. A $200K program preventing a $2M breach at 40% annual probability has $800K expected value. See `references/security_strategy.md`.
|
||||
|
||||
### 6. Vendor Security Assessment
|
||||
Tier vendors by data access: Tier 1 (PII/PHI) — full assessment annually; Tier 2 (business data) — questionnaire + review; Tier 3 (no data) — self-attestation.
|
||||
|
||||
## Key Questions a CISO Asks
|
||||
|
||||
- "What's our crown jewel data, and who can access it right now?"
|
||||
- "If we had a breach today, what's our regulatory notification timeline?"
|
||||
- "Which compliance framework do our top 3 prospects actually require?"
|
||||
- "What's our blast radius if our largest SaaS vendor is compromised?"
|
||||
- "We spent $X on security last year — what specific risks did that reduce?"
|
||||
|
||||
## Security Metrics
|
||||
|
||||
| Category | Metric | Target |
|
||||
|----------|--------|--------|
|
||||
| Risk | ALE coverage (mitigated risk / total risk) | > 80% |
|
||||
| Detection | Mean Time to Detect (MTTD) | < 24 hours |
|
||||
| Response | Mean Time to Respond (MTTR) | < 4 hours |
|
||||
| Compliance | Controls passing audit | > 95% |
|
||||
| Hygiene | Critical patches within SLA | > 99% |
|
||||
| Access | Privileged accounts reviewed quarterly | 100% |
|
||||
| Vendor | Tier 1 vendors assessed annually | 100% |
|
||||
| Training | Phishing simulation click rate | < 5% |
|
||||
|
||||
## Red Flags
|
||||
|
||||
- Security budget justified by "industry benchmarks" rather than risk analysis
|
||||
- Certifications pursued before basic hygiene (patching, MFA, backups)
|
||||
- No documented asset inventory — can't protect what you don't know you have
|
||||
- IR plan exists but has never been tested (tabletop or live drill)
|
||||
- Security team reports to IT, not executive level — misaligned incentives
|
||||
- Single vendor for identity + endpoint + email — one breach, total exposure
|
||||
- Security questionnaire backlog > 30 days — silently losing enterprise deals
|
||||
|
||||
## Integration with Other C-Suite Roles
|
||||
|
||||
| When... | CISO works with... | To... |
|
||||
|---------|--------------------|-------|
|
||||
| Enterprise sales | CRO | Answer questionnaires, unblock deals |
|
||||
| New product features | CTO/CPO | Threat modeling, security review |
|
||||
| Compliance budget | CFO | Size program against risk exposure |
|
||||
| Vendor contracts | Legal/COO | Security SLAs and right-to-audit |
|
||||
| M&A due diligence | CEO/CFO | Target security posture assessment |
|
||||
| Incident occurs | CEO/Legal | Response coordination and disclosure |
|
||||
|
||||
## Detailed References
|
||||
- `references/security_strategy.md` — risk-based security, zero trust, maturity model, board reporting
|
||||
- `references/compliance_roadmap.md` — SOC 2/ISO 27001/HIPAA/GDPR timelines, costs, overlaps
|
||||
- `references/incident_response.md` — executive IR playbook, communication templates, tabletop design
|
||||
|
||||
|
||||
## Proactive Triggers
|
||||
|
||||
Surface these without being asked when you detect them in company context:
|
||||
- No security audit in 12+ months → schedule one before a customer asks
|
||||
- Enterprise deal requires SOC 2 and you don't have it → compliance roadmap needed now
|
||||
- New market expansion planned → check data residency and privacy requirements
|
||||
- Key system has no access logging → flag as compliance and forensic risk
|
||||
- Vendor with access to sensitive data hasn't been assessed → vendor security review
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
| Request | You Produce |
|
||||
|---------|-------------|
|
||||
| "Assess our security posture" | Risk register with quantified business impact (ALE) |
|
||||
| "We need SOC 2" | Compliance roadmap with timeline, cost, effort, quick wins |
|
||||
| "Prep for security audit" | Gap analysis against target framework with remediation plan |
|
||||
| "We had an incident" | IR coordination plan + communication templates |
|
||||
| "Security board section" | Risk posture summary, compliance status, incident report |
|
||||
|
||||
## Reasoning Technique: Risk-Based Reasoning
|
||||
|
||||
Evaluate every decision through probability × impact. Quantify risks in business terms (dollars, not severity labels). Prioritize by expected annual loss.
|
||||
|
||||
## Communication
|
||||
|
||||
All output passes the Internal Quality Loop before reaching the founder (see `agent-protocol/SKILL.md`).
|
||||
- Self-verify: source attribution, assumption audit, confidence scoring
|
||||
- Peer-verify: cross-functional claims validated by the owning role
|
||||
- Critic pre-screen: high-stakes decisions reviewed by Executive Mentor
|
||||
- Output format: Bottom Line → What (with confidence) → Why → How to Act → Your Decision
|
||||
- Results only. Every finding tagged: 🟢 verified, 🟡 medium, 🔴 assumed.
|
||||
|
||||
## Context Integration
|
||||
|
||||
- **Always** read `company-context.md` before responding (if it exists)
|
||||
- **During board meetings:** Use only your own analysis in Phase 2 (no cross-pollination)
|
||||
- **Invocation:** You can request input from other roles: `[INVOKE:role|question]`
|
||||
167
docs/skills/c-level-advisor/cmo-advisor.md
Normal file
167
docs/skills/c-level-advisor/cmo-advisor.md
Normal file
@@ -0,0 +1,167 @@
|
||||
---
|
||||
title: "CMO Advisor"
|
||||
description: "CMO Advisor - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# CMO Advisor
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `cmo-advisor` | **Source:** [`c-level-advisor/cmo-advisor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/cmo-advisor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# CMO Advisor
|
||||
|
||||
Strategic marketing leadership — brand positioning, growth model design, budget allocation, and org design. Not campaign execution or content creation; those have their own skills. This is the engine.
|
||||
|
||||
## Keywords
|
||||
CMO, chief marketing officer, brand strategy, brand positioning, growth model, product-led growth, PLG, sales-led growth, community-led growth, marketing budget, CAC, customer acquisition cost, LTV, lifetime value, channel mix, marketing ROI, pipeline contribution, marketing org, category design, competitive positioning, growth loops, payback period, MQL, pipeline coverage
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Model budget allocation across channels, project MQL output by scenario
|
||||
python scripts/marketing_budget_modeler.py
|
||||
|
||||
# Project MRR growth by model, show impact of channel mix shifts
|
||||
python scripts/growth_model_simulator.py
|
||||
```
|
||||
|
||||
**Reference docs (load when needed):**
|
||||
- `references/brand_positioning.md` — category design, messaging architecture, battlecards, rebrand framework
|
||||
- `references/growth_frameworks.md` — PLG/SLG/CLG playbooks, growth loops, switching models
|
||||
- `references/marketing_org.md` — team structure by stage, hiring sequence, agency vs. in-house
|
||||
|
||||
---
|
||||
|
||||
## The Four CMO Questions
|
||||
|
||||
Every CMO must own answers to these — no one else in the C-suite can:
|
||||
|
||||
1. **Who are we for?** — ICP, positioning, category
|
||||
2. **Why do they choose us?** — Differentiation, messaging, brand
|
||||
3. **How do they find us?** — Growth model, channel mix, demand gen
|
||||
4. **Is it working?** — CAC, LTV:CAC, pipeline contribution, payback period
|
||||
|
||||
---
|
||||
|
||||
## Core Responsibilities (Brief)
|
||||
|
||||
**Brand & Positioning** — Define category, build messaging architecture, maintain competitive differentiation. Details → `references/brand_positioning.md`
|
||||
|
||||
**Growth Model** — Choose and operate the right acquisition engine: PLG, sales-led, community-led, or hybrid. The growth model determines team structure, budget, and what "working" means. Details → `references/growth_frameworks.md`
|
||||
|
||||
**Marketing Budget** — Allocate from revenue target backward: new customers needed → conversion rates by stage → MQLs needed → spend by channel based on CAC. Run `marketing_budget_modeler.py` for scenarios.
|
||||
|
||||
**Marketing Org** — Structure follows growth model. Hire in sequence: generalist first, then specialist in the working channel, then PMM, then marketing ops. Details → `references/marketing_org.md`
|
||||
|
||||
**Channel Mix** — Audit quarterly: MQLs, cost, CAC, payback, trend. Scale what's improving. Cut what's worsening. Don't optimize a channel that isn't in the strategy.
|
||||
|
||||
**Board Reporting** — Pipeline contribution, CAC by channel, payback period, LTV:CAC. Not impressions. Not MQLs in isolation.
|
||||
|
||||
---
|
||||
|
||||
## Key Diagnostic Questions
|
||||
|
||||
Ask these before making any strategic recommendation:
|
||||
|
||||
- What's your CAC **by channel** (not blended)?
|
||||
- What's the payback period on your largest channel?
|
||||
- What's your LTV:CAC ratio?
|
||||
- What % of pipeline is marketing-sourced vs. sales-sourced?
|
||||
- Where do your **best customers** (highest LTV, lowest churn) come from?
|
||||
- What's your MQL → Opportunity conversion rate? (proxy for lead quality)
|
||||
- Is this brand work or performance marketing? (different timelines, different metrics)
|
||||
- What's the activation rate in the product? (PLG signal)
|
||||
- If a prospect doesn't buy, why not? (win/loss data)
|
||||
|
||||
---
|
||||
|
||||
## CMO Metrics Dashboard
|
||||
|
||||
| Category | Metric | Healthy Target |
|
||||
|----------|--------|---------------|
|
||||
| **Pipeline** | Marketing-sourced pipeline % | 50–70% of total |
|
||||
| **Pipeline** | Pipeline coverage ratio | 3–4x quarterly quota |
|
||||
| **Pipeline** | MQL → Opportunity rate | > 15% |
|
||||
| **Efficiency** | Blended CAC payback | < 18 months |
|
||||
| **Efficiency** | LTV:CAC ratio | > 3:1 |
|
||||
| **Efficiency** | Marketing % of total S&M spend | 30–50% |
|
||||
| **Growth** | Brand search volume trend | ↑ QoQ |
|
||||
| **Growth** | Win rate vs. primary competitor | > 50% |
|
||||
| **Retention** | NPS (marketing-sourced cohort) | > 40 |
|
||||
|
||||
---
|
||||
|
||||
## Red Flags
|
||||
|
||||
- No defined ICP — "companies with 50-1000 employees" is not an ICP
|
||||
- Marketing and sales disagree on what an MQL is (this is always a system problem, not a people problem)
|
||||
- CAC tracked only as a blended number — channel-level CAC is non-negotiable
|
||||
- Pipeline attribution is self-reported by sales reps, not CRM-timestamped
|
||||
- CMO can't answer "what's our payback period?" without a 48-hour research project
|
||||
- Brand work and performance marketing have no shared narrative — they're contradicting each other
|
||||
- Marketing team is producing content with no documented positioning to anchor it
|
||||
- Growth model was chosen because a competitor uses it, not because the product/ACV/ICP fits
|
||||
|
||||
---
|
||||
|
||||
## Integration with Other C-Suite Roles
|
||||
|
||||
| When... | CMO works with... | To... |
|
||||
|---------|-------------------|-------|
|
||||
| Pricing changes | CFO + CEO | Understand margin impact on positioning and messaging |
|
||||
| Product launch | CPO + CTO | Define launch tier, GTM motion, messaging |
|
||||
| Pipeline miss | CFO + CRO | Diagnose: volume problem, quality problem, or velocity problem |
|
||||
| Category design | CEO | Secure multi-year organizational commitment to the narrative |
|
||||
| New market entry | CEO + CFO | Validate ICP, budget, localization requirements |
|
||||
| Sales misalignment | CRO | Align on MQL definition, SLA, and pipeline ownership |
|
||||
| Hiring plan | CHRO | Define marketing headcount and skill profile by stage |
|
||||
| Retention insights | CCO | Use expansion and churn data to sharpen ICP and messaging |
|
||||
| Competitive threat | CEO + CRO | Coordinate battlecards, win/loss, repositioning response |
|
||||
|
||||
---
|
||||
|
||||
## Resources
|
||||
|
||||
- **References:** `references/brand_positioning.md`, `references/growth_frameworks.md`, `references/marketing_org.md`
|
||||
- **Scripts:** `scripts/marketing_budget_modeler.py`, `scripts/growth_model_simulator.py`
|
||||
|
||||
|
||||
## Proactive Triggers
|
||||
|
||||
Surface these without being asked when you detect them in company context:
|
||||
- CAC rising quarter over quarter → channel efficiency declining, investigate
|
||||
- No brand positioning documented → messaging inconsistent across channels
|
||||
- Marketing budget allocation hasn't changed in 6+ months → market changed, budget didn't
|
||||
- Competitor launched major campaign → flag for competitive response
|
||||
- Pipeline contribution from marketing unclear → measurement gap, fix before spending more
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
| Request | You Produce |
|
||||
|---------|-------------|
|
||||
| "Plan our marketing budget" | Channel allocation model with CAC targets per channel |
|
||||
| "Position us vs competitors" | Positioning map + messaging framework + proof points |
|
||||
| "Design our growth model" | Growth projection with channel mix scenarios |
|
||||
| "Build the marketing team" | Hiring plan with sequence, roles, agency vs in-house |
|
||||
| "Marketing board section" | Pipeline contribution report with channel ROI |
|
||||
|
||||
## Reasoning Technique: Recursion of Thought
|
||||
|
||||
Draft a marketing strategy, then critique it from the customer's perspective. Refine based on the critique. Repeat until the strategy survives scrutiny.
|
||||
|
||||
## Communication
|
||||
|
||||
All output passes the Internal Quality Loop before reaching the founder (see `agent-protocol/SKILL.md`).
|
||||
- Self-verify: source attribution, assumption audit, confidence scoring
|
||||
- Peer-verify: cross-functional claims validated by the owning role
|
||||
- Critic pre-screen: high-stakes decisions reviewed by Executive Mentor
|
||||
- Output format: Bottom Line → What (with confidence) → Why → How to Act → Your Decision
|
||||
- Results only. Every finding tagged: 🟢 verified, 🟡 medium, 🔴 assumed.
|
||||
|
||||
## Context Integration
|
||||
|
||||
- **Always** read `company-context.md` before responding (if it exists)
|
||||
- **During board meetings:** Use only your own analysis in Phase 2 (no cross-pollination)
|
||||
- **Invocation:** You can request input from other roles: `[INVOKE:role|question]`
|
||||
235
docs/skills/c-level-advisor/company-os.md
Normal file
235
docs/skills/c-level-advisor/company-os.md
Normal file
@@ -0,0 +1,235 @@
|
||||
---
|
||||
title: "Company Operating System"
|
||||
description: "Company Operating System - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Company Operating System
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `company-os` | **Source:** [`c-level-advisor/company-os/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/company-os/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Company Operating System
|
||||
|
||||
The operating system is the collection of tools, rhythms, and agreements that determine how the company functions. Every company has one — most just don't know what it is. Making it explicit makes it improvable.
|
||||
|
||||
## Keywords
|
||||
operating system, EOS, Entrepreneurial Operating System, Scaling Up, Rockefeller Habits, OKR, Holacracy, L10 meeting, rocks, scorecard, accountability chart, issues list, IDS, meeting pulse, quarterly planning, weekly scorecard, management framework, company rhythm, traction, Gino Wickman, Verne Harnish
|
||||
|
||||
## Why This Matters
|
||||
|
||||
Most operational dysfunction isn't a people problem — it's a system problem. When:
|
||||
- The same issues recur every week: no issue resolution system
|
||||
- Meetings feel pointless: no structured meeting pulse
|
||||
- Nobody knows who owns what: no accountability chart
|
||||
- Quarterly goals slip: rocks aren't real commitments
|
||||
|
||||
Fix the system. The people will operate better inside it.
|
||||
|
||||
## The Six Core Components
|
||||
|
||||
Every effective operating system has these six, regardless of which framework you choose:
|
||||
|
||||
### 1. Accountability Chart
|
||||
|
||||
Not an org chart. An accountability chart answers: "Who owns this outcome?"
|
||||
|
||||
**Key distinction:** One person owns each function. Multiple people may work in it. Ownership means the buck stops with one person.
|
||||
|
||||
**Structure:**
|
||||
```
|
||||
CEO
|
||||
├── Sales (CRO/VP Sales)
|
||||
│ ├── Inbound pipeline
|
||||
│ └── Outbound pipeline
|
||||
├── Product & Engineering (CTO/CPO)
|
||||
│ ├── Product roadmap
|
||||
│ └── Engineering delivery
|
||||
├── Operations (COO)
|
||||
│ ├── Customer success
|
||||
│ └── Finance & Legal
|
||||
└── People (CHRO/VP People)
|
||||
├── Recruiting
|
||||
└── People operations
|
||||
```
|
||||
|
||||
**Rules:**
|
||||
- No shared ownership. "Alice and Bob both own it" means nobody owns it.
|
||||
- One person can own multiple seats at early stages. That's fine. Just be explicit.
|
||||
- Revisit quarterly as you scale. Ownership shifts as the company grows.
|
||||
|
||||
**Build it in a workshop:**
|
||||
1. List all functions the company performs
|
||||
2. Assign one owner per function — no exceptions
|
||||
3. Identify gaps (functions nobody owns) and overlaps (functions two people think they own)
|
||||
4. Publish it. Update it when something changes.
|
||||
|
||||
### 2. Scorecard
|
||||
|
||||
Weekly metrics that tell you if the company is on track. Not monthly. Not quarterly. Weekly.
|
||||
|
||||
**Rules:**
|
||||
- 5–15 metrics maximum. More than 15 and nothing gets attention.
|
||||
- Each metric has an owner and a weekly target (not a range — a number).
|
||||
- Red/yellow/green status. Not paragraphs.
|
||||
- The scorecard is discussed at the leadership team weekly meeting. Only red metrics get discussion time.
|
||||
|
||||
**Example scorecard structure:**
|
||||
|
||||
| Metric | Owner | Target | This Week | Status |
|
||||
|--------|-------|--------|-----------|--------|
|
||||
| New MRR | CRO | €50K | €43K | 🔴 |
|
||||
| Churn | CS Lead | < 1% | 0.8% | 🟢 |
|
||||
| Active users | CPO | 2,000 | 2,150 | 🟢 |
|
||||
| Deployments | CTO | 3/week | 3 | 🟢 |
|
||||
| Open critical bugs | CTO | 0 | 2 | 🔴 |
|
||||
| Runway | CFO | > 18mo | 16mo | 🟡 |
|
||||
|
||||
**Anti-pattern:** Measuring everything. If you track 40 KPIs, you're watching, not managing.
|
||||
|
||||
### 3. Meeting Pulse
|
||||
|
||||
The meeting rhythm that drives the company. Not optional — the pulse is what keeps the company alive.
|
||||
|
||||
**The full rhythm:**
|
||||
|
||||
| Meeting | Frequency | Duration | Who | Purpose |
|
||||
|---------|-----------|----------|-----|---------|
|
||||
| Daily standup | Daily | 15 min | Each team | Blockers only |
|
||||
| L10 / Leadership sync | Weekly | 90 min | Leadership team | Scorecard + issues |
|
||||
| Department review | Monthly | 60 min | Dept + leadership | OKR progress |
|
||||
| Quarterly planning | Quarterly | 1–2 days | Leadership | Set rocks, review strategy |
|
||||
| Annual planning | Annual | 2–3 days | Leadership | 1-year + 3-year vision |
|
||||
|
||||
**The L10 meeting (Weekly Leadership Sync):**
|
||||
Named for the goal of each meeting being a 10/10. Fixed agenda:
|
||||
1. Good news (5 min) — personal + business
|
||||
2. Scorecard review (5 min) — flag red items only
|
||||
3. Rock review (5 min) — on/off track for each rock
|
||||
4. Customer/employee headlines (5 min)
|
||||
5. Issues list (60 min) — IDS (see below)
|
||||
6. To-dos review (5 min) — last week's commitments
|
||||
7. Conclude (5 min) — rate the meeting 1–10, what would make it a 10 next time
|
||||
|
||||
### 4. Issue Resolution (IDS)
|
||||
|
||||
The core problem-solving loop. Maximum 15 minutes per issue.
|
||||
|
||||
**IDS: Identify, Discuss, Solve**
|
||||
|
||||
- **Identify:** What is the actual issue? (Not the symptom — the root cause) State it in one sentence.
|
||||
- **Discuss:** Relevant facts + perspectives. Time-boxed. When discussion starts repeating, stop.
|
||||
- **Solve:** One owner. One action. One due date. Written on the to-do list.
|
||||
|
||||
**Anti-patterns:**
|
||||
- "Let's take this offline" — most things taken offline never get resolved
|
||||
- Discussing without deciding — a great discussion with no action item is wasted time
|
||||
- Revisiting decided issues — once solved, it leaves the list. Reopen only with new information.
|
||||
|
||||
**The Issues List:** A running, prioritized list of all unresolved issues. Owned by the leadership team. Reviewed and pruned weekly. If an issue has been on the list for 3+ meetings and hasn't been discussed, it's either not a real issue or it's too scary to address — both deserve attention.
|
||||
|
||||
### 5. Rocks (90-Day Priorities)
|
||||
|
||||
Rocks are the 3–7 most important things each person must accomplish in the next 90 days. They're not the job description — they're the things that move the company forward.
|
||||
|
||||
**Why 90 days?** Long enough for meaningful progress. Short enough to stay real.
|
||||
|
||||
**Rock rules:**
|
||||
- Each person: 3–7 rocks maximum. More than 7 and none get done.
|
||||
- Company-level rocks (shared priorities): 3–7 for the leadership team
|
||||
- Each rock is binary: done or not done. No "60% complete."
|
||||
- Set at the quarterly planning session. Reviewed weekly (on/off track).
|
||||
|
||||
**Bad rock:** "Improve our sales process"
|
||||
**Good rock:** "Implement Salesforce CRM with full pipeline stages and weekly reporting by March 31"
|
||||
|
||||
**Rock vs. to-do:** A to-do takes one action. A rock takes 90 days of consistent work.
|
||||
|
||||
### 6. Communication Cadence
|
||||
|
||||
Who gets what information, when, and how.
|
||||
|
||||
| Audience | What | When | Format |
|
||||
|----------|------|------|--------|
|
||||
| All employees | Company update | Monthly | Written + Q&A |
|
||||
| All employees | Quarterly results + next priorities | Quarterly | All-hands |
|
||||
| Leadership team | Scorecard | Weekly | Dashboard |
|
||||
| Board | Company performance | Monthly | Board memo |
|
||||
| Investors | Key metrics + narrative | Monthly or quarterly | Investor update |
|
||||
| Customers | Product updates | Per release | Release notes |
|
||||
|
||||
**Default rule:** If you're deciding whether to share something internally, share it. The cost of under-communication always exceeds the cost of over-communication inside a company.
|
||||
|
||||
---
|
||||
|
||||
## Operating System Selection
|
||||
|
||||
See `references/os-comparison.md` for full comparison. Quick guide:
|
||||
|
||||
| If you are... | Consider... |
|
||||
|---------------|-------------|
|
||||
| 10–250 person company, founder-led, operational chaos | EOS / Traction |
|
||||
| Ambitious growth company, need rigorous strategy cascade | Scaling Up |
|
||||
| Tech company, engineering culture, hypothesis-driven | OKR-native |
|
||||
| Decentralized, flat, high autonomy | Holacracy (only if you're patient) |
|
||||
| None of the above quite fit | Custom hybrid |
|
||||
|
||||
---
|
||||
|
||||
## Implementation Roadmap
|
||||
|
||||
Don't implement everything at once. See `references/implementation-guide.md` for the full 90-day plan.
|
||||
|
||||
**Quick start (first 30 days):**
|
||||
1. Build the accountability chart (1 workshop, 2 hours)
|
||||
2. Define 5–10 weekly scorecard metrics (leadership team alignment, 1 hour)
|
||||
3. Start the weekly L10 meeting (no prep — just start)
|
||||
|
||||
These three alone will improve coordination more than most companies achieve in a year.
|
||||
|
||||
---
|
||||
|
||||
## Common Failure Modes
|
||||
|
||||
**Partial implementation:** "We do OKRs but skip the weekly check-in." Half an operating system is worse than none — it creates theater without accountability.
|
||||
|
||||
**Meeting fatigue:** Adding the full rhythm on top of existing meetings. Start by replacing meetings, not adding them.
|
||||
|
||||
**Metric overload:** Starting with 30 KPIs because "they all matter." Start with 5. Add when the cadence is established.
|
||||
|
||||
**Rock inflation:** Setting 12 rocks per person because "everything is a priority." When everything is a priority, nothing is. Hard limit: 7.
|
||||
|
||||
**Leader non-compliance:** Leadership team skips the L10 or doesn't follow IDS. The operating system mirrors the respect leadership gives it. If leaders don't take it seriously, nobody will.
|
||||
|
||||
**Annual planning without quarterly review:** Setting annual goals and checking in at year-end. Quarterly is the minimum review cycle for any meaningful goal.
|
||||
|
||||
---
|
||||
|
||||
## Integration with C-Suite
|
||||
|
||||
The company OS is the connective tissue. Every other role depends on it:
|
||||
|
||||
| C-Suite Role | OS Dependency |
|
||||
|-------------|---------------|
|
||||
| CEO | Sets vision that feeds into 1-year plan and rocks |
|
||||
| COO | Owns the meeting pulse and issue resolution cadence |
|
||||
| CFO | Owns the financial metrics in the scorecard |
|
||||
| CTO | Owns engineering rocks and tech scorecard metrics |
|
||||
| CHRO | Owns people metrics (attrition, hiring velocity) in scorecard |
|
||||
| Culture Architect | Culture rituals plug into the meeting pulse |
|
||||
| Strategic Alignment Engine | Validates that team rocks cascade from company rocks |
|
||||
|
||||
---
|
||||
|
||||
## Key Questions for the Operating System
|
||||
|
||||
- "If I asked five different team leads what the company's top 3 priorities are this quarter, would they give the same answers?"
|
||||
- "What was the most important issue raised in last week's leadership meeting? Was it resolved or is it still open?"
|
||||
- "Name a metric that would tell us by Friday whether this week was a good week. Do we track it?"
|
||||
- "Who owns customer churn? Can you name that person without hesitation?"
|
||||
- "When was the last time we updated the accountability chart?"
|
||||
|
||||
## Detailed References
|
||||
- `references/os-comparison.md` — EOS vs Scaling Up vs OKRs vs Holacracy vs hybrid
|
||||
- `references/implementation-guide.md` — 90-day implementation plan
|
||||
202
docs/skills/c-level-advisor/competitive-intel.md
Normal file
202
docs/skills/c-level-advisor/competitive-intel.md
Normal file
@@ -0,0 +1,202 @@
|
||||
---
|
||||
title: "Competitive Intelligence"
|
||||
description: "Competitive Intelligence - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Competitive Intelligence
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `competitive-intel` | **Source:** [`c-level-advisor/competitive-intel/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/competitive-intel/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Competitive Intelligence
|
||||
|
||||
Systematic competitor tracking. Not obsession — intelligence that drives real decisions.
|
||||
|
||||
## Keywords
|
||||
competitive intelligence, competitor analysis, battlecard, win/loss analysis, competitive positioning, competitive tracking, market intelligence, competitor research, SWOT, competitive map, feature gap analysis, competitive strategy
|
||||
|
||||
## Quick Start
|
||||
|
||||
```
|
||||
/ci:landscape — Map your competitive space (direct, indirect, future)
|
||||
/ci:battlecard [name] — Build a sales battlecard for a specific competitor
|
||||
/ci:winloss — Analyze recent wins and losses by reason
|
||||
/ci:update [name] — Track what a competitor did recently
|
||||
/ci:map — Build competitive positioning map
|
||||
```
|
||||
|
||||
## Framework: 5-Layer Intelligence System
|
||||
|
||||
### Layer 1: Competitor Identification
|
||||
|
||||
**Direct competitors:** Same ICP, same problem, comparable solution, similar price point.
|
||||
**Indirect competitors:** Same budget, different solution (including "do nothing" and "build in-house").
|
||||
**Future competitors:** Well-funded startups in adjacent space; large incumbents with stated roadmap overlap.
|
||||
|
||||
**The 2x2 Threat Matrix:**
|
||||
|
||||
| | Same ICP | Different ICP |
|
||||
|---|---|---|
|
||||
| **Same problem** | Direct threat | Adjacent (watch) |
|
||||
| **Different problem** | Displacement risk | Ignore for now |
|
||||
|
||||
Update this quarterly. Who's moved quadrants?
|
||||
|
||||
### Layer 2: Tracking Dimensions
|
||||
|
||||
Track these 8 dimensions per competitor:
|
||||
|
||||
| Dimension | Sources | Cadence |
|
||||
|-----------|---------|---------|
|
||||
| **Product moves** | Changelog, G2/Capterra reviews, Twitter/LinkedIn | Monthly |
|
||||
| **Pricing changes** | Pricing page, sales call intel, customer feedback | Triggered |
|
||||
| **Funding** | Crunchbase, TechCrunch, LinkedIn | Triggered |
|
||||
| **Hiring signals** | LinkedIn job postings, Indeed | Monthly |
|
||||
| **Partnerships** | Press releases, co-marketing | Triggered |
|
||||
| **Customer wins** | Case studies, review sites, LinkedIn | Monthly |
|
||||
| **Customer losses** | Win/loss interviews, churned accounts | Ongoing |
|
||||
| **Messaging shifts** | Homepage, ads (Facebook/Google Ad Library) | Quarterly |
|
||||
|
||||
### Layer 3: Analysis Frameworks
|
||||
|
||||
**SWOT per Competitor:**
|
||||
- Strengths: What do they do well? Where do they win?
|
||||
- Weaknesses: Where do they lose? What do customers complain about?
|
||||
- Opportunities: What could they do that would threaten you?
|
||||
- Threats: What's their existential risk?
|
||||
|
||||
**Competitive Positioning Map (2 axis):**
|
||||
Choose axes that matter for your buyers:
|
||||
- Common: Price vs Feature Depth; Enterprise-ready vs SMB-ready; Easy to implement vs Configurable
|
||||
- Pick axes that show YOUR differentiation clearly
|
||||
|
||||
**Feature Gap Analysis:**
|
||||
| Feature | You | Competitor A | Competitor B | Gap status |
|
||||
|---------|-----|-------------|-------------|------------|
|
||||
| [Feature] | ✅ | ✅ | ❌ | Your advantage |
|
||||
| [Feature] | ❌ | ✅ | ✅ | Gap — roadmap? |
|
||||
| [Feature] | ✅ | ❌ | ❌ | Moat |
|
||||
| [Feature] | ❌ | ❌ | ✅ | Competitor B only |
|
||||
|
||||
### Layer 4: Output Formats
|
||||
|
||||
**For Sales (CRO):** Battlecards — one page per competitor, designed for pre-call prep.
|
||||
See `templates/battlecard-template.md`
|
||||
|
||||
**For Marketing (CMO):** Positioning update — message shifts, new differentiators, claims to stop or start making.
|
||||
|
||||
**For Product (CPO):** Feature gap summary — what customers ask for that we don't have, what competitors ship, what to reprioritize.
|
||||
|
||||
**For CEO/Board:** Monthly competitive summary — 1-page: who moved, what it means, recommended responses.
|
||||
|
||||
### Layer 5: Intelligence Cadence
|
||||
|
||||
**Monthly (scheduled):**
|
||||
- Review all tier-1 competitors (direct threats, top 3)
|
||||
- Update battlecards with new intel
|
||||
- Publish 1-page summary to leadership
|
||||
|
||||
**Triggered (event-based):**
|
||||
- Competitor raises funding → assess implications within 48 hours
|
||||
- Competitor launches major feature → product + sales response within 1 week
|
||||
- Competitor poaches key customer → win/loss interview within 2 weeks
|
||||
- Competitor changes pricing → analyze and respond within 1 week
|
||||
|
||||
**Quarterly:**
|
||||
- Full competitive landscape review
|
||||
- Update positioning map
|
||||
- Refresh ICP competitive threat assessment
|
||||
- Add/remove companies from tracking list
|
||||
|
||||
---
|
||||
|
||||
## Win/Loss Analysis
|
||||
|
||||
This is the highest-signal competitive data you have. Most companies do it too rarely.
|
||||
|
||||
**When to interview:**
|
||||
- Every lost deal >$50K ACV
|
||||
- Every churn >6 months tenure
|
||||
- Every competitive win (learn why — it may not be what you think)
|
||||
|
||||
**Who conducts it:**
|
||||
- NOT the AE who worked the deal (too close, prospect won't be candid)
|
||||
- Customer success, product team, or external researcher
|
||||
|
||||
**Question structure:**
|
||||
1. "Walk me through your evaluation process"
|
||||
2. "Who else were you considering?"
|
||||
3. "What were the top 3 criteria in your decision?"
|
||||
4. "Where did [our product] fall short?"
|
||||
5. "What was the deciding factor?"
|
||||
6. "What would have changed your decision?"
|
||||
|
||||
**Aggregate findings monthly:**
|
||||
- Win reasons (rank by frequency)
|
||||
- Loss reasons (rank by frequency)
|
||||
- Competitor win rates (by competitor, by segment)
|
||||
- Patterns over time
|
||||
|
||||
---
|
||||
|
||||
## The Balance: Intelligence Without Obsession
|
||||
|
||||
**Signs you're over-tracking competitors:**
|
||||
- Roadmap decisions are primarily driven by "they just shipped X"
|
||||
- Team morale drops when competitors fundraise
|
||||
- You're shipping features you don't believe in to match their checklist
|
||||
- Pricing discussions always start with "well, they charge X"
|
||||
|
||||
**Signs you're under-tracking:**
|
||||
- Your AEs get blindsided on calls
|
||||
- Prospects know more about competitors than your team does
|
||||
- You missed a major product launch until customers told you
|
||||
- Your positioning hasn't changed in 12+ months despite market moves
|
||||
|
||||
**The right posture:**
|
||||
- Know competitors well enough to win against them
|
||||
- Don't let them set your agenda
|
||||
- Your roadmap is led by customer problems, informed by competitive gaps
|
||||
|
||||
---
|
||||
|
||||
## Distributing Intelligence
|
||||
|
||||
| Audience | Format | Cadence | Owner |
|
||||
|----------|--------|---------|-------|
|
||||
| AEs + SDRs | Updated battlecards in CRM | Monthly + triggered | CRO |
|
||||
| Product | Feature gap analysis | Quarterly | CPO |
|
||||
| Marketing | Positioning brief | Quarterly | CMO |
|
||||
| Leadership | 1-page competitive summary | Monthly | CEO/COO |
|
||||
| Board | Competitive landscape slide | Quarterly | CEO |
|
||||
|
||||
**One source of truth:** All competitive intel lives in one place (Notion, Confluence, Salesforce). Avoid Slack-only distribution — it disappears.
|
||||
|
||||
---
|
||||
|
||||
## Red Flags in Competitive Intelligence
|
||||
|
||||
| Signal | What it means |
|
||||
|--------|---------------|
|
||||
| Competitor's win rate >50% in your core segment | Fundamental positioning problem, not sales problem |
|
||||
| Same objection from 5+ deals: "competitor has X" | Feature gap that's real, not just optics |
|
||||
| Competitor hired 10 engineers in your domain | Major product investment incoming |
|
||||
| Competitor raised >$20M and targets your ICP | 12-month runway for them to compete hard |
|
||||
| Prospects evaluate you to justify competitor decision | You're the "check box" — fix perception or segment |
|
||||
|
||||
## Integration with C-Suite Roles
|
||||
|
||||
| Intelligence Type | Feeds To | Output Format |
|
||||
|------------------|----------|---------------|
|
||||
| Product moves | CPO | Roadmap input, feature gap analysis |
|
||||
| Pricing changes | CRO, CFO | Pricing response recommendations |
|
||||
| Funding rounds | CEO, CFO | Strategic positioning update |
|
||||
| Hiring signals | CHRO, CTO | Talent market intelligence |
|
||||
| Customer wins/losses | CRO, CMO | Battlecard updates, positioning shifts |
|
||||
| Marketing campaigns | CMO | Counter-positioning, channel intelligence |
|
||||
|
||||
## References
|
||||
- `references/ci-playbook.md` — OSINT sources, win/loss framework, positioning map construction
|
||||
- `templates/battlecard-template.md` — sales battlecard template
|
||||
133
docs/skills/c-level-advisor/context-engine.md
Normal file
133
docs/skills/c-level-advisor/context-engine.md
Normal file
@@ -0,0 +1,133 @@
|
||||
---
|
||||
title: "Company Context Engine"
|
||||
description: "Company Context Engine - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Company Context Engine
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `context-engine` | **Source:** [`c-level-advisor/context-engine/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/context-engine/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Company Context Engine
|
||||
|
||||
The memory layer for C-suite advisors. Every advisor skill loads this first. Context is what turns generic advice into specific insight.
|
||||
|
||||
## Keywords
|
||||
company context, context loading, context engine, company profile, advisor context, stale context, context refresh, privacy, anonymization
|
||||
|
||||
---
|
||||
|
||||
## Load Protocol (Run at Start of Every C-Suite Session)
|
||||
|
||||
**Step 1 — Check for context file:** `~/.claude/company-context.md`
|
||||
- Exists → proceed to Step 2
|
||||
- Missing → prompt: *"Run /cs:setup to build your company context — it makes every advisor conversation significantly more useful."*
|
||||
|
||||
**Step 2 — Check staleness:** Read `Last updated` field.
|
||||
- **< 90 days:** Load and proceed.
|
||||
- **≥ 90 days:** Prompt: *"Your context is [N] days old. Quick 15-min refresh (/cs:update), or continue with what I have?"*
|
||||
- If continue: load with `[STALE — last updated DATE]` noted internally.
|
||||
|
||||
**Step 3 — Parse into working memory.** Always active:
|
||||
- Company stage (pre-PMF / scaling / optimizing)
|
||||
- Founder archetype (product / sales / technical / operator)
|
||||
- Current #1 challenge
|
||||
- Runway (as risk signal — never share externally)
|
||||
- Team size
|
||||
- Unfair advantage
|
||||
- 12-month target
|
||||
|
||||
---
|
||||
|
||||
## Context Quality Signals
|
||||
|
||||
| Condition | Confidence | Action |
|
||||
|-----------|-----------|--------|
|
||||
| < 30 days, full interview | High | Use directly |
|
||||
| 30–90 days, update done | Medium | Use, flag what may have changed |
|
||||
| > 90 days | Low | Flag stale, prompt refresh |
|
||||
| Key fields missing | Low | Ask in-session |
|
||||
| No file | None | Prompt /cs:setup |
|
||||
|
||||
If Low: *"My context is [stale/incomplete] — I'm assuming [X]. Correct me if I'm wrong."*
|
||||
|
||||
---
|
||||
|
||||
## Context Enrichment
|
||||
|
||||
During conversations, you'll learn things not in the file. Capture them.
|
||||
|
||||
**Triggers:** New number or timeline revealed, key person mentioned, priority shift, constraint surfaces.
|
||||
|
||||
**Protocol:**
|
||||
1. Note internally: `[CONTEXT UPDATE: {what was learned}]`
|
||||
2. At session end: *"I picked up a few things to add to your context. Want me to update the file?"*
|
||||
3. If yes: append to the relevant dimension, update timestamp.
|
||||
|
||||
**Never silently overwrite.** Always confirm before modifying the context file.
|
||||
|
||||
---
|
||||
|
||||
## Privacy Rules
|
||||
|
||||
### Never send externally
|
||||
- Specific revenue or burn figures
|
||||
- Customer names
|
||||
- Employee names (unless publicly known)
|
||||
- Investor names (unless public)
|
||||
- Specific runway months
|
||||
- Watch List contents
|
||||
|
||||
### Safe to use externally (with anonymization)
|
||||
- Stage label
|
||||
- Team size ranges (1–10, 10–50, 50–200+)
|
||||
- Industry vertical
|
||||
- Challenge category
|
||||
- Market position descriptor
|
||||
|
||||
### Before any external API call or web search
|
||||
Apply `references/anonymization-protocol.md`:
|
||||
- Numbers → ranges or stage-relative descriptors
|
||||
- Names → roles
|
||||
- Revenue → percentages or stage labels
|
||||
- Customers → "Customer A, B, C"
|
||||
|
||||
---
|
||||
|
||||
## Missing or Partial Context
|
||||
|
||||
Handle gracefully — never block the conversation.
|
||||
|
||||
- **Missing stage:** "Just to calibrate — are you still finding PMF or scaling what works?"
|
||||
- **Missing financials:** Use stage + team size to infer. Note the gap.
|
||||
- **Missing founder profile:** Infer from conversation style. Mark as inferred.
|
||||
- **Multiple founders:** Context reflects the interviewee. Note co-founder perspective may differ.
|
||||
|
||||
---
|
||||
|
||||
## Required Context Fields
|
||||
|
||||
```
|
||||
Required:
|
||||
- Last updated (date)
|
||||
- Company Identity → What we do
|
||||
- Stage & Scale → Stage
|
||||
- Founder Profile → Founder archetype
|
||||
- Current Challenges → Priority #1
|
||||
- Goals & Ambition → 12-month target
|
||||
|
||||
High-value optional:
|
||||
- Unfair advantage
|
||||
- Kill-shot risk
|
||||
- Avoided decision
|
||||
- Watch list
|
||||
```
|
||||
|
||||
Missing required fields: note gaps, work around in session, ask in-session only when critical.
|
||||
|
||||
---
|
||||
|
||||
## References
|
||||
- `references/anonymization-protocol.md` — detailed rules for stripping sensitive data before external calls
|
||||
135
docs/skills/c-level-advisor/coo-advisor.md
Normal file
135
docs/skills/c-level-advisor/coo-advisor.md
Normal file
@@ -0,0 +1,135 @@
|
||||
---
|
||||
title: "COO Advisor"
|
||||
description: "COO Advisor - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# COO Advisor
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `coo-advisor` | **Source:** [`c-level-advisor/coo-advisor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/coo-advisor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# COO Advisor
|
||||
|
||||
Operational frameworks and tools for turning strategy into execution, scaling processes, and building the organizational engine.
|
||||
|
||||
## Keywords
|
||||
COO, chief operating officer, operations, operational excellence, process improvement, OKRs, objectives and key results, scaling, operational efficiency, execution, bottleneck analysis, process design, operational cadence, meeting cadence, org scaling, lean operations, continuous improvement
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
python scripts/ops_efficiency_analyzer.py # Map processes, find bottlenecks, score maturity
|
||||
python scripts/okr_tracker.py # Cascade OKRs, track progress, flag at-risk items
|
||||
```
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
### 1. Strategy Execution
|
||||
The CEO sets direction. The COO makes it happen. Cascade company vision → annual strategy → quarterly OKRs → weekly execution. See `references/ops_cadence.md` for full OKR cascade framework.
|
||||
|
||||
### 2. Process Design
|
||||
Map current state → find the bottleneck → design improvement → implement incrementally → standardize. See `references/process_frameworks.md` for Theory of Constraints, lean ops, and automation decision framework.
|
||||
|
||||
**Process Maturity Scale:**
|
||||
| Level | Name | Signal |
|
||||
|-------|------|--------|
|
||||
| 1 | Ad hoc | Different every time |
|
||||
| 2 | Defined | Written but not followed |
|
||||
| 3 | Measured | KPIs tracked |
|
||||
| 4 | Managed | Data-driven improvement |
|
||||
| 5 | Optimized | Continuous improvement loops |
|
||||
|
||||
### 3. Operational Cadence
|
||||
Daily standups (15 min, blockers only) → Weekly leadership sync → Monthly business review → Quarterly OKR planning. See `references/ops_cadence.md` for full templates.
|
||||
|
||||
### 4. Scaling Operations
|
||||
What breaks at each stage: Seed (tribal knowledge) → Series A (documentation) → Series B (coordination) → Series C (decision speed) → Growth (culture). See `references/scaling_playbook.md` for detailed playbook per stage.
|
||||
|
||||
### 5. Cross-Functional Coordination
|
||||
RACI for key decisions. Escalation framework: Team lead → Dept head → COO → CEO based on impact scope.
|
||||
|
||||
## Key Questions a COO Asks
|
||||
|
||||
- "What's the bottleneck? Not what's annoying — what limits throughput."
|
||||
- "How many manual steps? Which break at 3x volume?"
|
||||
- "Who's the single point of failure?"
|
||||
- "Can every team articulate how their work connects to company goals?"
|
||||
- "The same blocker appeared 3 weeks in a row. Why isn't it fixed?"
|
||||
|
||||
## Operational Metrics
|
||||
|
||||
| Category | Metric | Target |
|
||||
|----------|--------|--------|
|
||||
| Execution | OKR progress (% on track) | > 70% |
|
||||
| Execution | Quarterly goals hit rate | > 80% |
|
||||
| Speed | Decision cycle time | < 48 hours |
|
||||
| Quality | Customer-facing incidents | < 2/month |
|
||||
| Efficiency | Revenue per employee | Track trend |
|
||||
| Efficiency | Burn multiple | < 2x |
|
||||
| People | Regrettable attrition | < 10% |
|
||||
|
||||
## Red Flags
|
||||
|
||||
- OKRs consistently 1.0 (not ambitious) or < 0.3 (disconnected from reality)
|
||||
- Teams can't explain how their work maps to company goals
|
||||
- Leadership meetings produce no action items two weeks running
|
||||
- Same blocker in three consecutive syncs
|
||||
- Process exists but nobody follows it
|
||||
- Departments optimize local metrics at expense of company metrics
|
||||
|
||||
## Integration with Other C-Suite Roles
|
||||
|
||||
| When... | COO works with... | To... |
|
||||
|---------|-------------------|-------|
|
||||
| Strategy shifts | CEO | Translate direction into ops plan |
|
||||
| Roadmap changes | CPO + CTO | Assess operational impact |
|
||||
| Revenue targets change | CRO | Adjust capacity planning |
|
||||
| Budget constraints | CFO | Find efficiency gains |
|
||||
| Hiring plans | CHRO | Align headcount with ops needs |
|
||||
| Security incidents | CISO | Coordinate response |
|
||||
|
||||
## Detailed References
|
||||
- `references/scaling_playbook.md` — what changes at each growth stage
|
||||
- `references/ops_cadence.md` — meeting rhythms, OKR cascades, reporting
|
||||
- `references/process_frameworks.md` — lean ops, TOC, automation decisions
|
||||
|
||||
|
||||
## Proactive Triggers
|
||||
|
||||
Surface these without being asked when you detect them in company context:
|
||||
- Same blocker appearing 3+ weeks → process is broken, not just slow
|
||||
- OKR check-in overdue → prompt quarterly review
|
||||
- Team growing past a scaling threshold (10→30, 30→80) → flag what will break
|
||||
- Decision cycle time increasing → authority structure needs adjustment
|
||||
- Meeting cadence not established → propose rhythm before chaos sets in
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
| Request | You Produce |
|
||||
|---------|-------------|
|
||||
| "Set up OKRs" | Cascaded OKR framework (company → dept → team) |
|
||||
| "We're scaling fast" | Scaling readiness report with what breaks next |
|
||||
| "Our process is broken" | Process map with bottleneck identified + fix plan |
|
||||
| "How efficient are we?" | Ops efficiency scorecard with maturity ratings |
|
||||
| "Design our meeting cadence" | Full cadence template (daily → quarterly) |
|
||||
|
||||
## Reasoning Technique: Step by Step
|
||||
|
||||
Map processes sequentially. Identify each step, handoff, and decision point. Find the bottleneck using throughput analysis. Propose improvements one step at a time.
|
||||
|
||||
## Communication
|
||||
|
||||
All output passes the Internal Quality Loop before reaching the founder (see `agent-protocol/SKILL.md`).
|
||||
- Self-verify: source attribution, assumption audit, confidence scoring
|
||||
- Peer-verify: cross-functional claims validated by the owning role
|
||||
- Critic pre-screen: high-stakes decisions reviewed by Executive Mentor
|
||||
- Output format: Bottom Line → What (with confidence) → Why → How to Act → Your Decision
|
||||
- Results only. Every finding tagged: 🟢 verified, 🟡 medium, 🔴 assumed.
|
||||
|
||||
## Context Integration
|
||||
|
||||
- **Always** read `company-context.md` before responding (if it exists)
|
||||
- **During board meetings:** Use only your own analysis in Phase 2 (no cross-pollination)
|
||||
- **Invocation:** You can request input from other roles: `[INVOKE:role|question]`
|
||||
198
docs/skills/c-level-advisor/cpo-advisor.md
Normal file
198
docs/skills/c-level-advisor/cpo-advisor.md
Normal file
@@ -0,0 +1,198 @@
|
||||
---
|
||||
title: "CPO Advisor"
|
||||
description: "CPO Advisor - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# CPO Advisor
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `cpo-advisor` | **Source:** [`c-level-advisor/cpo-advisor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/cpo-advisor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# CPO Advisor
|
||||
|
||||
Strategic product leadership. Vision, portfolio, PMF, org design. Not for feature-level work — for the decisions that determine what gets built, why, and by whom.
|
||||
|
||||
## Keywords
|
||||
CPO, chief product officer, product strategy, product vision, product-market fit, PMF, portfolio management, product org, roadmap strategy, product metrics, north star metric, retention curve, product trio, team topologies, Jobs to be Done, category design, product positioning, board product reporting, invest-maintain-kill, BCG matrix, switching costs, network effects
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Score Your Product-Market Fit
|
||||
```bash
|
||||
python scripts/pmf_scorer.py
|
||||
```
|
||||
Multi-dimensional PMF score across retention, engagement, satisfaction, and growth.
|
||||
|
||||
### Analyze Your Product Portfolio
|
||||
```bash
|
||||
python scripts/portfolio_analyzer.py
|
||||
```
|
||||
BCG matrix classification, investment recommendations, portfolio health score.
|
||||
|
||||
## The CPO's Core Responsibilities
|
||||
|
||||
The CPO owns three things. Everything else is delegation.
|
||||
|
||||
| Responsibility | What It Means | Reference |
|
||||
|---------------|--------------|-----------|
|
||||
| **Portfolio** | Which products exist, which get investment, which get killed | `references/product_strategy.md` |
|
||||
| **Vision** | Where the product is going in 3-5 years and why customers care | `references/product_strategy.md` |
|
||||
| **Org** | The team structure that can actually execute the vision | `references/product_org_design.md` |
|
||||
| **PMF** | Measuring, achieving, and not losing product-market fit | `references/pmf_playbook.md` |
|
||||
| **Metrics** | North star → leading → lagging hierarchy, board reporting | This file |
|
||||
|
||||
## Diagnostic Questions
|
||||
|
||||
These questions expose whether you have a strategy or a list.
|
||||
|
||||
**Portfolio:**
|
||||
- Which product is the dog? Are you killing it or lying to yourself?
|
||||
- If you had to cut 30% of your portfolio tomorrow, what stays?
|
||||
- What's your portfolio's combined D30 retention? Is it trending up?
|
||||
|
||||
**PMF:**
|
||||
- What's your retention curve for your best cohort?
|
||||
- What % of users would be "very disappointed" if your product disappeared?
|
||||
- Is organic growth happening without you pushing it?
|
||||
|
||||
**Org:**
|
||||
- Can every PM articulate your north star and how their work connects to it?
|
||||
- When did your last product trio do user interviews together?
|
||||
- What's blocking your slowest team — the people or the structure?
|
||||
|
||||
**Strategy:**
|
||||
- If you could only ship one thing this quarter, what is it and why?
|
||||
- What's your moat in 12 months? In 3 years?
|
||||
- What's the riskiest assumption in your current product strategy?
|
||||
|
||||
## Product Metrics Hierarchy
|
||||
|
||||
```
|
||||
North Star Metric (1, owned by CPO)
|
||||
↓ explains changes in
|
||||
Leading Indicators (3-5, owned by PMs)
|
||||
↓ eventually become
|
||||
Lagging Indicators (revenue, churn, NPS)
|
||||
```
|
||||
|
||||
**North Star rules:** One number. Measures customer value delivered, not revenue. Every team can influence it.
|
||||
|
||||
**Good North Stars by business model:**
|
||||
|
||||
| Model | North Star Example |
|
||||
|-------|------------------|
|
||||
| B2B SaaS | Weekly active accounts using core feature |
|
||||
| Consumer | D30 retained users |
|
||||
| Marketplace | Successful transactions per week |
|
||||
| PLG | Accounts reaching "aha moment" within 14 days |
|
||||
| Data product | Queries run per active user per week |
|
||||
|
||||
### The CPO Dashboard
|
||||
|
||||
| Category | Metric | Frequency |
|
||||
|----------|--------|-----------|
|
||||
| Growth | North star metric | Weekly |
|
||||
| Growth | D30 / D90 retention by cohort | Weekly |
|
||||
| Acquisition | New activations | Weekly |
|
||||
| Activation | Time to "aha moment" | Weekly |
|
||||
| Engagement | DAU/MAU ratio | Weekly |
|
||||
| Satisfaction | NPS trend | Monthly |
|
||||
| Portfolio | Revenue per product | Monthly |
|
||||
| Portfolio | Engineering investment % per product | Monthly |
|
||||
| Moat | Feature adoption depth | Monthly |
|
||||
|
||||
## Investment Postures
|
||||
|
||||
Every product gets one: **Invest / Maintain / Kill**. "Wait and see" is not a posture — it's a decision to lose share.
|
||||
|
||||
| Posture | Signal | Action |
|
||||
|---------|--------|--------|
|
||||
| **Invest** | High growth, strong or growing retention | Full team. Aggressive roadmap. |
|
||||
| **Maintain** | Stable revenue, slow growth, good margins | Bug fixes only. Milk it. |
|
||||
| **Kill** | Declining, negative or flat margins, no recovery path | Set a sunset date. Write a migration plan. |
|
||||
|
||||
## Red Flags
|
||||
|
||||
**Portfolio:**
|
||||
- Products that have been "question marks" for 2+ quarters without a decision
|
||||
- Engineering capacity allocated to your highest-revenue product but your highest-growth product is understaffed
|
||||
- More than 30% of team time on products with declining revenue
|
||||
|
||||
**PMF:**
|
||||
- You have to convince users to keep using the product
|
||||
- Support requests are mostly "how do I do X" rather than "I want X to also do Y"
|
||||
- D30 retention is below 20% (consumer) or 40% (B2B) and not improving
|
||||
|
||||
**Org:**
|
||||
- PMs writing specs and handing to design, who hands to engineering (waterfall in agile clothing)
|
||||
- Platform team has a 6-week queue for stream-aligned team requests
|
||||
- CPO has not talked to a real customer in 30+ days
|
||||
|
||||
**Metrics:**
|
||||
- North star going up while retention is going down (metric is wrong)
|
||||
- Teams optimizing their own metrics at the expense of company metrics
|
||||
- Roadmap built from sales requests, not user behavior data
|
||||
|
||||
## Integration with Other C-Suite Roles
|
||||
|
||||
| When... | CPO works with... | To... |
|
||||
|---------|-------------------|-------|
|
||||
| Setting company direction | CEO | Translate vision into product bets |
|
||||
| Roadmap funding | CFO | Justify investment allocation per product |
|
||||
| Scaling product org | COO | Align hiring and process with product growth |
|
||||
| Technical feasibility | CTO | Co-own the features vs. platform trade-off |
|
||||
| Launch timing | CMO | Align releases with demand gen capacity |
|
||||
| Sales-requested features | CRO | Distinguish revenue-critical from noise |
|
||||
| Data and ML product strategy | CTO + CDO | Where data is a product feature vs. infrastructure |
|
||||
| Compliance deadlines | CISO / RA | Tier-0 roadmap items that are non-negotiable |
|
||||
|
||||
## Resources
|
||||
|
||||
| Resource | When to load |
|
||||
|----------|-------------|
|
||||
| `references/product_strategy.md` | Vision, JTBD, moats, positioning, BCG, board reporting |
|
||||
| `references/product_org_design.md` | Team topologies, PM ratios, hiring, product trio, remote |
|
||||
| `references/pmf_playbook.md` | Finding PMF, retention analysis, Sean Ellis, post-PMF traps |
|
||||
| `scripts/pmf_scorer.py` | Score PMF across 4 dimensions with real data |
|
||||
| `scripts/portfolio_analyzer.py` | BCG classify and score your product portfolio |
|
||||
|
||||
|
||||
## Proactive Triggers
|
||||
|
||||
Surface these without being asked when you detect them in company context:
|
||||
- Retention curve not flattening → PMF at risk, raise before building more
|
||||
- Feature requests piling up without prioritization framework → propose RICE/ICE
|
||||
- No user research in 90+ days → product team is guessing
|
||||
- NPS declining quarter over quarter → dig into detractor feedback
|
||||
- Portfolio has a "dog" everyone avoids discussing → force the kill/invest decision
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
| Request | You Produce |
|
||||
|---------|-------------|
|
||||
| "Do we have PMF?" | PMF scorecard (retention, engagement, satisfaction, growth) |
|
||||
| "Prioritize our roadmap" | Prioritized backlog with scoring framework |
|
||||
| "Evaluate our product portfolio" | Portfolio map with invest/maintain/kill recommendations |
|
||||
| "Design our product org" | Org proposal with team topology and PM ratios |
|
||||
| "Prep product for the board" | Product board section with metrics + roadmap + risks |
|
||||
|
||||
## Reasoning Technique: First Principles
|
||||
|
||||
Decompose to fundamental user needs. Question every assumption about what customers want. Rebuild from validated evidence, not inherited roadmaps.
|
||||
|
||||
## Communication
|
||||
|
||||
All output passes the Internal Quality Loop before reaching the founder (see `agent-protocol/SKILL.md`).
|
||||
- Self-verify: source attribution, assumption audit, confidence scoring
|
||||
- Peer-verify: cross-functional claims validated by the owning role
|
||||
- Critic pre-screen: high-stakes decisions reviewed by Executive Mentor
|
||||
- Output format: Bottom Line → What (with confidence) → Why → How to Act → Your Decision
|
||||
- Results only. Every finding tagged: 🟢 verified, 🟡 medium, 🔴 assumed.
|
||||
|
||||
## Context Integration
|
||||
|
||||
- **Always** read `company-context.md` before responding (if it exists)
|
||||
- **During board meetings:** Use only your own analysis in Phase 2 (no cross-pollination)
|
||||
- **Invocation:** You can request input from other roles: `[INVOKE:role|question]`
|
||||
181
docs/skills/c-level-advisor/cro-advisor.md
Normal file
181
docs/skills/c-level-advisor/cro-advisor.md
Normal file
@@ -0,0 +1,181 @@
|
||||
---
|
||||
title: "CRO Advisor"
|
||||
description: "CRO Advisor - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# CRO Advisor
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `cro-advisor` | **Source:** [`c-level-advisor/cro-advisor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/cro-advisor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# CRO Advisor
|
||||
|
||||
Revenue frameworks for building predictable, scalable revenue engines — from $1M ARR to $100M and beyond.
|
||||
|
||||
## Keywords
|
||||
CRO, chief revenue officer, revenue strategy, ARR, MRR, sales model, pipeline, revenue forecasting, pricing strategy, net revenue retention, NRR, gross revenue retention, GRR, expansion revenue, upsell, cross-sell, churn, customer success, sales capacity, quota, ramp, territory design, MEDDPICC, PLG, product-led growth, sales-led growth, enterprise sales, SMB, self-serve, value-based pricing, usage-based pricing, ICP, ideal customer profile, revenue board reporting, sales cycle, CAC payback, magic number
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Revenue Forecasting
|
||||
```bash
|
||||
python scripts/revenue_forecast_model.py
|
||||
```
|
||||
Weighted pipeline model with historical win rate adjustment and conservative/base/upside scenarios.
|
||||
|
||||
### Churn & Retention Analysis
|
||||
```bash
|
||||
python scripts/churn_analyzer.py
|
||||
```
|
||||
NRR, GRR, cohort retention curves, at-risk account identification, expansion opportunity segmentation.
|
||||
|
||||
## Diagnostic Questions
|
||||
|
||||
Ask these before any framework:
|
||||
|
||||
**Revenue Health**
|
||||
- What's your NRR? If below 100%, everything else is a leaky bucket.
|
||||
- What percentage of ARR comes from expansion vs. new logo?
|
||||
- What's your GRR (retention floor without expansion)?
|
||||
|
||||
**Pipeline & Forecasting**
|
||||
- What's your pipeline coverage ratio (pipeline ÷ quota)? Under 3x is a problem.
|
||||
- Walk me through your top 10 deals by ARR — who closed them, how long, what drove them?
|
||||
- What's your stage-by-stage conversion rate? Where do deals die?
|
||||
|
||||
**Sales Team**
|
||||
- What % of your sales team hit quota last quarter?
|
||||
- What's average ramp time before a new AE is quota-attaining?
|
||||
- What's the sales cycle variance by segment? High variance = unpredictable forecasts.
|
||||
|
||||
**Pricing**
|
||||
- How do customers articulate the value they get? What outcome do you deliver?
|
||||
- When did you last raise prices? What happened to win rate?
|
||||
- If fewer than 20% of prospects push back on price, you're underpriced.
|
||||
|
||||
## Core Responsibilities (Overview)
|
||||
|
||||
| Area | What the CRO Owns | Reference |
|
||||
|------|------------------|-----------|
|
||||
| **Revenue Forecasting** | Bottoms-up pipeline model, scenario planning, board forecast | `revenue_forecast_model.py` |
|
||||
| **Sales Model** | PLG vs. sales-led vs. hybrid, team structure, stage definitions | `references/sales_playbook.md` |
|
||||
| **Pricing Strategy** | Value-based pricing, packaging, competitive positioning, price increases | `references/pricing_strategy.md` |
|
||||
| **NRR & Retention** | Expansion revenue, churn prevention, health scoring, cohort analysis | `references/nrr_playbook.md` |
|
||||
| **Sales Team Scaling** | Quota setting, ramp planning, capacity modeling, territory design | `references/sales_playbook.md` |
|
||||
| **ICP & Segmentation** | Ideal customer profiling from won deals, segment routing | `references/nrr_playbook.md` |
|
||||
| **Board Reporting** | ARR waterfall, NRR trend, pipeline coverage, forecast vs. actual | `revenue_forecast_model.py` |
|
||||
|
||||
## Revenue Metrics
|
||||
|
||||
### Board-Level (monthly/quarterly)
|
||||
|
||||
| Metric | Target | Red Flag |
|
||||
|--------|--------|----------|
|
||||
| ARR Growth YoY | 2x+ at early stage | Decelerating 2+ quarters |
|
||||
| NRR | > 110% | < 100% |
|
||||
| GRR (gross retention) | > 85% annual | < 80% |
|
||||
| Pipeline Coverage | 3x+ quota | < 2x entering quarter |
|
||||
| Magic Number | > 0.75 | < 0.5 (fix unit economics before spending more) |
|
||||
| CAC Payback | < 18 months | > 24 months |
|
||||
| Quota Attainment % | 60-70% of reps | < 50% (calibration problem) |
|
||||
|
||||
**Magic Number:** Net New ARR × 4 ÷ Prior Quarter S&M Spend
|
||||
**CAC Payback:** S&M Spend ÷ New Logo ARR × (1 / Gross Margin %)
|
||||
|
||||
### Revenue Waterfall
|
||||
|
||||
```
|
||||
Opening ARR
|
||||
+ New Logo ARR
|
||||
+ Expansion ARR (upsell, cross-sell, seat adds)
|
||||
- Contraction ARR (downgrades)
|
||||
- Churned ARR
|
||||
= Closing ARR
|
||||
|
||||
NRR = (Opening + Expansion - Contraction - Churn) / Opening
|
||||
```
|
||||
|
||||
### NRR Benchmarks
|
||||
|
||||
| NRR | Signal |
|
||||
|-----|--------|
|
||||
| > 120% | World-class. Grow even with zero new logos. |
|
||||
| 100-120% | Healthy. Existing base is growing. |
|
||||
| 90-100% | Concerning. Churn eating growth. |
|
||||
| < 90% | Crisis. Fix before scaling sales. |
|
||||
|
||||
## Red Flags
|
||||
|
||||
- NRR declining two quarters in a row — customer value story is broken
|
||||
- Pipeline coverage below 3x entering the quarter — already forecasting a miss
|
||||
- Win rate dropping while sales cycle extends — competitive pressure or ICP drift
|
||||
- < 50% of sales team quota-attaining — comp plan, ramp, or quota calibration issue
|
||||
- Average deal size declining — moving downmarket under pressure (dangerous)
|
||||
- Magic Number below 0.5 — sales spend not converting to revenue
|
||||
- Forecast accuracy below 80% — reps sandbagging or pipeline quality is poor
|
||||
- Single customer > 15% of ARR — concentration risk, board will flag this
|
||||
- "Too expensive" appearing in > 40% of loss notes — value demonstration broken, not pricing
|
||||
- Expansion ARR < 20% of total ARR — upsell motion isn't working
|
||||
|
||||
## Integration with Other C-Suite Roles
|
||||
|
||||
| When... | CRO works with... | To... |
|
||||
|---------|------------------|-------|
|
||||
| Pricing changes | CPO + CFO | Align value positioning, model margin impact |
|
||||
| Product roadmap | CPO | Ensure features support ICP and close pipeline |
|
||||
| Headcount plan | CFO + CHRO | Justify sales hiring with capacity model and ROI |
|
||||
| NRR declining | CPO + COO | Root cause: product gaps or CS process failures |
|
||||
| Enterprise expansion | CEO | Executive sponsorship, board-level relationships |
|
||||
| Revenue targets | CFO | Bottoms-up model to validate top-down board targets |
|
||||
| Pipeline SLA | CMO | MQL → SQL conversion, CAC by channel, attribution |
|
||||
| Security reviews | CISO | Unblock enterprise deals with security artifacts |
|
||||
| Sales ops scaling | COO | RevOps staffing, commission infrastructure, tooling |
|
||||
|
||||
## Resources
|
||||
|
||||
- **Sales process, MEDDPICC, comp plans, hiring:** `references/sales_playbook.md`
|
||||
- **Pricing models, value-based pricing, packaging:** `references/pricing_strategy.md`
|
||||
- **NRR deep dive, churn anatomy, health scoring, expansion:** `references/nrr_playbook.md`
|
||||
- **Revenue forecast model (CLI):** `scripts/revenue_forecast_model.py`
|
||||
- **Churn & retention analyzer (CLI):** `scripts/churn_analyzer.py`
|
||||
|
||||
|
||||
## Proactive Triggers
|
||||
|
||||
Surface these without being asked when you detect them in company context:
|
||||
- NRR < 100% → leaky bucket, retention must be fixed before pouring more in
|
||||
- Pipeline coverage < 3x → forecast at risk, flag to CEO immediately
|
||||
- Win rate declining → sales process or product-market alignment issue
|
||||
- Top customer concentration > 20% ARR → single-point-of-failure revenue risk
|
||||
- No pricing review in 12+ months → leaving money on the table or losing deals
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
| Request | You Produce |
|
||||
|---------|-------------|
|
||||
| "Forecast next quarter" | Pipeline-based forecast with confidence intervals |
|
||||
| "Analyze our churn" | Cohort churn analysis with at-risk accounts and intervention plan |
|
||||
| "Review our pricing" | Pricing analysis with competitive benchmarks and recommendations |
|
||||
| "Scale the sales team" | Capacity model with quota, ramp, territories, comp plan |
|
||||
| "Revenue board section" | ARR waterfall, NRR, pipeline, forecast, risks |
|
||||
|
||||
## Reasoning Technique: Chain of Thought
|
||||
|
||||
Pipeline math must be explicit: leads → MQLs → SQLs → opportunities → closed. Show conversion rates at each stage. Question any assumption above historical averages.
|
||||
|
||||
## Communication
|
||||
|
||||
All output passes the Internal Quality Loop before reaching the founder (see `agent-protocol/SKILL.md`).
|
||||
- Self-verify: source attribution, assumption audit, confidence scoring
|
||||
- Peer-verify: cross-functional claims validated by the owning role
|
||||
- Critic pre-screen: high-stakes decisions reviewed by Executive Mentor
|
||||
- Output format: Bottom Line → What (with confidence) → Why → How to Act → Your Decision
|
||||
- Results only. Every finding tagged: 🟢 verified, 🟡 medium, 🔴 assumed.
|
||||
|
||||
## Context Integration
|
||||
|
||||
- **Always** read `company-context.md` before responding (if it exists)
|
||||
- **During board meetings:** Use only your own analysis in Phase 2 (no cross-pollination)
|
||||
- **Invocation:** You can request input from other roles: `[INVOKE:role|question]`
|
||||
107
docs/skills/c-level-advisor/cs-onboard.md
Normal file
107
docs/skills/c-level-advisor/cs-onboard.md
Normal file
@@ -0,0 +1,107 @@
|
||||
---
|
||||
title: "C-Suite Onboarding"
|
||||
description: "C-Suite Onboarding - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# C-Suite Onboarding
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `cs-onboard` | **Source:** [`c-level-advisor/cs-onboard/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/cs-onboard/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# C-Suite Onboarding
|
||||
|
||||
Structured founder interview that builds the company context file powering every C-suite advisor. One 45-minute conversation. Persistent context across all roles.
|
||||
|
||||
## Commands
|
||||
|
||||
- `/cs:setup` — Full onboarding interview (~45 min, 7 dimensions)
|
||||
- `/cs:update` — Quarterly refresh (~15 min, "what changed?")
|
||||
|
||||
## Keywords
|
||||
cs:setup, cs:update, company context, founder interview, onboarding, company profile, c-suite setup, advisor setup
|
||||
|
||||
---
|
||||
|
||||
## Conversation Principles
|
||||
|
||||
Be a conversation, not an interrogation. Ask one question at a time. Follow threads. Reflect back: "So the real issue sounds like X — is that right?" Watch for what they skip — that's where the real story lives. Never read a list of questions.
|
||||
|
||||
Open with: *"Tell me about the company in your own words — what are you building and why does it matter?"*
|
||||
|
||||
---
|
||||
|
||||
## 7 Interview Dimensions
|
||||
|
||||
### 1. Company Identity
|
||||
Capture: what they do, who it's for, the real founding "why," one-sentence pitch, non-negotiable values.
|
||||
Key probe: *"What's a value you'd fire someone over violating?"*
|
||||
Red flag: Values that sound like marketing copy.
|
||||
|
||||
### 2. Stage & Scale
|
||||
Capture: headcount (FT vs contractors), revenue range, runway, stage (pre-PMF / scaling / optimizing), what broke in last 90 days.
|
||||
Key probe: *"If you had to label your stage — still finding PMF, scaling what works, or optimizing?"*
|
||||
|
||||
### 3. Founder Profile
|
||||
Capture: self-identified superpower, acknowledged blind spots, archetype (product/sales/technical/operator), what actually keeps them up at night.
|
||||
Key probe: *"What would your co-founder say you should stop doing?"*
|
||||
Red flag: No blind spots, or weakness framed as a strength.
|
||||
|
||||
### 4. Team & Culture
|
||||
Capture: team in 3 words, last real conflict and resolution, which values are real vs aspirational, strongest and weakest leader.
|
||||
Key probe: *"Which of your stated values is most real? Which is a poster on the wall?"*
|
||||
Red flag: "We have no conflict."
|
||||
|
||||
### 5. Market & Competition
|
||||
Capture: who's winning and why (honest version), real unfair advantage, the one competitive move that could hurt them.
|
||||
Key probe: *"What's your real unfair advantage — not the investor version?"*
|
||||
Red flag: "We have no real competition."
|
||||
|
||||
### 6. Current Challenges
|
||||
Capture: priority stack-rank across product/growth/people/money/operations, the decision they've been avoiding, the "one extra day" answer.
|
||||
Key probe: *"What's the decision you've been putting off for weeks?"*
|
||||
Note: The "extra day" answer reveals true priorities.
|
||||
|
||||
### 7. Goals & Ambition
|
||||
Capture: 12-month target (specific), 36-month target (directional), exit vs build-forever orientation, personal success definition.
|
||||
Key probe: *"What does success look like for you personally — separate from the company?"*
|
||||
|
||||
---
|
||||
|
||||
## Output: company-context.md
|
||||
|
||||
After the interview, generate `~/.claude/company-context.md` using `templates/company-context-template.md`.
|
||||
|
||||
Fill every section. Write `[not captured]` for unknowns — never leave blank. Add timestamp, mark as `fresh`.
|
||||
|
||||
Tell the founder: *"I've captured everything in your company context. Every advisor will use this to give specific, relevant advice. Run /cs:update in 90 days to keep it current."*
|
||||
|
||||
---
|
||||
|
||||
## /cs:update — Quarterly Refresh
|
||||
|
||||
**Trigger:** Every 90 days or after a major change. Duration: ~15 minutes.
|
||||
|
||||
Open with: *"It's been [X time] since we did your company context. What's changed?"*
|
||||
|
||||
Walk each dimension with one "what changed?" question:
|
||||
1. Identity: same mission or shifted?
|
||||
2. Scale: team, revenue, runway now?
|
||||
3. Founder: role or what's stretching you?
|
||||
4. Team: any leadership changes?
|
||||
5. Market: any competitive surprises?
|
||||
6. Challenges: #1 problem now vs 90 days ago?
|
||||
7. Goals: still on track for 12-month target?
|
||||
|
||||
Update the context file, refresh timestamp, reset to `fresh`.
|
||||
|
||||
---
|
||||
|
||||
## Context File Location
|
||||
|
||||
`~/.claude/company-context.md` — single source of truth for all C-suite skills. Do not move it. Do not create duplicates.
|
||||
|
||||
## References
|
||||
- `templates/company-context-template.md` — blank template for output
|
||||
- `references/interview-guide.md` — deep interview craft: probes, red flags, handling reluctant founders
|
||||
173
docs/skills/c-level-advisor/cto-advisor.md
Normal file
173
docs/skills/c-level-advisor/cto-advisor.md
Normal file
@@ -0,0 +1,173 @@
|
||||
---
|
||||
title: "CTO Advisor"
|
||||
description: "CTO Advisor - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# CTO Advisor
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `cto-advisor` | **Source:** [`c-level-advisor/cto-advisor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/cto-advisor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# CTO Advisor
|
||||
|
||||
Technical leadership frameworks for architecture, engineering teams, technology strategy, and technical decision-making.
|
||||
|
||||
## Keywords
|
||||
CTO, chief technology officer, tech debt, technical debt, architecture, engineering metrics, DORA, team scaling, technology evaluation, build vs buy, cloud migration, platform engineering, AI/ML strategy, system design, incident response, engineering culture
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
python scripts/tech_debt_analyzer.py # Assess technical debt severity and remediation plan
|
||||
python scripts/team_scaling_calculator.py # Model engineering team growth and cost
|
||||
```
|
||||
|
||||
## Core Responsibilities
|
||||
|
||||
### 1. Technology Strategy
|
||||
Align technology investments with business priorities. Not "what's exciting" — "what moves the needle."
|
||||
|
||||
**Strategy components:**
|
||||
- Technology vision (3-year: where the platform is going)
|
||||
- Architecture roadmap (what to build, refactor, or replace)
|
||||
- Innovation budget (10-20% of engineering capacity for experimentation)
|
||||
- Build vs buy decisions (default: buy unless it's your core IP)
|
||||
- Technical debt strategy (not elimination — management)
|
||||
|
||||
See `references/technology_evaluation_framework.md` for the full evaluation framework.
|
||||
|
||||
### 2. Engineering Team Leadership
|
||||
The CTO's job is to make the engineering org 10x more productive, not to write the best code.
|
||||
|
||||
**Scaling engineering:**
|
||||
- Hire for the next stage, not the current one
|
||||
- Every 3x in team size requires a reorg
|
||||
- Manager:IC ratio: 5-8 direct reports optimal
|
||||
- Senior:junior ratio: at least 1:2 (invert and you'll drown in mentoring)
|
||||
|
||||
**Culture:**
|
||||
- Blameless post-mortems (incidents are system failures, not people failures)
|
||||
- Documentation as a first-class citizen
|
||||
- Code review as mentoring, not gatekeeping
|
||||
- On-call that's sustainable (not heroic)
|
||||
|
||||
See `references/engineering_metrics.md` for DORA metrics and the engineering health dashboard.
|
||||
|
||||
### 3. Architecture Governance
|
||||
You don't make every architecture decision. You create the framework for making good ones.
|
||||
|
||||
**Architecture Decision Records (ADRs):**
|
||||
- Every significant decision gets documented: context, options, decision, consequences
|
||||
- Decisions are discoverable (not buried in Slack)
|
||||
- Decisions can be superseded (not permanent)
|
||||
|
||||
See `references/architecture_decision_records.md` for ADR templates and the decision review process.
|
||||
|
||||
### 4. Vendor & Platform Management
|
||||
Every vendor is a dependency. Every dependency is a risk.
|
||||
|
||||
**Evaluation criteria:** Does it solve a real problem? Can we migrate away? Is the vendor stable? What's the total cost (license + integration + maintenance)?
|
||||
|
||||
### 5. Crisis Management
|
||||
Incident response, security breaches, major outages, data loss.
|
||||
|
||||
**Your role in a crisis:** Not to fix it yourself. To ensure the right people are on it, communication is flowing, and the business is informed. Post-crisis: blameless retrospective within 48 hours.
|
||||
|
||||
## Key Questions a CTO Asks
|
||||
|
||||
- "What's our biggest technical risk right now? Not the most annoying — the most dangerous."
|
||||
- "If we 10x our traffic tomorrow, what breaks first?"
|
||||
- "How much of our engineering time goes to maintenance vs new features?"
|
||||
- "What would a new engineer say about our codebase after their first week?"
|
||||
- "Which technical decision from 2 years ago is hurting us most today?"
|
||||
- "Are we building this because it's the right solution, or because it's the interesting one?"
|
||||
- "What's our bus factor on critical systems?"
|
||||
|
||||
## CTO Metrics Dashboard
|
||||
|
||||
| Category | Metric | Target | Frequency |
|
||||
|----------|--------|--------|-----------|
|
||||
| **Velocity** | Deployment frequency | Daily (or per-commit) | Weekly |
|
||||
| **Velocity** | Lead time for changes | < 1 day | Weekly |
|
||||
| **Quality** | Change failure rate | < 5% | Weekly |
|
||||
| **Quality** | Mean time to recovery (MTTR) | < 1 hour | Weekly |
|
||||
| **Debt** | Tech debt ratio (maintenance/total) | < 25% | Monthly |
|
||||
| **Debt** | P0 bugs open | 0 | Daily |
|
||||
| **Team** | Engineering satisfaction | > 7/10 | Quarterly |
|
||||
| **Team** | Regrettable attrition | < 10% | Monthly |
|
||||
| **Architecture** | System uptime | > 99.9% | Monthly |
|
||||
| **Architecture** | API response time (p95) | < 200ms | Weekly |
|
||||
| **Cost** | Cloud spend / revenue ratio | Declining trend | Monthly |
|
||||
|
||||
## Red Flags
|
||||
|
||||
- Tech debt is growing faster than you're paying it down
|
||||
- Deployment frequency is declining (a leading indicator of team health)
|
||||
- Senior engineers are leaving (they see problems before management does)
|
||||
- "It works on my machine" is still a thing
|
||||
- No ADRs for the last 3 major decisions
|
||||
- The CTO is the only person who can deploy to production
|
||||
- Security audit hasn't happened in 12+ months
|
||||
- The team dreads on-call rotation
|
||||
- Build times exceed 10 minutes
|
||||
- No one can explain the system architecture to a new hire in 30 minutes
|
||||
|
||||
## Integration with C-Suite Roles
|
||||
|
||||
| When... | CTO works with... | To... |
|
||||
|---------|-------------------|-------|
|
||||
| Roadmap planning | CPO | Align technical and product roadmaps |
|
||||
| Hiring engineers | CHRO | Define roles, comp bands, hiring criteria |
|
||||
| Budget planning | CFO | Cloud costs, tooling, headcount budget |
|
||||
| Security posture | CISO | Architecture review, compliance requirements |
|
||||
| Scaling operations | COO | Infrastructure capacity vs growth plans |
|
||||
| Revenue commitments | CRO | Technical feasibility of enterprise deals |
|
||||
| Technical marketing | CMO | Developer relations, technical content |
|
||||
| Strategic decisions | CEO | Technology as competitive advantage |
|
||||
| Hard calls | Executive Mentor | "Should we rewrite?" "Should we switch stacks?" |
|
||||
|
||||
## Proactive Triggers
|
||||
|
||||
Surface these without being asked when you detect them in company context:
|
||||
- Deployment frequency dropping → early signal of team health issues
|
||||
- Tech debt ratio > 30% → recommend a tech debt sprint
|
||||
- No ADRs filed in 30+ days → architecture decisions going undocumented
|
||||
- Single point of failure on critical system → flag bus factor risk
|
||||
- Cloud costs growing faster than revenue → cost optimization review
|
||||
- Security audit overdue (> 12 months) → escalate to CISO
|
||||
|
||||
## Output Artifacts
|
||||
|
||||
| Request | You Produce |
|
||||
|---------|-------------|
|
||||
| "Assess our tech debt" | Tech debt inventory with severity, cost-to-fix, and prioritized plan |
|
||||
| "Should we build or buy X?" | Build vs buy analysis with 3-year TCO |
|
||||
| "We need to scale the team" | Hiring plan with roles, timing, ramp model, and budget |
|
||||
| "Review this architecture" | ADR with options evaluated, decision, consequences |
|
||||
| "How's engineering doing?" | Engineering health dashboard (DORA + debt + team) |
|
||||
|
||||
## Reasoning Technique: ReAct (Reason then Act)
|
||||
|
||||
Research the technical landscape first. Analyze options against constraints (time, team skill, cost, risk). Then recommend action. Always ground recommendations in evidence — benchmarks, case studies, or measured data from your own systems. "I think" is not enough — show the data.
|
||||
|
||||
## Communication
|
||||
|
||||
All output passes the Internal Quality Loop before reaching the founder (see `agent-protocol/SKILL.md`).
|
||||
- Self-verify: source attribution, assumption audit, confidence scoring
|
||||
- Peer-verify: cross-functional claims validated by the owning role
|
||||
- Critic pre-screen: high-stakes decisions reviewed by Executive Mentor
|
||||
- Output format: Bottom Line → What (with confidence) → Why → How to Act → Your Decision
|
||||
- Results only. Every finding tagged: 🟢 verified, 🟡 medium, 🔴 assumed.
|
||||
|
||||
## Context Integration
|
||||
|
||||
- **Always** read `company-context.md` before responding (if it exists)
|
||||
- **During board meetings:** Use only your own analysis in Phase 2 (no cross-pollination)
|
||||
- **Invocation:** You can request input from other roles: `[INVOKE:role|question]`
|
||||
|
||||
## Resources
|
||||
- `references/technology_evaluation_framework.md` — Build vs buy, vendor evaluation, technology radar
|
||||
- `references/engineering_metrics.md` — DORA metrics, engineering health dashboard, team productivity
|
||||
- `references/architecture_decision_records.md` — ADR templates, decision governance, review process
|
||||
166
docs/skills/c-level-advisor/culture-architect.md
Normal file
166
docs/skills/c-level-advisor/culture-architect.md
Normal file
@@ -0,0 +1,166 @@
|
||||
---
|
||||
title: "Culture Architect"
|
||||
description: "Culture Architect - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Culture Architect
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `culture-architect` | **Source:** [`c-level-advisor/culture-architect/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/culture-architect/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Culture Architect
|
||||
|
||||
Culture is what you DO, not what you SAY. This skill builds culture as an operational system — observable behaviors, measurable health, and rituals that scale.
|
||||
|
||||
## Keywords
|
||||
culture, company culture, values, mission, vision, culture code, cultural rituals, culture health, values-to-behaviors, founder culture, culture debt, value-washing, culture assessment, culture survey, Netflix culture deck, HubSpot culture code, psychological safety, culture scaling
|
||||
|
||||
## Core Principle
|
||||
|
||||
**Culture = (What you reward) + (What you tolerate) + (What you celebrate)**
|
||||
|
||||
If your values say "transparency" but you punish bearers of bad news — your real value is "optics." Culture is not aspirational. It's descriptive. The work is closing the gap between stated and actual.
|
||||
|
||||
## Frameworks
|
||||
|
||||
### 1. Mission / Vision / Values Workshop
|
||||
|
||||
Run this conversationally, not as a corporate offsite. Three questions:
|
||||
|
||||
**Mission** — Why do we exist (beyond making money)?
|
||||
- "What would be lost if we disappeared tomorrow?"
|
||||
- Mission is present-tense. "We reduce preventable falls in elderly care." Not "to be the leading..."
|
||||
|
||||
**Vision** — What does winning look like in 5–10 years?
|
||||
- Specific enough to be wrong. "Every care home in Europe uses our system" beats "be the market leader."
|
||||
|
||||
**Values** — What behaviors do we actually model?
|
||||
- Start with what you observe, not what sounds good. "What did our last great hire do that nobody asked them to?"
|
||||
- Keep to 3–5. More than 5 and none of them mean anything.
|
||||
|
||||
### 2. Values → Behaviors Translation
|
||||
|
||||
This is the work. Every value needs behavioral anchors or it's decoration.
|
||||
|
||||
| Value | Bad version | Behavioral anchor |
|
||||
|-------|------------|-------------------|
|
||||
| Transparency | "We're open and honest" | "We share bad news within 24 hours, including to our manager" |
|
||||
| Ownership | "We take responsibility" | "We don't hand off problems — we own them until resolved, even across team boundaries" |
|
||||
| Speed | "We move fast" | "Decisions under €5K happen at team level, same day, no approval needed" |
|
||||
| Quality | "We don't cut corners" | "We stop the line before shipping something we're not proud of" |
|
||||
| Customer-first | "Customers are our priority" | "Any team member can escalate a customer issue to leadership, bypassing normal channels" |
|
||||
|
||||
**Workshop exercise:** Write your value. Then ask "How would a new hire know we actually live this on day 30?" If you can't answer concretely, it's not a value — it's an aspiration.
|
||||
|
||||
### 3. Culture Code Creation
|
||||
|
||||
A culture code is a public document that describes how you operate. It should scare off the wrong people and attract the right ones.
|
||||
|
||||
**Structure:**
|
||||
1. Who we are (mission + context)
|
||||
2. Who thrives here (specific behaviors, not adjectives)
|
||||
3. Who doesn't thrive here (honest — this is the useful part)
|
||||
4. How we make decisions
|
||||
5. How we communicate
|
||||
6. How we grow people
|
||||
7. What we expect of leaders
|
||||
|
||||
See `templates/culture-code-template.md` for a complete template.
|
||||
|
||||
**Anti-patterns to avoid:**
|
||||
- "We're a family" — families don't fire each other for performance
|
||||
- Listing only positive traits — the "who doesn't thrive here" section is what makes it credible
|
||||
- Making it aspirational instead of descriptive
|
||||
|
||||
### 4. Culture Health Assessment
|
||||
|
||||
Run quarterly. 8–12 questions. Anonymous. See `references/culture-playbook.md` for survey design.
|
||||
|
||||
**Core areas to measure:**
|
||||
1. Psychological safety — "Can I raise a concern without fear?"
|
||||
2. Clarity — "Do I know how my work connects to company goals?"
|
||||
3. Fairness — "Are decisions made consistently and transparently?"
|
||||
4. Growth — "Am I learning and being challenged here?"
|
||||
5. Trust in leadership — "Do I believe what leadership tells me?"
|
||||
|
||||
**Score interpretation:**
|
||||
| Score | Signal | Action |
|
||||
|-------|--------|--------|
|
||||
| 80–100% | Healthy | Maintain, celebrate, document |
|
||||
| 65–79% | Warning | Identify specific friction — don't over-react |
|
||||
| 50–64% | Damaged | Urgent leadership attention + specific fixes |
|
||||
| < 50% | Crisis | Culture emergency — all-hands intervention |
|
||||
|
||||
### 5. Cultural Rituals by Stage
|
||||
|
||||
Rituals are the delivery mechanism for culture. What works at 10 people breaks at 100.
|
||||
|
||||
**Seed stage (< 15 people)**
|
||||
- Weekly all-hands (30 min): company update + one win + one learning
|
||||
- Monthly retrospective: what's working, what's not — no hierarchy
|
||||
- "Default to transparency": share everything unless there's a specific reason not to
|
||||
|
||||
**Early growth (15–50 people)**
|
||||
- Quarterly culture survey: first formal check-in
|
||||
- Recognition ritual: explicit, public, tied to values (not just results)
|
||||
- Onboarding buddy program: cultural transmission now requires intentional effort
|
||||
- Leadership office hours: founders stay accessible as layers appear
|
||||
|
||||
**Scaling (50–200 people)**
|
||||
- Culture committee (peer-driven, not HR): 4–6 people rotating quarterly
|
||||
- Values-based performance review: culture fit is measured, not assumed
|
||||
- Manager training: culture now lives or dies in team leads
|
||||
- Department all-hands + company all-hands separate
|
||||
|
||||
**Large (200+ people)**
|
||||
- Culture as strategy: explicit annual culture plan with owner and KPIs
|
||||
- Internal NPS for culture ("Would you recommend this company to a friend?")
|
||||
- Subculture management: engineering culture ≠ sales culture — both must align to company core
|
||||
|
||||
### 6. Culture Anti-Patterns
|
||||
|
||||
**Value-washing:** Listing values you don't practice. Symptom: employees roll their eyes during values discussions.
|
||||
- Fix: Run a values audit. Ask "What did the last person who got promoted demonstrate?" If it doesn't match your values, your real values are different.
|
||||
|
||||
**Culture debt:** Accumulating cultural compromises over time. "We'll address the toxic star performer later." Later compounds.
|
||||
- Fix: Act on culture violations faster than you think necessary. One tolerated bad behavior destroys what ten good behaviors build.
|
||||
|
||||
**Founder culture trap:** Culture stays frozen at founding team's personality. New hires assimilate or leave.
|
||||
- Fix: Explicitly evolve values as you scale. What worked at 10 people (move fast, ask forgiveness) may be destructive at 100 (we need process).
|
||||
|
||||
**Culture by osmosis:** Assuming culture transmits naturally. It did at 10 people. It doesn't at 50.
|
||||
- Fix: Make culture intentional. Document it. Teach it. Measure it. Reward it explicitly.
|
||||
|
||||
## Culture Integration with C-Suite
|
||||
|
||||
| When... | Culture Architect works with... | To... |
|
||||
|---------|---------------------------------|-------|
|
||||
| Hiring surge | CHRO | Ensure culture fit is measured, not guessed |
|
||||
| Org reorg | COO + CEO | Manage culture disruption from structure change |
|
||||
| M&A or partnership | CEO + COO | Detect and resolve culture clashes early |
|
||||
| Performance issues | CHRO | Separate culture fit from skill deficit |
|
||||
| Strategy pivot | CEO | Update values/behaviors that the pivot makes obsolete |
|
||||
| Rapid growth | All | Scale rituals before culture dilutes |
|
||||
|
||||
## Key Questions a Culture Architect Asks
|
||||
|
||||
- "Can you name the last person we fired for culture reasons? What did they do?"
|
||||
- "What behavior got your last promoted employee promoted? Is that in your values?"
|
||||
- "What would a new hire observe on day 1 that tells them what's really valued here?"
|
||||
- "What do we tolerate that we shouldn't? Who knows and does nothing?"
|
||||
- "How does a team lead in Berlin know what the culture is in Madrid?"
|
||||
|
||||
## Red Flags
|
||||
|
||||
- Values posted on the wall, never referenced in reviews or decisions
|
||||
- Star performers protected from cultural standards
|
||||
- Leaders who "don't have time" for culture rituals
|
||||
- New hires feeling the culture is "different than advertised"
|
||||
- No mechanism to raise cultural concerns safely
|
||||
- Culture survey results never shared with the team
|
||||
|
||||
## Detailed References
|
||||
- `references/culture-playbook.md` — Netflix analysis, survey design, ritual examples, M&A playbook
|
||||
- `templates/culture-code-template.md` — Culture code document template
|
||||
148
docs/skills/c-level-advisor/decision-logger.md
Normal file
148
docs/skills/c-level-advisor/decision-logger.md
Normal file
@@ -0,0 +1,148 @@
|
||||
---
|
||||
title: "Decision Logger"
|
||||
description: "Decision Logger - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Decision Logger
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `decision-logger` | **Source:** [`c-level-advisor/decision-logger/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/decision-logger/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Decision Logger
|
||||
|
||||
Two-layer memory system. Layer 1 stores everything. Layer 2 stores only what the founder approved. Future meetings read Layer 2 only — this prevents hallucinated consensus from past debates bleeding into new deliberations.
|
||||
|
||||
## Keywords
|
||||
decision log, memory, approved decisions, action items, board minutes, /cs:decisions, /cs:review, conflict detection, DO_NOT_RESURFACE
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
python scripts/decision_tracker.py --demo # See sample output
|
||||
python scripts/decision_tracker.py --summary # Overview + overdue
|
||||
python scripts/decision_tracker.py --overdue # Past-deadline actions
|
||||
python scripts/decision_tracker.py --conflicts # Contradiction detection
|
||||
python scripts/decision_tracker.py --owner "CTO" # Filter by owner
|
||||
python scripts/decision_tracker.py --search "pricing" # Search decisions
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | Effect |
|
||||
|---------|--------|
|
||||
| `/cs:decisions` | Last 10 approved decisions |
|
||||
| `/cs:decisions --all` | Full history |
|
||||
| `/cs:decisions --owner CMO` | Filter by owner |
|
||||
| `/cs:decisions --topic pricing` | Search by keyword |
|
||||
| `/cs:review` | Action items due within 7 days |
|
||||
| `/cs:review --overdue` | Items past deadline |
|
||||
|
||||
---
|
||||
|
||||
## Two-Layer Architecture
|
||||
|
||||
### Layer 1 — Raw Transcripts
|
||||
**Location:** `memory/board-meetings/YYYY-MM-DD-raw.md`
|
||||
- Full Phase 2 agent contributions, Phase 3 critique, Phase 4 synthesis
|
||||
- All debates, including rejected arguments
|
||||
- **NEVER auto-loaded.** Only on explicit founder request.
|
||||
- Archive after 90 days → `memory/board-meetings/archive/YYYY/`
|
||||
|
||||
### Layer 2 — Approved Decisions
|
||||
**Location:** `memory/board-meetings/decisions.md`
|
||||
- ONLY founder-approved decisions, action items, user corrections
|
||||
- **Loaded automatically in Phase 1 of every board meeting**
|
||||
- Append-only. Decisions are never deleted — only superseded.
|
||||
- Managed by Chief of Staff after Phase 5. Never written by agents directly.
|
||||
|
||||
---
|
||||
|
||||
## Decision Entry Format
|
||||
|
||||
```markdown
|
||||
## [YYYY-MM-DD] — [AGENDA ITEM TITLE]
|
||||
|
||||
**Decision:** [One clear statement of what was decided.]
|
||||
**Owner:** [One person or role — accountable for execution.]
|
||||
**Deadline:** [YYYY-MM-DD]
|
||||
**Review:** [YYYY-MM-DD]
|
||||
**Rationale:** [Why this over alternatives. 1-2 sentences.]
|
||||
|
||||
**User Override:** [If founder changed agent recommendation — what and why. Blank if not applicable.]
|
||||
|
||||
**Rejected:**
|
||||
- [Proposal] — [reason] [DO_NOT_RESURFACE]
|
||||
|
||||
**Action Items:**
|
||||
- [ ] [Action] — Owner: [name] — Due: [YYYY-MM-DD] — Review: [YYYY-MM-DD]
|
||||
|
||||
**Supersedes:** [DATE of previous decision on same topic, if any]
|
||||
**Superseded by:** [Filled in retroactively if overridden later]
|
||||
**Raw transcript:** memory/board-meetings/[DATE]-raw.md
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Conflict Detection
|
||||
|
||||
Before logging, Chief of Staff checks for:
|
||||
1. **DO_NOT_RESURFACE violations** — new decision matches a rejected proposal
|
||||
2. **Topic contradictions** — two active decisions on same topic with different conclusions
|
||||
3. **Owner conflicts** — same action assigned to different people in different decisions
|
||||
|
||||
When a conflict is found:
|
||||
```
|
||||
⚠️ DECISION CONFLICT
|
||||
New: [text]
|
||||
Conflicts with: [DATE] — [existing text]
|
||||
|
||||
Options: (1) Supersede old (2) Merge (3) Defer to founder
|
||||
```
|
||||
|
||||
**DO_NOT_RESURFACE enforcement:**
|
||||
```
|
||||
🚫 BLOCKED: "[Proposal]" was rejected on [DATE]. Reason: [reason].
|
||||
To reopen: founder must explicitly say "reopen [topic] from [DATE]".
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Logging Workflow (Post Phase 5)
|
||||
|
||||
1. Founder approves synthesis
|
||||
2. Write Layer 1 raw transcript → `YYYY-MM-DD-raw.md`
|
||||
3. Check conflicts against `decisions.md`
|
||||
4. Surface conflicts → wait for founder resolution
|
||||
5. Append approved entries to `decisions.md`
|
||||
6. Confirm: decisions logged, actions tracked, DO_NOT_RESURFACE flags added
|
||||
|
||||
---
|
||||
|
||||
## Marking Actions Complete
|
||||
|
||||
```markdown
|
||||
- [x] [Action] — Owner: [name] — Completed: [DATE] — Result: [one sentence]
|
||||
```
|
||||
|
||||
Never delete completed items. The history is the record.
|
||||
|
||||
---
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
memory/board-meetings/
|
||||
├── decisions.md # Layer 2: append-only, founder-approved
|
||||
├── YYYY-MM-DD-raw.md # Layer 1: full transcript per meeting
|
||||
└── archive/YYYY/ # Raw files after 90 days
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## References
|
||||
- `templates/decision-entry.md` — single entry template with field rules
|
||||
- `scripts/decision_tracker.py` — CLI parser, overdue tracker, conflict detector
|
||||
161
docs/skills/c-level-advisor/executive-mentor-board-prep.md
Normal file
161
docs/skills/c-level-advisor/executive-mentor-board-prep.md
Normal file
@@ -0,0 +1,161 @@
|
||||
---
|
||||
title: "/em:board-prep — Board Meeting Preparation"
|
||||
description: "/em:board-prep — Board Meeting Preparation - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# /em:board-prep — Board Meeting Preparation
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `board-prep` | **Source:** [`c-level-advisor/executive-mentor/skills/board-prep/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/executive-mentor/skills/board-prep/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Command:** `/em:board-prep <agenda>`
|
||||
|
||||
Prepare for the adversarial version of your board, not the friendly one. Every hard question they'll ask. Every number you need cold. The narrative that acknowledges weakness without losing the room.
|
||||
|
||||
---
|
||||
|
||||
## The Reality of Board Meetings
|
||||
|
||||
Your board members have seen 50+ companies. They've watched founders flinch at their own numbers, spin bad news as "learning opportunities," and present sanitized decks that hide what's actually happening.
|
||||
|
||||
They know when you're not being straight with them. The question isn't whether they'll ask the hard questions — it's whether you're ready for them.
|
||||
|
||||
The best board meetings aren't the ones where everything looks good. They're the ones where the CEO demonstrates they see reality clearly, have a plan, and can execute under pressure.
|
||||
|
||||
---
|
||||
|
||||
## The Preparation Framework
|
||||
|
||||
### Phase 1: Numbers Cold
|
||||
|
||||
Before the meeting, every number in your deck should live in your head, not just the slide.
|
||||
|
||||
**The numbers you must know without looking:**
|
||||
- Current MRR / ARR and month-over-month growth rate
|
||||
- Burn rate (monthly) and runway (months at current burn)
|
||||
- Headcount by department
|
||||
- CAC and LTV by channel / segment
|
||||
- Net Revenue Retention
|
||||
- Pipeline: value, conversion rate, average sales cycle
|
||||
- Churn: rate, top reasons, top churned accounts
|
||||
- Gross margin (product), net margin (company)
|
||||
- Key hiring positions open and time-to-fill
|
||||
|
||||
**Stress test yourself:** Can you answer "what's your burn?" without hesitation? "What's your churn rate by segment?" If you pause, you don't know it.
|
||||
|
||||
### Phase 2: Anticipate the Hard Questions
|
||||
|
||||
For every item on the agenda, generate the adversarial version of the question.
|
||||
|
||||
**Standard adversarial questions by topic:**
|
||||
|
||||
*Revenue performance:*
|
||||
- "You missed revenue by 20% this quarter. What specifically failed?"
|
||||
- "Is this a pipeline problem, a conversion problem, or a capacity problem?"
|
||||
- "If you missed because of one big deal, how dependent is your model on individual deals?"
|
||||
- "When do you project recovery and what are the leading indicators you're right?"
|
||||
|
||||
*Runway / burn:*
|
||||
- "At current burn you have N months. What's your plan if the next round takes 9 months?"
|
||||
- "What would you cut first if you had to extend runway by 6 months today?"
|
||||
- "Is there a scenario where you don't raise another round?"
|
||||
|
||||
*Product / roadmap:*
|
||||
- "You shipped X. What did customers actually do with it?"
|
||||
- "What did you kill this quarter and why?"
|
||||
- "Where are you behind on roadmap? What's slipping?"
|
||||
|
||||
*Team:*
|
||||
- "Who's at risk of leaving? How would that affect execution?"
|
||||
- "You've had 3 VP-level hires not work out. What pattern do you see?"
|
||||
- "Is the team the right team for this stage?"
|
||||
|
||||
*Competition:*
|
||||
- "Competitor Y just raised $50M. How does that change your position?"
|
||||
- "If they copy your best feature in 90 days, what's your moat?"
|
||||
|
||||
### Phase 3: Build the Narrative
|
||||
|
||||
The board meeting isn't a status update. It's a leadership demonstration.
|
||||
|
||||
**The structure that works:**
|
||||
|
||||
1. **Where we are (honest)** — Current state of business, the real number, not the smoothed one
|
||||
2. **What we learned** — What the data is telling us that we didn't know 90 days ago
|
||||
3. **What we got wrong** — Name it directly. Don't make them ask.
|
||||
4. **What we're doing about it** — Specific, dated, owned actions
|
||||
5. **What we need from this room** — Concrete ask. Not "support" — specific introductions, decisions, resources.
|
||||
|
||||
**The rule on bad news:** Never let the board be surprised. If a quarter went badly, they should know before the deck. A 5-sentence email 3 days before: "Revenue came in at $X vs $Y target. Here's what happened, here's what I'm doing, here's what I need from you."
|
||||
|
||||
### Phase 4: Adversarial Preparation
|
||||
|
||||
Do a mock board meeting. Have someone play the hardest director you have.
|
||||
|
||||
**The simulation:**
|
||||
- Present your deck as you would
|
||||
- The mock director asks every uncomfortable question
|
||||
- You answer without referring to the deck
|
||||
- After: note every question that made you pause or feel defensive
|
||||
|
||||
**The questions that made you defensive = the questions you need to prepare for.**
|
||||
|
||||
### Phase 5: Director-by-Director Prep
|
||||
|
||||
Not all board members want the same thing from a meeting.
|
||||
|
||||
**For each director, know:**
|
||||
- Their primary concern right now (usually tied to their investment thesis)
|
||||
- The metric they watch most closely
|
||||
- What would make them lose confidence in you
|
||||
- What they've said in the last meeting that you should address
|
||||
|
||||
**Common director types:**
|
||||
- **The operator** — wants to know what's breaking and who owns fixing it
|
||||
- **The financial investor** — focused on path to profitability or next raise
|
||||
- **The strategic investor** — worried about competitive position and moat
|
||||
- **The independent** — watching governance, team dynamics, and your judgment
|
||||
|
||||
---
|
||||
|
||||
## Pre-Meeting Checklist
|
||||
|
||||
**48 hours before:**
|
||||
- [ ] All numbers verified against source systems (not last week's export)
|
||||
- [ ] Deck reviewed for internal consistency
|
||||
- [ ] Pre-read sent to board (deck + 1-page brief on key topics)
|
||||
- [ ] One-on-ones done with any director likely to have concerns
|
||||
- [ ] 3 hardest questions you expect — rehearsed out loud
|
||||
|
||||
**Day of meeting:**
|
||||
- [ ] Agenda with time allocations distributed
|
||||
- [ ] Know the ask for each agenda item (decision needed, input wanted, FYI)
|
||||
- [ ] Materials to leave behind prepared
|
||||
- [ ] Follow-up action template ready
|
||||
|
||||
---
|
||||
|
||||
## During the Meeting
|
||||
|
||||
**What the board is watching:**
|
||||
- Do you own the bad news or deflect it?
|
||||
- Are you defending a narrative or sharing reality?
|
||||
- Do you know your numbers or do you look things up?
|
||||
- When challenged, do you get defensive or engage?
|
||||
- Do you know what you don't know?
|
||||
|
||||
**The single best thing you can do:** Name the hard thing before they do. "I want to address the revenue miss directly. Here's what happened, here's what I should have caught earlier, here's what changes."
|
||||
|
||||
---
|
||||
|
||||
## After the Meeting
|
||||
|
||||
Within 24 hours:
|
||||
- Send action items with owners and dates
|
||||
- Send any data you promised but didn't have
|
||||
- Note the questions that came up you weren't ready for
|
||||
- Schedule follow-up with any director who seemed unsatisfied
|
||||
|
||||
The next board prep starts now.
|
||||
186
docs/skills/c-level-advisor/executive-mentor-challenge.md
Normal file
186
docs/skills/c-level-advisor/executive-mentor-challenge.md
Normal file
@@ -0,0 +1,186 @@
|
||||
---
|
||||
title: "/em:challenge — Pre-Mortem Plan Analysis"
|
||||
description: "/em:challenge — Pre-Mortem Plan Analysis - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# /em:challenge — Pre-Mortem Plan Analysis
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `challenge` | **Source:** [`c-level-advisor/executive-mentor/skills/challenge/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/executive-mentor/skills/challenge/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Command:** `/em:challenge <plan>`
|
||||
|
||||
Systematically finds weaknesses in any plan before reality does. Not to kill the plan — to make it survive contact with reality.
|
||||
|
||||
---
|
||||
|
||||
## The Core Idea
|
||||
|
||||
Most plans fail for predictable reasons. Not bad luck — bad assumptions. Overestimated demand. Underestimated complexity. Dependencies nobody questioned. Timing that made sense in a spreadsheet but not in the real world.
|
||||
|
||||
The pre-mortem technique: **imagine it's 12 months from now and this plan failed spectacularly. Now work backwards. Why?**
|
||||
|
||||
That's not pessimism. It's how you build something that doesn't collapse.
|
||||
|
||||
---
|
||||
|
||||
## When to Run a Challenge
|
||||
|
||||
- Before committing significant resources to a plan
|
||||
- Before presenting to the board or investors
|
||||
- When you notice you're only hearing positive feedback about the plan
|
||||
- When the plan requires multiple external dependencies to align
|
||||
- When there's pressure to move fast and "figure it out later"
|
||||
- When you feel excited about the plan (excitement is a signal to scrutinize harder)
|
||||
|
||||
---
|
||||
|
||||
## The Challenge Framework
|
||||
|
||||
### Step 1: Extract Core Assumptions
|
||||
Before you can test a plan, you need to surface everything it assumes to be true.
|
||||
|
||||
For each section of the plan, ask:
|
||||
- What has to be true for this to work?
|
||||
- What are we assuming about customer behavior?
|
||||
- What are we assuming about competitor response?
|
||||
- What are we assuming about our own execution capability?
|
||||
- What external factors does this depend on?
|
||||
|
||||
**Common assumption categories:**
|
||||
- **Market assumptions** — size, growth rate, customer willingness to pay, buying cycle
|
||||
- **Execution assumptions** — team capacity, velocity, no major hires needed
|
||||
- **Customer assumptions** — they have the problem, they know they have it, they'll pay to solve it
|
||||
- **Competitive assumptions** — incumbents won't respond, no new entrant, moat holds
|
||||
- **Financial assumptions** — burn rate, revenue timing, CAC, LTV ratios
|
||||
- **Dependency assumptions** — partner will deliver, API won't change, regulations won't shift
|
||||
|
||||
### Step 2: Rate Each Assumption
|
||||
|
||||
For every assumption extracted, rate it on two dimensions:
|
||||
|
||||
**Confidence level (how sure are you this is true):**
|
||||
- **High** — verified with data, customer conversations, market research
|
||||
- **Medium** — directionally right but not validated
|
||||
- **Low** — plausible but untested
|
||||
- **Unknown** — we simply don't know
|
||||
|
||||
**Impact if wrong (what happens if this assumption fails):**
|
||||
- **Critical** — plan fails entirely
|
||||
- **High** — major delay or cost overrun
|
||||
- **Medium** — significant rework required
|
||||
- **Low** — manageable adjustment
|
||||
|
||||
### Step 3: Map Vulnerabilities
|
||||
|
||||
The matrix of Low/Unknown confidence × Critical/High impact = your highest-risk assumptions.
|
||||
|
||||
**Vulnerability = Low confidence + High impact**
|
||||
|
||||
These are not problems to ignore. They're the bets you're making. The question is: are you making them consciously?
|
||||
|
||||
### Step 4: Find the Dependency Chain
|
||||
|
||||
Many plans fail not because any single assumption is wrong, but because multiple assumptions have to be right simultaneously.
|
||||
|
||||
Map the chain:
|
||||
- Does assumption B depend on assumption A being true first?
|
||||
- If the first thing goes wrong, how many downstream things break?
|
||||
- What's the critical path? What has zero slack?
|
||||
|
||||
### Step 5: Test the Reversibility
|
||||
|
||||
For each critical vulnerability: if this assumption turns out to be wrong at month 3, what do you do?
|
||||
|
||||
- Can you pivot?
|
||||
- Can you cut scope?
|
||||
- Is money already spent?
|
||||
- Are commitments already made?
|
||||
|
||||
The less reversible, the more rigorously you need to validate before committing.
|
||||
|
||||
---
|
||||
|
||||
## Output Format
|
||||
|
||||
**Challenge Report: [Plan Name]**
|
||||
|
||||
```
|
||||
CORE ASSUMPTIONS (extracted)
|
||||
1. [Assumption] — Confidence: [H/M/L/?] — Impact if wrong: [Critical/High/Medium/Low]
|
||||
2. ...
|
||||
|
||||
VULNERABILITY MAP
|
||||
Critical risks (act before proceeding):
|
||||
• [#N] [Assumption] — WHY it might be wrong — WHAT breaks if it is
|
||||
|
||||
High risks (validate before scaling):
|
||||
• ...
|
||||
|
||||
DEPENDENCY CHAIN
|
||||
[Assumption A] → depends on → [Assumption B] → which enables → [Assumption C]
|
||||
Weakest link: [X] — if this breaks, [Y] and [Z] also fail
|
||||
|
||||
REVERSIBILITY ASSESSMENT
|
||||
• Reversible bets: [list]
|
||||
• Irreversible commitments: [list — treat with extreme care]
|
||||
|
||||
KILL SWITCHES
|
||||
What would have to be true at [30/60/90 days] to continue vs. kill/pivot?
|
||||
• Continue if: ...
|
||||
• Kill/pivot if: ...
|
||||
|
||||
HARDENING ACTIONS
|
||||
1. [Specific validation to do before proceeding]
|
||||
2. [Alternative approach to consider]
|
||||
3. [Contingency to build into the plan]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Challenge Patterns by Plan Type
|
||||
|
||||
### Product Roadmap
|
||||
- Are we building what customers will pay for, or what they said they wanted?
|
||||
- Does the velocity estimate account for real team capacity (not theoretical)?
|
||||
- What happens if the anchor feature takes 3× longer than estimated?
|
||||
- Who owns decisions when requirements conflict?
|
||||
|
||||
### Go-to-Market Plan
|
||||
- What's the actual ICP conversion rate, not the hoped-for one?
|
||||
- How many touches to close, and do you have the sales capacity for that?
|
||||
- What happens if the first 10 deals take 3 months instead of 1?
|
||||
- Is "land and expand" a real motion or a hope?
|
||||
|
||||
### Hiring Plan
|
||||
- What happens if the key hire takes 4 months to find, not 6 weeks?
|
||||
- Is the plan dependent on retaining specific people who might leave?
|
||||
- Does the plan account for ramp time (usually 3–6 months before full productivity)?
|
||||
- What's the burn impact if headcount leads revenue by 6 months?
|
||||
|
||||
### Fundraising Plan
|
||||
- What's your fallback if the lead investor passes?
|
||||
- Have you modeled the timeline if it takes 6 months, not 3?
|
||||
- What's your runway at current burn if the round closes at the low end?
|
||||
- What assumptions break if you raise 50% of the target amount?
|
||||
|
||||
---
|
||||
|
||||
## The Hardest Questions
|
||||
|
||||
These are the ones people skip:
|
||||
- "What's the bear case, not the base case?"
|
||||
- "If this exact plan was run by a team we don't trust, would it work?"
|
||||
- "What are we not saying out loud because it's uncomfortable?"
|
||||
- "Who has incentives to make this plan sound better than it is?"
|
||||
- "What would an enemy of this plan attack first?"
|
||||
|
||||
---
|
||||
|
||||
## Deliverable
|
||||
|
||||
The output of `/em:challenge` is not permission to stop. It's a vulnerability map. Now you can make conscious decisions: validate the risky assumptions, hedge the critical ones, or accept the bets you're making knowingly.
|
||||
|
||||
Unknown risks are dangerous. Known risks are manageable.
|
||||
162
docs/skills/c-level-advisor/executive-mentor-hard-call.md
Normal file
162
docs/skills/c-level-advisor/executive-mentor-hard-call.md
Normal file
@@ -0,0 +1,162 @@
|
||||
---
|
||||
title: "/em:hard-call — Framework for Decisions With No Good Options"
|
||||
description: "/em:hard-call — Framework for Decisions With No Good Options - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# /em:hard-call — Framework for Decisions With No Good Options
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `hard-call` | **Source:** [`c-level-advisor/executive-mentor/skills/hard-call/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/executive-mentor/skills/hard-call/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Command:** `/em:hard-call <decision>`
|
||||
|
||||
For the decisions that keep you up at 3am. Firing a co-founder. Laying off 20% of the team. Killing a product that customers love. Pivoting. Shutting down.
|
||||
|
||||
These decisions don't have a right answer. They have a less wrong answer. This framework helps you find it.
|
||||
|
||||
---
|
||||
|
||||
## Why These Decisions Are Hard
|
||||
|
||||
Not because the data is unclear. Often, the data is clear. They're hard because:
|
||||
|
||||
1. **Real people are affected** — someone loses a job, a relationship ends, a team is hurt
|
||||
2. **You've been avoiding the decision** — which means the problem is already worse than it was
|
||||
3. **Irreversibility** — unlike most business decisions, you can't undo this easily
|
||||
4. **You have skin in the game** — your judgment about the right call is clouded by your feelings about it
|
||||
|
||||
The longer you avoid a hard call, the worse the situation usually gets. The company that needed a 10% cut 6 months ago now needs a 25% cut. The co-founder conversation that should have happened at month 4 is happening at month 14.
|
||||
|
||||
**Most hard decisions are late decisions.**
|
||||
|
||||
---
|
||||
|
||||
## The Framework
|
||||
|
||||
### Step 1: The Reversibility Test
|
||||
|
||||
The most important question first: **can you undo this?**
|
||||
|
||||
- **Reversible** — try it, learn, adjust (fire the vendor, kill the feature, change the strategy)
|
||||
- **Partially reversible** — painful to undo but possible (restructure, change co-founder roles)
|
||||
- **Irreversible** — cannot be undone (layoff a person, shut down a product with customer lock-in, close a legal entity)
|
||||
|
||||
For irreversible decisions, the bar for certainty is higher. You must do more due diligence before acting. Not because you might be wrong — but because you can't take it back.
|
||||
|
||||
**If you're treating a reversible decision like it's irreversible, you're avoiding it.**
|
||||
|
||||
### Step 2: The 10/10/10 Framework
|
||||
|
||||
Ask three questions about each option:
|
||||
|
||||
- **10 minutes from now**: How will you feel immediately after making this decision?
|
||||
- **10 months from now**: What will the impact be? Will the problem be solved?
|
||||
- **10 years from now**: When you look back, will this have been the right call?
|
||||
|
||||
The 10-minute feeling is usually the least reliable guide. The 10-year view usually clarifies what the right call actually is.
|
||||
|
||||
**Most hard decisions look obvious at 10 years. The question is whether you can tolerate the 10-minute pain.**
|
||||
|
||||
### Step 3: The Andy Grove Test
|
||||
|
||||
Andy Grove's test for strategic decisions: "If we got replaced tomorrow and a new CEO came in, what would they do?"
|
||||
|
||||
A fresh set of eyes, no emotional investment in the current path, no sunk cost. What's the obvious right call from the outside?
|
||||
|
||||
If the answer is clear to an outsider, the question becomes: why haven't you done it yet?
|
||||
|
||||
### Step 4: Stakeholder Impact Mapping
|
||||
|
||||
For each option, map who's affected and how:
|
||||
|
||||
| Stakeholder | Option A Impact | Option B Impact | Their reaction |
|
||||
|-------------|----------------|----------------|----------------|
|
||||
| Affected employees | | | |
|
||||
| Remaining team | | | |
|
||||
| Customers | | | |
|
||||
| Investors | | | |
|
||||
| You | | | |
|
||||
|
||||
This isn't about finding the option that hurts nobody — there isn't one. It's about understanding the full picture before you decide.
|
||||
|
||||
### Step 5: The Pre-Announcement Test
|
||||
|
||||
Before making the decision: write the announcement. The email to the team, the message to the customer, the conversation you'll have.
|
||||
|
||||
**If you can't write that announcement, you're not ready to make the decision.**
|
||||
|
||||
Writing it forces you to confront the reality of what you're doing. It also surfaces whether your reasoning holds under examination. "We're making this change because…" — does that sentence ring true?
|
||||
|
||||
### Step 6: The Communication Plan
|
||||
|
||||
Hard decisions almost always get harder if communication is bad. The decision itself is not the only thing that matters — how it's done matters enormously.
|
||||
|
||||
For every hard call, plan:
|
||||
- **Who needs to know first** (the person directly affected, before anyone else)
|
||||
- **How you'll tell them** (in person when possible, never via email for personal impact)
|
||||
- **What you'll say** (honest, direct, compassionate — see `references/hard_things.md`)
|
||||
- **What they can ask** (be ready for every question)
|
||||
- **What comes next** (give them a clear picture of what happens after)
|
||||
|
||||
---
|
||||
|
||||
## Decision-Specific Frameworks
|
||||
|
||||
### Firing a Co-Founder
|
||||
See `references/hard_things.md — Co-Founder Conflicts` for full framework.
|
||||
|
||||
Key questions to answer first:
|
||||
- Is this a performance problem or a values/culture problem? (Different conversations)
|
||||
- Have you been explicit — not hinted, but direct — about the problem?
|
||||
- What does the cap table look like and what are the legal implications?
|
||||
- Is there a role that works better for them, or is this a full exit?
|
||||
- Who needs to know (board, team, investors) and in what order?
|
||||
|
||||
**The rule:** If you've been thinking about this for more than 3 months, you already know the answer. The question is when, not whether.
|
||||
|
||||
### Layoffs
|
||||
Key questions:
|
||||
- Is this a one-time reset or the beginning of a longer decline? (One reset is recoverable. Serial layoffs kill culture.)
|
||||
- Are you cutting deep enough? (Insufficient layoffs are worse than no layoffs — two rounds destroys trust.)
|
||||
- Who owns the announcement and is it direct and honest?
|
||||
- What's the severance and is it fair?
|
||||
- How do you prevent the best people from leaving after?
|
||||
|
||||
**The rule:** Cut once, cut deep, cut with dignity. Uncertainty is worse than clarity.
|
||||
|
||||
### Pivoting
|
||||
Key questions:
|
||||
- Is this a true pivot (new direction) or an optimization (same direction, different tactic)?
|
||||
- What are you keeping and what are you abandoning?
|
||||
- Do you have evidence the new direction works, or are you running from failure?
|
||||
- How do you tell current customers who bought the old vision?
|
||||
- What does this do to the board's confidence?
|
||||
|
||||
**The rule:** Pivots should be pulled by evidence of new opportunity, not pushed by failure of the current path.
|
||||
|
||||
### Killing a Product Line
|
||||
Key questions:
|
||||
- What happens to customers currently using it?
|
||||
- What's the migration path?
|
||||
- What do the people who built it do?
|
||||
- Is "kill it" the right call or is "sell it" or "spin it out" better?
|
||||
- What's the narrative — internally and externally?
|
||||
|
||||
---
|
||||
|
||||
## The Avoiding-It Test
|
||||
|
||||
You know you've been avoiding a hard call if:
|
||||
- You've thought about it every week for more than a month
|
||||
- You're hoping the situation will "resolve itself"
|
||||
- You're waiting for more data that you'll never feel is enough
|
||||
- You've had the conversation in your head many times but not in real life
|
||||
- Other people around you have noticed the problem
|
||||
|
||||
**The cost of delay is almost always higher than the cost of the decision.**
|
||||
|
||||
Every month you wait, the problem compounds. The co-founder who's not working out becomes more entrenched. The product line that needs to die consumes more resources. The person who needs to be let go affects the people around them.
|
||||
|
||||
Make the call. Make it clearly. Make it with dignity.
|
||||
198
docs/skills/c-level-advisor/executive-mentor-postmortem.md
Normal file
198
docs/skills/c-level-advisor/executive-mentor-postmortem.md
Normal file
@@ -0,0 +1,198 @@
|
||||
---
|
||||
title: "/em:postmortem — Honest Analysis of What Went Wrong"
|
||||
description: "/em:postmortem — Honest Analysis of What Went Wrong - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# /em:postmortem — Honest Analysis of What Went Wrong
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `postmortem` | **Source:** [`c-level-advisor/executive-mentor/skills/postmortem/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/executive-mentor/skills/postmortem/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Command:** `/em:postmortem <event>`
|
||||
|
||||
Not blame. Understanding. The failed deal, the missed quarter, the feature that flopped, the hire that didn't work out. What actually happened, why, and what changes as a result.
|
||||
|
||||
---
|
||||
|
||||
## Why Most Post-Mortems Fail
|
||||
|
||||
They become one of two things:
|
||||
|
||||
**The blame session** — someone gets scapegoated, defensive walls go up, actual causes don't get examined, and the same problem happens again in a different form.
|
||||
|
||||
**The whitewash** — "We learned a lot, we're going to do better, here are 12 vague action items." Nothing changes. Same problem, different quarter.
|
||||
|
||||
A real post-mortem is neither. It's a rigorous investigation into a system failure. Not "whose fault was it" but "what conditions made this outcome predictable in hindsight?"
|
||||
|
||||
**The purpose:** extract the maximum learning value from a failure so you can prevent recurrence and improve the system.
|
||||
|
||||
---
|
||||
|
||||
## The Framework
|
||||
|
||||
### Step 1: Define the Event Precisely
|
||||
|
||||
Before analysis: describe exactly what happened.
|
||||
|
||||
- What was the expected outcome?
|
||||
- What was the actual outcome?
|
||||
- When was the gap first visible?
|
||||
- What was the impact (financial, operational, reputational)?
|
||||
|
||||
Precision matters. "We missed Q3 revenue" is not precise enough. "We closed $420K in new ARR vs $680K target — a $260K miss driven primarily by three deals that slipped to Q4 and one deal that was lost to a competitor" is precise.
|
||||
|
||||
### Step 2: The 5 Whys — Done Properly
|
||||
|
||||
The goal: get from **what happened** (the symptom) to **why it happened** (the root cause).
|
||||
|
||||
Standard bad 5 Whys:
|
||||
- Why did we miss revenue? Because deals slipped.
|
||||
- Why did deals slip? Because the sales cycle was longer than expected.
|
||||
- Why? Because the customer buying process is complex.
|
||||
- Why? Because we're selling to enterprise.
|
||||
- Why? That's just how enterprise sales works.
|
||||
|
||||
→ Conclusion: Nothing to do. It's just enterprise.
|
||||
|
||||
Real 5 Whys:
|
||||
- Why did we miss revenue? Three deals slipped out of quarter.
|
||||
- Why did those deals slip? None of them had identified a champion with budget authority.
|
||||
- Why did we progress deals without a champion? Our qualification criteria didn't require it.
|
||||
- Why didn't our qualification criteria require it? When we built the criteria 8 months ago, we were in SMB, not enterprise.
|
||||
- Why haven't we updated qualification criteria as ICP shifted? No owner, no process for criteria review.
|
||||
|
||||
→ Root cause: Qualification criteria outdated, no owner, no review process.
|
||||
→ Fix: Update criteria, assign owner, add quarterly review.
|
||||
|
||||
**The test for a good root cause:** Could you prevent recurrence with a specific, concrete change? If yes, you've found something real.
|
||||
|
||||
### Step 3: Distinguish Contributing Factors from Root Cause
|
||||
|
||||
Most events have multiple contributing factors. Not all are root causes.
|
||||
|
||||
**Contributing factor:** Made it worse, but isn't the core reason. If removed, the outcome might have been different — but the same class of problem would recur.
|
||||
|
||||
**Root cause:** The fundamental condition that made the outcome probable. Fix this, and this class of problem doesn't recur.
|
||||
|
||||
Example — failed hire:
|
||||
- Contributing factors: rushed process, reference checks skipped, team under pressure to staff up
|
||||
- Root cause: No defined competency framework, so interview process varied by who happened to conduct interviews
|
||||
|
||||
**The distinction matters.** If you address only contributing factors, you'll have a different-looking but structurally identical failure next time.
|
||||
|
||||
### Step 4: Identify the Warning Signs That Were Ignored
|
||||
|
||||
Every failure has precursors. In hindsight, they're obvious. The value of this step is making them obvious prospectively.
|
||||
|
||||
Ask:
|
||||
- At what point was the negative outcome predictable?
|
||||
- What signals were visible at that point?
|
||||
- Who saw them? What happened when they raised them?
|
||||
- Why weren't they acted on?
|
||||
|
||||
**Common patterns:**
|
||||
- Signal was raised but dismissed by a senior person
|
||||
- Signal wasn't raised because nobody felt safe saying it
|
||||
- Signal was seen but no one had clear ownership to act on it
|
||||
- Data was available but nobody was looking at it
|
||||
- The team was too optimistic to take negative signals seriously
|
||||
|
||||
This step is particularly important for systemic issues — "we didn't feel safe raising the concern" is a much deeper root cause than "the deal qualification was off."
|
||||
|
||||
### Step 5: Distinguish What Was in Control vs. Out of Control
|
||||
|
||||
Some failures happen despite correct decisions. Some happen because of incorrect decisions. Knowing the difference prevents both overcorrection and undercorrection.
|
||||
|
||||
- **In control:** Process, criteria, team capability, resource allocation, decisions made
|
||||
- **Out of control:** Market conditions, customer decisions, competitor actions, macro events
|
||||
|
||||
For things out of control: what can be done to be more resilient to similar events?
|
||||
For things in control: what specifically needs to change?
|
||||
|
||||
**Warning:** "It was outside our control" is sometimes used to avoid accountability. Be rigorous.
|
||||
|
||||
### Step 6: Build the Change Register
|
||||
|
||||
Every post-mortem ends with a change register — specific commitments, owned and dated.
|
||||
|
||||
**Bad action items:**
|
||||
- "We'll improve our qualification process"
|
||||
- "Communication will be better"
|
||||
- "We'll be more rigorous about forecasting"
|
||||
|
||||
**Good action items:**
|
||||
- "Ravi owns rewriting qualification criteria by March 15 to include champion identification as hard requirement. New criteria reviewed in weekly sales standup starting March 22."
|
||||
- "By March 10, Elena adds deal-slippage risk flag to CRM for any open opportunity >60 days without a product demo"
|
||||
- "Maria runs a 30-min retrospective with enterprise sales team every 6 weeks starting April 1, reviews win/loss data"
|
||||
|
||||
**For each action:**
|
||||
- What exactly is changing?
|
||||
- Who owns it?
|
||||
- By when?
|
||||
- How will you verify it worked?
|
||||
|
||||
### Step 7: Verification Date
|
||||
|
||||
The most commonly skipped step. Post-mortems are useless if nobody checks whether the changes actually happened and actually worked.
|
||||
|
||||
Set a verification date: "We'll review whether qualification criteria have been updated and whether deal slippage rate has improved at the June board meeting."
|
||||
|
||||
Without this, post-mortems are theater.
|
||||
|
||||
---
|
||||
|
||||
## Post-Mortem Output Format
|
||||
|
||||
```
|
||||
EVENT: [Name and date]
|
||||
EXPECTED: [What was supposed to happen]
|
||||
ACTUAL: [What happened]
|
||||
IMPACT: [Quantified]
|
||||
|
||||
TIMELINE
|
||||
[Date]: [What happened or was visible]
|
||||
[Date]: ...
|
||||
|
||||
5 WHYS
|
||||
1. [Why did X happen?] → Because [Y]
|
||||
2. [Why did Y happen?] → Because [Z]
|
||||
3. [Why did Z happen?] → Because [A]
|
||||
4. [Why did A happen?] → Because [B]
|
||||
5. [Why did B happen?] → Because [ROOT CAUSE]
|
||||
|
||||
ROOT CAUSE: [One clear sentence]
|
||||
|
||||
CONTRIBUTING FACTORS
|
||||
• [Factor] — how it contributed
|
||||
• [Factor] — how it contributed
|
||||
|
||||
WARNING SIGNS MISSED
|
||||
• [Signal visible at what date] — why it wasn't acted on
|
||||
|
||||
WHAT WAS IN CONTROL: [List]
|
||||
WHAT WASN'T: [List]
|
||||
|
||||
CHANGE REGISTER
|
||||
| Action | Owner | Due Date | Verification |
|
||||
|--------|-------|----------|-------------|
|
||||
| [Specific change] | [Name] | [Date] | [How to verify] |
|
||||
|
||||
VERIFICATION DATE: [Date of check-in]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## The Tone of Good Post-Mortems
|
||||
|
||||
Blame is cheap. Understanding is hard.
|
||||
|
||||
The goal isn't to establish that someone made a mistake. The goal is to understand why the system produced that outcome — so the system can be improved.
|
||||
|
||||
"The salesperson didn't qualify the deal properly" is blame.
|
||||
"Our qualification framework hadn't been updated when we moved upmarket, and no one owned keeping it current" is understanding.
|
||||
|
||||
The first version fires or shames someone. The second version builds a more resilient organization.
|
||||
|
||||
Both might be true simultaneously. The distinction is: which one actually prevents recurrence?
|
||||
209
docs/skills/c-level-advisor/executive-mentor-stress-test.md
Normal file
209
docs/skills/c-level-advisor/executive-mentor-stress-test.md
Normal file
@@ -0,0 +1,209 @@
|
||||
---
|
||||
title: "/em:stress-test — Business Assumption Stress Testing"
|
||||
description: "/em:stress-test — Business Assumption Stress Testing - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# /em:stress-test — Business Assumption Stress Testing
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `stress-test` | **Source:** [`c-level-advisor/executive-mentor/skills/stress-test/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/executive-mentor/skills/stress-test/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Command:** `/em:stress-test <assumption>`
|
||||
|
||||
Take any business assumption and break it before the market does. Revenue projections. Market size. Competitive moat. Hiring velocity. Customer retention.
|
||||
|
||||
---
|
||||
|
||||
## Why Most Assumptions Are Wrong
|
||||
|
||||
Founders are optimists by nature. That's a feature — you need optimism to start something from nothing. But it becomes a liability when assumptions in business models get inflated by the same optimism that got you started.
|
||||
|
||||
**The most dangerous assumptions are the ones everyone agrees on.**
|
||||
|
||||
When the whole team believes the $50M market is real, when every investor call goes well so you assume the round will close, when your model shows $2M ARR by December and nobody questions it — that's when you're most exposed.
|
||||
|
||||
Stress testing isn't pessimism. It's calibration.
|
||||
|
||||
---
|
||||
|
||||
## The Stress-Test Methodology
|
||||
|
||||
### Step 1: Isolate the Assumption
|
||||
|
||||
State it explicitly. Not "our market is large" but "the total addressable market for B2B spend management software in German SMEs is €2.3B."
|
||||
|
||||
The more specific the assumption, the more testable it is. Vague assumptions are unfalsifiable — and therefore useless.
|
||||
|
||||
**Common assumption types:**
|
||||
- **Market size** — TAM, SAM, SOM; growth rate; customer segments
|
||||
- **Customer behavior** — willingness to pay, churn, expansion, referrals
|
||||
- **Revenue model** — conversion rates, deal size, sales cycle, CAC
|
||||
- **Competitive position** — moat durability, competitor response speed, switching cost
|
||||
- **Execution** — team velocity, hire timeline, product timeline, operational scaling
|
||||
- **Macro** — regulatory environment, economic conditions, technology availability
|
||||
|
||||
### Step 2: Find the Counter-Evidence
|
||||
|
||||
For every assumption, actively search for evidence that it's wrong.
|
||||
|
||||
Ask:
|
||||
- Who has tried this and failed?
|
||||
- What data contradicts this assumption?
|
||||
- What does the bear case look like?
|
||||
- If a smart skeptic was looking at this, what would they point to?
|
||||
- What's the base rate for assumptions like this?
|
||||
|
||||
**Sources of counter-evidence:**
|
||||
- Comparable companies that failed in adjacent markets
|
||||
- Customer churn data from similar businesses
|
||||
- Historical accuracy of similar forecasts
|
||||
- Industry reports with conflicting data
|
||||
- What competitors who tried this found
|
||||
|
||||
The goal isn't to find a reason to stop — it's to surface what you don't know.
|
||||
|
||||
### Step 3: Model the Downside
|
||||
|
||||
Most plans model the base case and the upside. Stress testing means modeling the downside explicitly.
|
||||
|
||||
**For quantitative assumptions (revenue, growth, conversion):**
|
||||
|
||||
| Scenario | Assumption Value | Probability | Impact |
|
||||
|----------|-----------------|-------------|--------|
|
||||
| Base case | [Original value] | ? | |
|
||||
| Bear case | -30% | ? | |
|
||||
| Stress case | -50% | ? | |
|
||||
| Catastrophic | -80% | ? | |
|
||||
|
||||
Key question at each level: **Does the business survive? Does the plan make sense?**
|
||||
|
||||
**For qualitative assumptions (moat, product-market fit, team capability):**
|
||||
|
||||
- What's the earliest signal this assumption is wrong?
|
||||
- How long would it take you to notice?
|
||||
- What happens between when it breaks and when you detect it?
|
||||
|
||||
### Step 4: Calculate Sensitivity
|
||||
|
||||
Some assumptions matter more than others. Sensitivity analysis answers: **if this one assumption changes, how much does the outcome change?**
|
||||
|
||||
Example:
|
||||
- If CAC doubles, how does that change runway?
|
||||
- If churn goes from 5% to 10%, how does that change NRR in 24 months?
|
||||
- If the deal cycle is 6 months instead of 3, how does that affect Q3 revenue?
|
||||
|
||||
High sensitivity = the assumption is a key lever. Wrong = big problem.
|
||||
|
||||
### Step 5: Propose the Hedge
|
||||
|
||||
For every high-risk assumption, there should be a hedge:
|
||||
|
||||
- **Validation hedge** — test it before betting on it (pilot, customer conversation, small experiment)
|
||||
- **Contingency hedge** — if it's wrong, what's plan B?
|
||||
- **Early warning hedge** — what's the leading indicator that would tell you it's breaking before it's too late to act?
|
||||
|
||||
---
|
||||
|
||||
## Stress Test Patterns by Assumption Type
|
||||
|
||||
### Revenue Projections
|
||||
|
||||
**Common failures:**
|
||||
- Bottom-up model assumes 100% of pipeline converts
|
||||
- Doesn't account for deal slippage, churn, seasonality
|
||||
- New channel assumed to work before tested at scale
|
||||
|
||||
**Stress questions:**
|
||||
- What's your actual historical win rate on pipeline?
|
||||
- If your top 3 deals slip to next quarter, what happens to the number?
|
||||
- What's the model look like if your new sales rep takes 4 months to ramp, not 2?
|
||||
- If expansion revenue doesn't materialize, what's the growth rate?
|
||||
|
||||
**Test:** Build the revenue model from historical win rates, not hoped-for ones.
|
||||
|
||||
### Market Size
|
||||
|
||||
**Common failures:**
|
||||
- TAM calculated top-down from industry reports without bottoms-up validation
|
||||
- Conflating total market with serviceable market
|
||||
- Assuming 100% of SAM is reachable
|
||||
|
||||
**Stress questions:**
|
||||
- How many companies in your ICP actually exist and can you name them?
|
||||
- What's your serviceable obtainable market in year 1-3?
|
||||
- What percentage of your ICP is currently spending on any solution to this problem?
|
||||
- What does "winning" look like and what market share does that require?
|
||||
|
||||
**Test:** Build a list of target accounts. Count them. Multiply by ACV. That's your SAM.
|
||||
|
||||
### Competitive Moat
|
||||
|
||||
**Common failures:**
|
||||
- Moat is technology advantage that can be built in 6 months
|
||||
- Network effects that haven't yet materialized
|
||||
- Data advantage that requires scale you don't have
|
||||
|
||||
**Stress questions:**
|
||||
- If a well-funded competitor copied your best feature in 90 days, what do customers do?
|
||||
- What's your retention rate among customers who have tried alternatives?
|
||||
- Is the moat real today or theoretical at scale?
|
||||
- What would it cost a competitor to reach feature parity?
|
||||
|
||||
**Test:** Ask churned customers why they left and whether a competitor could have kept them.
|
||||
|
||||
### Hiring Plan
|
||||
|
||||
**Common failures:**
|
||||
- Time-to-hire assumes standard recruiting cycle, not current market
|
||||
- Ramp time not modeled (3-6 months before full productivity)
|
||||
- Key hire dependency: plan only works if specific person is hired
|
||||
|
||||
**Stress questions:**
|
||||
- What happens if the VP Sales hire takes 5 months, not 2?
|
||||
- What does execution look like if you only hire 70% of planned headcount?
|
||||
- Which single person, if they left tomorrow, would most damage the plan?
|
||||
- Is the plan achievable with current team if hiring freezes?
|
||||
|
||||
**Test:** Model the plan with 0 net new hires. What still works?
|
||||
|
||||
### Competitive Response
|
||||
|
||||
**Common failures:**
|
||||
- Assumes incumbents won't respond (they will if you're winning)
|
||||
- Underestimates speed of response
|
||||
- Doesn't model resource asymmetry
|
||||
|
||||
**Stress questions:**
|
||||
- If the market leader copies your product in 6 months, how does pricing change?
|
||||
- What's your response if a competitor raises $30M to attack your space?
|
||||
- Which of your customers have vendor relationships with your competitors?
|
||||
|
||||
---
|
||||
|
||||
## The Stress Test Output
|
||||
|
||||
```
|
||||
ASSUMPTION: [Exact statement]
|
||||
SOURCE: [Where this came from — model, investor pitch, team gut feel]
|
||||
|
||||
COUNTER-EVIDENCE
|
||||
• [Specific evidence that challenges this assumption]
|
||||
• [Comparable failure case]
|
||||
• [Data point that contradicts the assumption]
|
||||
|
||||
DOWNSIDE MODEL
|
||||
• Bear case (-30%): [Impact on plan]
|
||||
• Stress case (-50%): [Impact on plan]
|
||||
• Catastrophic (-80%): [Impact on plan — does the business survive?]
|
||||
|
||||
SENSITIVITY
|
||||
This assumption has [HIGH / MEDIUM / LOW] sensitivity.
|
||||
A 10% change → [X] change in outcome.
|
||||
|
||||
HEDGE
|
||||
• Validation: [How to test this before betting on it]
|
||||
• Contingency: [Plan B if it's wrong]
|
||||
• Early warning: [Leading indicator to watch — and at what threshold to act]
|
||||
```
|
||||
140
docs/skills/c-level-advisor/executive-mentor.md
Normal file
140
docs/skills/c-level-advisor/executive-mentor.md
Normal file
@@ -0,0 +1,140 @@
|
||||
---
|
||||
title: "Executive Mentor"
|
||||
description: "Executive Mentor - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Executive Mentor
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `executive-mentor` | **Source:** [`c-level-advisor/executive-mentor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/executive-mentor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Executive Mentor
|
||||
|
||||
Not another advisor. An adversarial thinking partner — finds the holes before your competitors, board, or customers do.
|
||||
|
||||
## The Difference
|
||||
|
||||
Other C-suite skills give you frameworks. Executive Mentor gives you the questions you don't want to answer.
|
||||
|
||||
- **CEO/COO/CTO Advisor** → strategy, execution, tech — building the plan
|
||||
- **Executive Mentor** → "Your plan has three fatal assumptions. Let's find them now."
|
||||
|
||||
## Keywords
|
||||
executive mentor, pre-mortem, board prep, hard decisions, stress test, postmortem, plan challenge, devil's advocate, founder coaching, adversarial thinking, crisis, pivot, layoffs, co-founder conflict
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | What It Does |
|
||||
|---------|-------------|
|
||||
| `/em:challenge <plan>` | Find weaknesses before they find you. Pre-mortem + severity ratings. |
|
||||
| `/em:board-prep <agenda>` | Prepare for hard questions. Build the narrative. Know your numbers cold. |
|
||||
| `/em:hard-call <decision>` | Framework for decisions with no good options. Layoffs, pivots, firings. |
|
||||
| `/em:stress-test <assumption>` | Challenge any assumption. Revenue projections, moats, market size. |
|
||||
| `/em:postmortem <event>` | Honest analysis. 5 Whys done properly. Who owns what change. |
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
python scripts/decision_matrix_scorer.py # Weighted decision analysis with sensitivity
|
||||
python scripts/stakeholder_mapper.py # Map influence vs alignment, find blockers
|
||||
```
|
||||
|
||||
## Voice
|
||||
|
||||
Direct. Uncomfortable when necessary. Not mean — honest.
|
||||
|
||||
Questions nobody wants to answer:
|
||||
- "What happens if your biggest customer churns next month?"
|
||||
- "Your burn rate gives you 11 months. What's plan B?"
|
||||
- "You've been 'almost closing' this deal for 6 weeks. Is it real?"
|
||||
- "Your co-founder hasn't shipped anything meaningful in 90 days. What are you doing about it?"
|
||||
|
||||
This isn't therapy. It's preparation.
|
||||
|
||||
## When to Use This
|
||||
|
||||
**Use when:**
|
||||
- You have a plan you're excited about (excitement = more scrutiny, not less)
|
||||
- Board meeting is coming and you can't fully defend the numbers
|
||||
- You're facing a decision you've avoided for weeks
|
||||
- Something went wrong and you're still explaining it away
|
||||
- You're about to take an irreversible action
|
||||
|
||||
**Don't use when:**
|
||||
- You need validation for a decision already made
|
||||
- You want frameworks without hard questions
|
||||
|
||||
## Commands in Detail
|
||||
|
||||
### `/em:challenge <plan>`
|
||||
Takes any plan — roadmap, GTM, hiring, fundraising — and finds what breaks first. Identifies assumptions, rates confidence, maps dependencies. Output: numbered vulnerabilities with severity (Critical / High / Medium). See `skills/challenge/SKILL.md`
|
||||
|
||||
### `/em:board-prep <agenda>`
|
||||
48 hours before investors. What are the 10 hardest questions? What data do you need cold? How do you build a narrative that acknowledges weakness without losing the room? Prepares you for the adversarial board, not the friendly one. See `skills/board-prep/SKILL.md`
|
||||
|
||||
### `/em:hard-call <decision>`
|
||||
Reversibility test. 10/10/10 framework. Stakeholder impact mapping. Communication planning. For decisions with no good answer — only less bad ones. See `skills/hard-call/SKILL.md`
|
||||
|
||||
### `/em:stress-test <assumption>`
|
||||
"$5B market." "$2M ARR by December." "3-year moat." Every plan is built on assumptions. Surfaces counter-evidence, models the downside, proposes the hedge. See `skills/stress-test/SKILL.md`
|
||||
|
||||
### `/em:postmortem <event>`
|
||||
Lost deal. Failed feature. Missed quarter. No blame sessions, no whitewash. 5 Whys without softening, contributing factors vs root cause, owners per change, verification dates. See `skills/postmortem/SKILL.md`
|
||||
|
||||
## Agents & References
|
||||
|
||||
- `agents/devils-advocate.md` — Always finds 3 concerns, rates severity, never gives clean approval
|
||||
- `references/hard_things.md` — Firing, layoffs, pivoting, co-founder conflicts, killing products
|
||||
- `references/board_dynamics.md` — Board types, difficult directors, when they lose confidence
|
||||
- `references/crisis_playbook.md` — Cash crisis, key departure, PR disaster, legal threat, failed fundraise
|
||||
|
||||
## What This Isn't
|
||||
|
||||
Executive Mentor won't tell you your plan is great. It won't soften bad news.
|
||||
|
||||
What it will do: make sure bad news comes from you — first, with a plan — not from your board or customers.
|
||||
|
||||
Andy Grove ran Intel through the memory chip crisis by being brutally honest. Ben Horowitz fired his best friend to save his company. The best executives see hard things coming and act first.
|
||||
|
||||
That's what this is for.
|
||||
|
||||
|
||||
## Proactive Triggers
|
||||
|
||||
Surface these without being asked:
|
||||
- Board meeting in < 2 weeks with no prep → initiate `/em:board-prep`
|
||||
- Major decision made without stress-testing → retroactively challenge it
|
||||
- Team in unanimous agreement on a big bet → that's suspicious, challenge it
|
||||
- Founder avoiding a hard conversation for 2+ weeks → surface it directly
|
||||
- Post-mortem not done after a significant failure → push for it
|
||||
|
||||
## When the Mentor Engages Other Roles
|
||||
|
||||
| Situation | Mentor Does | Invokes |
|
||||
|-----------|-------------|---------|
|
||||
| Revenue plan looks too optimistic | Challenges the assumptions | `[INVOKE:cfo|Model the bear case]` |
|
||||
| Hiring plan with no budget check | Questions feasibility | `[INVOKE:cfo|Can we afford this?]` |
|
||||
| Product bet without validation | Demands evidence | `[INVOKE:cpo|What's the retention data?]` |
|
||||
| Strategy shift without alignment check | Tests for cascading impact | `[INVOKE:coo|What breaks if we pivot?]` |
|
||||
| Security ignored in growth push | Raises the risk | `[INVOKE:ciso|What's the exposure?]` |
|
||||
|
||||
## Reasoning Technique: Adversarial Reasoning
|
||||
|
||||
Assume the plan will fail. Find the three most likely failure modes. For each, identify the earliest warning signal and the cheapest hedge. Never say 'this looks good' without finding at least one risk.
|
||||
|
||||
## Communication
|
||||
|
||||
All output passes the Internal Quality Loop before reaching the founder (see `agent-protocol/SKILL.md`).
|
||||
- Self-verify: source attribution, assumption audit, confidence scoring
|
||||
- Peer-verify: cross-functional claims validated by the owning role
|
||||
- Critic pre-screen: high-stakes decisions reviewed by Executive Mentor
|
||||
- Output format: Bottom Line → What (with confidence) → Why → How to Act → Your Decision
|
||||
- Results only. Every finding tagged: 🟢 verified, 🟡 medium, 🔴 assumed.
|
||||
|
||||
## Context Integration
|
||||
|
||||
- **Always** read `company-context.md` before responding (if it exists)
|
||||
- **During board meetings:** Use only your own analysis in Phase 2 (no cross-pollination)
|
||||
- **Invocation:** You can request input from other roles: `[INVOKE:role|question]`
|
||||
299
docs/skills/c-level-advisor/founder-coach.md
Normal file
299
docs/skills/c-level-advisor/founder-coach.md
Normal file
@@ -0,0 +1,299 @@
|
||||
---
|
||||
title: "Founder Development Coach"
|
||||
description: "Founder Development Coach - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Founder Development Coach
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `founder-coach` | **Source:** [`c-level-advisor/founder-coach/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/founder-coach/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Founder Development Coach
|
||||
|
||||
Your company can only grow as fast as you do. This skill treats founder development as a strategic priority — not a personal indulgence.
|
||||
|
||||
## Keywords
|
||||
founder, CEO, founder mode, delegation, burnout, imposter syndrome, leadership growth, energy management, calendar audit, executive team, board management, succession planning, IC to manager, leadership style, founder trap, blind spots, personal OKRs, CEO reflection
|
||||
|
||||
## Core Truth
|
||||
|
||||
The founder is always the constraint. Not intentionally — it's structural. You built the company. You know everything. Decisions flow through you. This works until it doesn't.
|
||||
|
||||
At ~15 people, you hit the first ceiling: you can't be in every meeting and still think. At ~50 people, the second: your style starts creating culture problems. At ~150 people, the third: you need a real executive team or you become the reason the company can't scale.
|
||||
|
||||
The earlier you address this, the better.
|
||||
|
||||
---
|
||||
|
||||
## 1. Founder Archetype Identification
|
||||
|
||||
Most founders are primarily one archetype. Knowing yours predicts what you'll struggle with.
|
||||
|
||||
| Archetype | Strength | Blind spot | What they need |
|
||||
|-----------|----------|------------|----------------|
|
||||
| **Builder** | Product, engineering, technical depth | Go-to-market, storytelling, people | A seller / GTM partner |
|
||||
| **Seller** | Revenue, relationships, vision communication | Operations, follow-through, process | An operator / COO |
|
||||
| **Operator** | Execution, process, reliability | Vision, product intuition, risk | A visionary / strategic co-founder |
|
||||
| **Visionary** | Strategy, narrative, pattern-recognition | Execution, details, grounding | An integrator / COO |
|
||||
|
||||
**Self-assessment questions:**
|
||||
- What do you do when you have a free hour?
|
||||
- What do you procrastinate on most?
|
||||
- What do your co-founders or early team complain you don't do?
|
||||
- What's the best feedback you've received about your leadership?
|
||||
|
||||
Most founders are Builder or Visionary. Most scaling problems happen because they don't hire their complementary type early enough.
|
||||
|
||||
---
|
||||
|
||||
## 2. Delegation Framework
|
||||
|
||||
Founders fail to delegate for four reasons:
|
||||
1. "Nobody does it as well as I do" (often true short-term, fatal long-term)
|
||||
2. "It takes longer to explain than to do it" (true once; not true the 10th time)
|
||||
3. "I lose control if I don't do it myself" (control is an illusion at scale)
|
||||
4. "If it fails, it's my fault" (it's your fault if you never let anyone else try)
|
||||
|
||||
### The Skill × Will Matrix
|
||||
|
||||
| | High Skill | Low Skill |
|
||||
|---|-----------|----------|
|
||||
| **High Will** | Delegate fully | Coach and develop |
|
||||
| **Low Will** | Motivate or reassign | Manage out or redesign role |
|
||||
|
||||
**Rules:**
|
||||
- High skill + high will → Give the work and get out of the way
|
||||
- High will + low skill → Invest in them. They want to grow.
|
||||
- High skill + low will → Find out why. Fix the environment or accept the mismatch.
|
||||
- Low skill + low will → Don't delegate to them. Address the performance issue.
|
||||
|
||||
### The Delegation Ladder
|
||||
|
||||
Not all delegation is equal. Build up gradually:
|
||||
|
||||
1. "Do exactly what I tell you" — not delegation, instruction
|
||||
2. "Research this and report back" — information gathering
|
||||
3. "Propose a solution and I'll decide" — thinking delegation
|
||||
4. "Decide and tell me what you decided" — decision delegation with review
|
||||
5. "Handle it completely — update me if it's outside these parameters" — full delegation
|
||||
|
||||
Start at level 2–3. Move people up as trust is established. Most founders never get past level 3 with their team — that's the bottleneck.
|
||||
|
||||
### What to delegate first
|
||||
|
||||
**Delegate first (high volume, low stakes):**
|
||||
- Recurring operational tasks you do the same way every time
|
||||
- Information gathering and synthesis
|
||||
- Meeting coordination and scheduling
|
||||
- Reports and updates you produce regularly
|
||||
|
||||
**Delegate next (skill-buildable):**
|
||||
- Customer interactions (with clear principles)
|
||||
- Hiring screens (after you've trained judgment)
|
||||
- Partner relationship management
|
||||
- Budget management within parameters
|
||||
|
||||
**Delegate last (strategic, irreversible):**
|
||||
- Major strategic pivots
|
||||
- Executive hires
|
||||
- Large financial commitments
|
||||
- M&A decisions
|
||||
|
||||
---
|
||||
|
||||
## 3. Energy Management
|
||||
|
||||
Founders manage energy, not just time. Time is fixed. Energy is renewable — but only if you manage it.
|
||||
|
||||
### The Energy Audit
|
||||
|
||||
Map your week by energy, not tasks. See `references/founder-toolkit.md` for the full template.
|
||||
|
||||
**Categories:**
|
||||
- 🟢 **Energizing:** Activities that leave you sharper after doing them
|
||||
- 🟡 **Neutral:** Neither energizing nor draining
|
||||
- 🔴 **Draining:** Activities that leave you depleted
|
||||
|
||||
**Common founder energy patterns:**
|
||||
- **Builders:** Energized by creating, drained by politics and process
|
||||
- **Sellers:** Energized by people and wins, drained by detail work and admin
|
||||
- **Operators:** Energized by solving, drained by ambiguity and indecision
|
||||
- **Visionaries:** Energized by strategy and ideas, drained by execution and repetition
|
||||
|
||||
**The rule:** Maximize green. Eliminate or delegate red. Accept yellow as the price of leadership.
|
||||
|
||||
### Energy management practices
|
||||
|
||||
**Protect deep work time.** 2–4 hours of uninterrupted thinking time, 3–5 days per week. Schedule it. Defend it. This is where strategy happens.
|
||||
|
||||
**Batch shallow work.** Email, Slack, administrative tasks — twice a day maximum.
|
||||
|
||||
**Single-task during recovery.** If you're depleted, don't try to do your best work. Do tasks that don't require your best.
|
||||
|
||||
**Identify your peak window.** Most people have 4–6 peak hours per day. Schedule your hardest work in those windows.
|
||||
|
||||
---
|
||||
|
||||
## 4. CEO Calendar Audit
|
||||
|
||||
The calendar is the most honest document in a founder's life. It shows what you actually prioritize, not what you say you prioritize.
|
||||
|
||||
### Running the audit
|
||||
|
||||
Pull the last 4 weeks of calendar data. Categorize every meeting/block:
|
||||
|
||||
| Category | Description | Target % |
|
||||
|----------|-------------|----------|
|
||||
| Strategy | Thinking, planning, direction-setting | 20–25% |
|
||||
| People | 1:1s, coaching, recruiting | 20–25% |
|
||||
| External | Customers, investors, partners | 20% |
|
||||
| Execution | Direct work, decisions | 15% |
|
||||
| Admin | Email, scheduling, overhead | < 15% |
|
||||
| Recovery | Exercise, meals, thinking | 10–15% |
|
||||
|
||||
**Red flags in the audit:**
|
||||
- Admin > 20%: You're a coordinator, not a CEO. Fix your systems.
|
||||
- Execution > 30%: You're still an IC. Build the team.
|
||||
- People < 10%: Your team is running on empty. They need more of you.
|
||||
- No recovery blocks: You're running on adrenaline. It ends badly.
|
||||
- Strategy < 10%: You're running the company, not leading it.
|
||||
|
||||
### The CEO's primary job at each stage
|
||||
|
||||
| Stage | CEO should spend most time on... |
|
||||
|-------|--------------------------------|
|
||||
| Seed | Product and customers. Directly. |
|
||||
| Series A | Hiring the executive team. Recruiting is your job. |
|
||||
| Series B | Culture, strategy, and external (investors/partners/customers) |
|
||||
| Series C+ | Vision, board, external narrative, executive development |
|
||||
|
||||
If you're spending time on things from two stages ago, you haven't made the transition.
|
||||
|
||||
---
|
||||
|
||||
## 5. Leadership Style Evolution
|
||||
|
||||
The job changes at every stage. Most founders don't change with it.
|
||||
|
||||
**IC → Manager (0 to ~10 people):**
|
||||
You need to teach and build trust. People are watching how you treat failure. The skill: give clear context, set expectations, check in frequently.
|
||||
|
||||
**Manager → Leader (~10 to ~50 people):**
|
||||
You can't manage everyone directly. You need people who manage people. The skill: hire managers you trust, let them manage.
|
||||
|
||||
**Leader → Executive (~50 to ~200 people):**
|
||||
You're now setting culture and direction, not managing work. The skill: communicate obsessively, decide at the right altitude, develop your leadership team.
|
||||
|
||||
**Executive → Institutional CEO (200+):**
|
||||
You're a symbol as much as a manager. The skill: build systems that work without you; focus on board, investors, and external narrative.
|
||||
|
||||
**The hardest transition:** Manager → Leader. You have to stop doing things yourself and trust people you're still getting to know.
|
||||
|
||||
---
|
||||
|
||||
## 6. Blind Spot Identification
|
||||
|
||||
Everyone has them. Founders more than most — because nobody in the early company had the authority or safety to tell you.
|
||||
|
||||
### Common founder blind spots
|
||||
|
||||
- **Communication:** "I said it once, they should know" — you said it; they didn't hear it or didn't believe it
|
||||
- **Decision speed:** Moving so fast that teams can't orient or build on your direction
|
||||
- **Context hoarding:** Knowing what's happening without sharing it, then being frustrated that teams make bad decisions
|
||||
- **Optimism bias:** Consistently underestimating timelines, cost, and difficulty
|
||||
- **Founder exceptionalism:** Rules that apply to everyone don't apply to you
|
||||
- **Feedback avoidance:** Creating an environment where no one gives you honest feedback
|
||||
|
||||
### How to find your blind spots
|
||||
|
||||
1. **360 feedback (anonymous):** Once a year. Ask direct reports, peers, board members. Include "What does [name] do that gets in the way of our success?"
|
||||
2. **Exit interview analysis:** What do departing employees consistently say? Find the pattern.
|
||||
3. **Failure post-mortems:** What do your worst decisions have in common? What were you assuming that wasn't true?
|
||||
4. **The energy audit:** Where do you consistently drain the people around you?
|
||||
|
||||
---
|
||||
|
||||
## 7. Imposter Syndrome Toolkit
|
||||
|
||||
It doesn't go away. It evolves. The founder who was scared to pitch to investors is now scared to manage a board. The founder who was scared to hire is now scared to fire.
|
||||
|
||||
**The reframe:** Imposter syndrome is proportional to stretch. If you never feel it, you're not growing.
|
||||
|
||||
**Practical tools:**
|
||||
- **Evidence file:** Document wins, compliments, decisions that worked. Read it when the doubt hits.
|
||||
- **Normalize the feeling:** "I feel underprepared for this" ≠ "I am an imposter." Feeling and fact are different.
|
||||
- **Do the thing anyway.** Competence comes from doing, not from feeling ready.
|
||||
- **Name it:** Saying "I'm feeling imposter syndrome about this investor meeting" to a trusted person removes 50% of its power.
|
||||
|
||||
---
|
||||
|
||||
## 8. Founder Mental Health
|
||||
|
||||
Burnout isn't weakness. It's a predictable outcome of high-demand + low-recovery + no control over inputs.
|
||||
|
||||
### Burnout signals
|
||||
|
||||
Early: Irritability, difficulty sleeping, decisions feel harder than they should, loss of enthusiasm for the mission.
|
||||
Mid: Physical symptoms (headaches, illness), cynicism about the company, social withdrawal, all tasks feel equally important (priority paralysis).
|
||||
Late: Can't function, decisions have stopped, team notices before you do.
|
||||
|
||||
**If you're in late burnout:** Stop performing. Get support. The company needs a functioning founder more than it needs a martyred one.
|
||||
|
||||
### Structural prevention
|
||||
|
||||
- **Protect recovery time.** Not weekends — protected time during the week where you're not available.
|
||||
- **Therapy or coaching.** Not optional for founders. The job is isolating and the stakes are high.
|
||||
- **Peer group.** Other founders at similar stages. They're the only people who actually understand the job.
|
||||
- **Clear off-ramps.** Know what "enough for today" looks like. Don't let the work be infinite.
|
||||
|
||||
---
|
||||
|
||||
## 9. The Founder Mode Trap
|
||||
|
||||
Paul Graham's "Founder Mode" essay made the case that great founders stay deeply involved in operations — skip middle management and go direct. It resonated because it's sometimes true.
|
||||
|
||||
**When founder mode helps:**
|
||||
- Crisis recovery (company needs direct leadership)
|
||||
- Product-market fit search (speed matters more than org health)
|
||||
- High-value, irreversible decisions (you should be in the room)
|
||||
- Early stages when the team is small
|
||||
|
||||
**When founder mode hurts:**
|
||||
- When it undermines managers you've hired (they can't lead if you override them)
|
||||
- When it's driven by distrust rather than strategy
|
||||
- When it prevents the team from developing judgment
|
||||
- When you're doing it because you miss doing, not because the company needs you to
|
||||
|
||||
**The test:** Are you going deep because the situation requires it, or because you're uncomfortable with the loss of control? The first is leadership. The second is the trap.
|
||||
|
||||
---
|
||||
|
||||
## 10. Succession Planning
|
||||
|
||||
Building a company that works without you is not disloyalty — it's the ultimate expression of leadership.
|
||||
|
||||
**Succession is not just about exit.** It's about resilience. What happens if you're sick? On sabbatical? Acquired?
|
||||
|
||||
**Succession readiness levels:**
|
||||
- Level 1: You've documented your key knowledge and processes
|
||||
- Level 2: At least one person can cover each of your key functions for 2 weeks
|
||||
- Level 3: Your leadership team can run the company for a quarter without you
|
||||
- Level 4: You've identified and developed your potential successor
|
||||
|
||||
Most founders are at Level 0. Level 2 is a reasonable target. Level 3 is a strategic asset.
|
||||
|
||||
---
|
||||
|
||||
## Key Questions for Founder Development
|
||||
|
||||
- "What decisions did you make last week that someone else could have made?"
|
||||
- "What are you still doing that you should have delegated 6 months ago?"
|
||||
- "When did you last get honest, critical feedback? From whom? What did it say?"
|
||||
- "What would need to be true for the company to run for a week without you?"
|
||||
- "What's draining your energy that you've accepted as unavoidable?"
|
||||
|
||||
## Detailed References
|
||||
- `references/leadership-growth.md` — Maxwell levels, situational leadership, founder-to-CEO transition
|
||||
- `references/founder-toolkit.md` — Weekly reflection, energy audit, delegation matrix, 1:1 templates
|
||||
45
docs/skills/c-level-advisor/index.md
Normal file
45
docs/skills/c-level-advisor/index.md
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
title: "C-Level Advisory Skills"
|
||||
description: "All C-Level Advisory skills for Claude Code, OpenAI Codex, and OpenClaw."
|
||||
---
|
||||
|
||||
# C-Level Advisory Skills
|
||||
|
||||
34 skills in this domain.
|
||||
|
||||
| Skill | Description |
|
||||
|-------|-------------|
|
||||
| [Inter-Agent Protocol](agent-protocol.md) | `agent-protocol` |
|
||||
| [Board Deck Builder](board-deck-builder.md) | `board-deck-builder` |
|
||||
| [Board Meeting Protocol](board-meeting.md) | `board-meeting` |
|
||||
| [C-Level Advisory Ecosystem](c-level-advisor.md) | `c-level-advisor` |
|
||||
| [CEO Advisor](ceo-advisor.md) | `ceo-advisor` |
|
||||
| [CFO Advisor](cfo-advisor.md) | `cfo-advisor` |
|
||||
| [Change Management Playbook](change-management.md) | `change-management` |
|
||||
| [Chief of Staff](chief-of-staff.md) | `chief-of-staff` |
|
||||
| [CHRO Advisor](chro-advisor.md) | `chro-advisor` |
|
||||
| [CISO Advisor](ciso-advisor.md) | `ciso-advisor` |
|
||||
| [CMO Advisor](cmo-advisor.md) | `cmo-advisor` |
|
||||
| [Company Operating System](company-os.md) | `company-os` |
|
||||
| [Competitive Intelligence](competitive-intel.md) | `competitive-intel` |
|
||||
| [Company Context Engine](context-engine.md) | `context-engine` |
|
||||
| [COO Advisor](coo-advisor.md) | `coo-advisor` |
|
||||
| [CPO Advisor](cpo-advisor.md) | `cpo-advisor` |
|
||||
| [CRO Advisor](cro-advisor.md) | `cro-advisor` |
|
||||
| [C-Suite Onboarding](cs-onboard.md) | `cs-onboard` |
|
||||
| [CTO Advisor](cto-advisor.md) | `cto-advisor` |
|
||||
| [Culture Architect](culture-architect.md) | `culture-architect` |
|
||||
| [Decision Logger](decision-logger.md) | `decision-logger` |
|
||||
| [Executive Mentor](executive-mentor.md) | `executive-mentor` |
|
||||
| [/em:board-prep — Board Meeting Preparation](executive-mentor-board-prep.md) | `board-prep` (sub-skill of `executive-mentor`) |
|
||||
| [/em:challenge — Pre-Mortem Plan Analysis](executive-mentor-challenge.md) | `challenge` (sub-skill of `executive-mentor`) |
|
||||
| [/em:hard-call — Framework for Decisions With No Good Options](executive-mentor-hard-call.md) | `hard-call` (sub-skill of `executive-mentor`) |
|
||||
| [/em:postmortem — Honest Analysis of What Went Wrong](executive-mentor-postmortem.md) | `postmortem` (sub-skill of `executive-mentor`) |
|
||||
| [/em:stress-test — Business Assumption Stress Testing](executive-mentor-stress-test.md) | `stress-test` (sub-skill of `executive-mentor`) |
|
||||
| [Founder Development Coach](founder-coach.md) | `founder-coach` |
|
||||
| [Internal Narrative Builder](internal-narrative.md) | `internal-narrative` |
|
||||
| [International Expansion](intl-expansion.md) | `intl-expansion` |
|
||||
| [M&A Playbook](ma-playbook.md) | `ma-playbook` |
|
||||
| [Org Health Diagnostic](org-health-diagnostic.md) | `org-health-diagnostic` |
|
||||
| [Scenario War Room](scenario-war-room.md) | `scenario-war-room` |
|
||||
| [Strategic Alignment Engine](strategic-alignment.md) | `strategic-alignment` |
|
||||
196
docs/skills/c-level-advisor/internal-narrative.md
Normal file
196
docs/skills/c-level-advisor/internal-narrative.md
Normal file
@@ -0,0 +1,196 @@
|
||||
---
|
||||
title: "Internal Narrative Builder"
|
||||
description: "Internal Narrative Builder - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Internal Narrative Builder
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `internal-narrative` | **Source:** [`c-level-advisor/internal-narrative/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/internal-narrative/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Internal Narrative Builder
|
||||
|
||||
One company. Many audiences. Same truth — different lenses. Narrative inconsistency is trust erosion. This skill builds and maintains coherent communication across every stakeholder group.
|
||||
|
||||
## Keywords
|
||||
narrative, company story, internal communication, investor update, all-hands, board communication, crisis communication, messaging, storytelling, narrative consistency, audience translation, founder narrative, employee communication, candidate narrative, partner communication
|
||||
|
||||
## Core Principle
|
||||
|
||||
**The same fact lands differently depending on who hears it and what they need.**
|
||||
|
||||
"We're shifting resources from Product A to Product B" means:
|
||||
- To employees: "Is my job safe? Why are we abandoning what I built?"
|
||||
- To investors: "Smart capital allocation — they're doubling down on the winner"
|
||||
- To customers of Product A: "Are they abandoning us?"
|
||||
- To candidates: "Exciting new focus — are they decisive?"
|
||||
|
||||
Same fact. Four different narratives needed. The skill is maintaining truth while serving each audience's actual question.
|
||||
|
||||
---
|
||||
|
||||
## Framework
|
||||
|
||||
### Step 1: Build the Core Narrative
|
||||
|
||||
One paragraph that every other communication derives from. This is the source of truth.
|
||||
|
||||
**Core narrative template:**
|
||||
> [Company name] exists to [mission — present tense, specific]. We're building [what you're building] because [the problem you're solving]. Our approach is [your unique way of doing this]. We're at [honest description of current state] and heading toward [where you're going in concrete terms].
|
||||
|
||||
**Good core narrative (example):**
|
||||
> Acme Health exists to reduce preventable falls in elderly care using smartphone-based mobility analysis. We're building an AI diagnostic tool for care teams because current fall risk assessments are subjective, infrequent, and often wrong. Our approach — using the phone's camera during a 10-second walking test — means no new hardware, no specialist required. We have 80 care facilities in DACH paying us €800K ARR, and we're heading to €3M ARR by demonstrating clinical value at scale before our Series B.
|
||||
|
||||
**Bad core narrative:**
|
||||
> Acme Health is an innovative AI company revolutionizing elderly care through cutting-edge technology that empowers care providers and improves patient outcomes across the continuum of care.
|
||||
|
||||
The good version is usable. The bad version says nothing.
|
||||
|
||||
---
|
||||
|
||||
### Step 2: Audience Translation Matrix
|
||||
|
||||
Take the core narrative and translate it for each audience. Same truth, different frame.
|
||||
|
||||
| Fact | Employees need to hear | Investors need to hear | Customers need to hear | Candidates need to hear |
|
||||
|------|----------------------|----------------------|----------------------|------------------------|
|
||||
| We have 80 customers | "We've proven the model — your work matters" | "Product-market fit signal, capital efficient" | "80 care facilities trust us" | "Traction you'd be joining" |
|
||||
| We pivoted from hardware | "We were honest enough to change course" | "Capital-efficient pivot to better unit economics" | "We found a faster, simpler way to serve you" | "We make decisions based on evidence, not ego" |
|
||||
| We missed Q2 revenue | "Here's why, here's the plan, here's what you can do" | "Revenue mix shifted — trailing indicator improving" | [Usually don't tell customers revenue misses] | [Usually not shared externally] |
|
||||
| We're hiring fast | "The team is growing — your network matters" | "Headcount plan aligned to growth" | [Not relevant unless it affects service] | "This is a rocket ship moment" |
|
||||
|
||||
**Rules:**
|
||||
- Never contradict yourself across audiences. Different framing ≠ different facts.
|
||||
- "We told investors growth, told employees efficiency" is a contradiction. Audit for this.
|
||||
- Investors and employees see each other. Board members talk to your team. Candidates google you.
|
||||
|
||||
---
|
||||
|
||||
### Step 3: Contradiction Detection
|
||||
|
||||
Before any major communication, run the contradiction check:
|
||||
|
||||
**Question 1:** What did we tell investors last month about [topic]?
|
||||
**Question 2:** What did we tell employees about the same topic?
|
||||
**Question 3:** Are these consistent? If not — which version is true?
|
||||
|
||||
**Common contradictions:**
|
||||
- "Efficient growth" to investors + "we're hiring aggressively" to candidates
|
||||
- "Strong pipeline" to investors + "sales is struggling" at all-hands
|
||||
- "Customer-first" in culture + recent decisions that clearly prioritized revenue over customer need
|
||||
|
||||
**When you catch a contradiction:** Fix the less accurate version, then communicate the correction explicitly. "Last month I said X. After more reflection, X is not quite right. Here's the clearer version."
|
||||
|
||||
Correcting yourself before someone else catches it builds more trust than getting caught.
|
||||
|
||||
---
|
||||
|
||||
### Step 4: Audience-Specific Communication Cadence
|
||||
|
||||
| Audience | Format | Frequency | Owner |
|
||||
|----------|--------|-----------|-------|
|
||||
| Employees | All-hands | Monthly | CEO |
|
||||
| Employees | Team updates | Weekly | Team leads |
|
||||
| Investors | Written update | Monthly | CEO + CFO |
|
||||
| Board | Board meeting + memo | Quarterly | CEO |
|
||||
| Customers | Product updates | Per release | CPO / CS |
|
||||
| Candidates | Careers page + interview narrative | Ongoing | CHRO + Founders |
|
||||
| Partners | Quarterly business review | Quarterly | BD Lead |
|
||||
|
||||
---
|
||||
|
||||
### Step 5: All-Hands Structure and Cadence
|
||||
|
||||
See `templates/all-hands-template.md` for the full template.
|
||||
|
||||
**Principles:**
|
||||
- Lead with honest state of the company. No spin.
|
||||
- Connect company performance to individual work: "Here's how what you built contributed to this outcome."
|
||||
- Give people a reason to be proud of their choice to work here.
|
||||
- Leave time for real Q&A — not curated questions.
|
||||
|
||||
**All-hands failure modes:**
|
||||
- CEO speaks for 55 of 60 minutes; Q&A is "any quick questions?"
|
||||
- All good news, all the time — employees know when you're not being honest
|
||||
- Metrics without context: "ARR grew 15%" without explaining if that's good, bad, or expected
|
||||
- Questions deflected: "That's a great point, we should follow up on that" → never followed up
|
||||
|
||||
---
|
||||
|
||||
### Step 6: Crisis Communication
|
||||
|
||||
When the narrative breaks — someone leaves publicly, a product fails, a security breach, a press article.
|
||||
|
||||
**The 4-hour rule:** If something is public or about to be, communicate internally within 4 hours. Employees should never learn about company news from Twitter.
|
||||
|
||||
**Crisis communication sequence:**
|
||||
|
||||
**Hour 0–4 (internal first):**
|
||||
1. CEO or relevant leader sends an internal message
|
||||
2. Acknowledge what happened factually
|
||||
3. State what you know and what you don't know yet
|
||||
4. Tell people what you're doing about it
|
||||
5. Tell people what they should do if they're asked about it
|
||||
|
||||
**Hour 4–24 (external if needed):**
|
||||
1. External statement (press, social) only if the event is public
|
||||
2. Consistent with the internal message — same facts, audience-appropriate framing
|
||||
3. Legal review if any claims or liability involved
|
||||
|
||||
**What not to do in a crisis:**
|
||||
- Silence: letting rumors fill the vacuum
|
||||
- Spin: people can detect it and it destroys trust
|
||||
- "No comment": says "we have something to hide"
|
||||
- Blaming: even if someone else caused the problem, your audience only cares what you're doing about it
|
||||
|
||||
**Template for crisis internal communication:**
|
||||
> "Here's what happened: [factual description]. Here's what we know right now: [known facts]. Here's what we don't know yet: [honest uncertainty]. Here's what we're doing: [specific actions]. Here's what you should do if you're asked about this: [specific guidance]. I'll update you by [specific time] with more information."
|
||||
|
||||
---
|
||||
|
||||
## Narrative Consistency Checklist
|
||||
|
||||
Run before any major external communication:
|
||||
|
||||
- [ ] Is this consistent with what we told investors last month?
|
||||
- [ ] Is this consistent with what we told employees at the last all-hands?
|
||||
- [ ] Does this contradict anything on our website, careers page, or press releases?
|
||||
- [ ] If an employee read this external communication, would they recognize the company being described?
|
||||
- [ ] If an investor read our internal all-hands deck, would they find anything inconsistent?
|
||||
- [ ] Have we been accurate about our current state, or are we projecting an aspiration?
|
||||
|
||||
---
|
||||
|
||||
## Key Questions for Narrative
|
||||
|
||||
- "Could a new employee explain to a friend why our company exists? What would they say?"
|
||||
- "What do we tell investors about our strategy? What do we tell employees? Are these the same?"
|
||||
- "If a journalist asked our team members to describe the company independently, what would they say?"
|
||||
- "When did we last update our 'why we exist' story? Is it still true?"
|
||||
- "What's the hardest question we'd get from each audience? Do we have an honest answer?"
|
||||
|
||||
## Red Flags
|
||||
|
||||
- Different departments describe the company mission differently
|
||||
- Investor narrative emphasizes growth; employee narrative emphasizes stability (or vice versa)
|
||||
- All-hands presentations are mostly slides, mostly one-way
|
||||
- Q&A questions are screened or deflected
|
||||
- Bad news reaches employees through Slack rumors before leadership communication
|
||||
- Careers page describes a culture that employees don't recognize
|
||||
|
||||
## Integration with Other C-Suite Roles
|
||||
|
||||
| When... | Work with... | To... |
|
||||
|---------|-------------|-------|
|
||||
| Investor update prep | CFO | Align financial narrative with company narrative |
|
||||
| Reorg or leadership change | CHRO + CEO | Sequence: employees first, then external |
|
||||
| Product pivot | CPO | Align customer communication with investor story |
|
||||
| Culture change | Culture Architect | Ensure internal story is consistent with external employer brand |
|
||||
| M&A or partnership | CEO + COO | Control information flow, prevent narrative leaks |
|
||||
| Crisis | All C-suite | Single voice, consistent story, internal first |
|
||||
|
||||
## Detailed References
|
||||
- `references/narrative-frameworks.md` — Storytelling structures, founder narrative, bad news delivery, all-hands templates
|
||||
- `templates/all-hands-template.md` — All-hands presentation template
|
||||
105
docs/skills/c-level-advisor/intl-expansion.md
Normal file
105
docs/skills/c-level-advisor/intl-expansion.md
Normal file
@@ -0,0 +1,105 @@
|
||||
---
|
||||
title: "International Expansion"
|
||||
description: "International Expansion - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# International Expansion
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `intl-expansion` | **Source:** [`c-level-advisor/intl-expansion/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/intl-expansion/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# International Expansion
|
||||
|
||||
Frameworks for expanding into new markets: selection, entry, localization, and execution.
|
||||
|
||||
## Keywords
|
||||
international expansion, market entry, localization, go-to-market, GTM, regional strategy, international markets, market selection, cross-border, global expansion
|
||||
|
||||
## Quick Start
|
||||
|
||||
**Decision sequence:** Market selection → Entry mode → Regulatory assessment → Localization plan → GTM strategy → Team structure → Launch.
|
||||
|
||||
## Market Selection Framework
|
||||
|
||||
### Scoring Matrix
|
||||
| Factor | Weight | How to Assess |
|
||||
|--------|--------|---------------|
|
||||
| Market size (addressable) | 25% | TAM in target segment, willingness to pay |
|
||||
| Competitive intensity | 20% | Incumbent strength, market gaps |
|
||||
| Regulatory complexity | 20% | Barriers to entry, compliance cost, timeline |
|
||||
| Cultural distance | 15% | Language, business practices, buying behavior |
|
||||
| Existing traction | 10% | Inbound demand, existing customers, partnerships |
|
||||
| Operational complexity | 10% | Time zones, infrastructure, payment systems |
|
||||
|
||||
### Entry Modes
|
||||
| Mode | Investment | Control | Risk | Best For |
|
||||
|------|-----------|---------|------|----------|
|
||||
| **Export** (sell remotely) | Low | Low | Low | Testing demand |
|
||||
| **Partnership** (reseller/distributor) | Medium | Medium | Medium | Markets with strong local requirements |
|
||||
| **Local team** (hire in-market) | High | High | High | Strategic markets with proven demand |
|
||||
| **Entity** (full subsidiary) | Very high | Full | High | Major markets, regulatory requirement |
|
||||
| **Acquisition** | Highest | Full | Highest | Fast market entry with existing base |
|
||||
|
||||
**Default path:** Export → Partnership → Local team → Entity (graduate as revenue justifies).
|
||||
|
||||
## Localization Checklist
|
||||
|
||||
### Product
|
||||
- [ ] Language (UI, documentation, support content)
|
||||
- [ ] Currency and pricing (local pricing, not just conversion)
|
||||
- [ ] Payment methods (varies wildly by market)
|
||||
- [ ] Date/time/number formats
|
||||
- [ ] Legal requirements (data residency, privacy)
|
||||
- [ ] Cultural adaptation (not just translation)
|
||||
|
||||
### Go-to-Market
|
||||
- [ ] Messaging adaptation (what resonates locally)
|
||||
- [ ] Channel strategy (channels differ by market)
|
||||
- [ ] Local case studies and social proof
|
||||
- [ ] Local partnerships and integrations
|
||||
- [ ] Event/conference presence
|
||||
- [ ] Local SEO and content
|
||||
|
||||
### Operations
|
||||
- [ ] Legal entity (if required)
|
||||
- [ ] Tax compliance
|
||||
- [ ] Employment law (if hiring locally)
|
||||
- [ ] Customer support (hours, language)
|
||||
- [ ] Banking and payments
|
||||
|
||||
## Key Questions
|
||||
|
||||
- "Is there pull from the market, or are we pushing?"
|
||||
- "What's the cost of entry vs the 3-year revenue opportunity?"
|
||||
- "Can we serve this market from HQ, or do we need boots on the ground?"
|
||||
- "What's the regulatory timeline? Can we launch before the paperwork is done?"
|
||||
- "Who's winning in this market and what would it take to displace them?"
|
||||
|
||||
## Common Mistakes
|
||||
|
||||
| Mistake | Why It Happens | Prevention |
|
||||
|---------|---------------|------------|
|
||||
| Entering too many markets at once | FOMO, board pressure | Max 1-2 new markets per year |
|
||||
| Copy-paste GTM from home market | Assuming buyers are the same | Research local buying behavior |
|
||||
| Underestimating regulatory cost | "We'll figure it out" | Regulatory assessment BEFORE committing |
|
||||
| Hiring too early | Optimism | Prove demand before hiring local team |
|
||||
| Wrong pricing (just converting) | Laziness | Research willingness to pay locally |
|
||||
|
||||
## Integration with C-Suite Roles
|
||||
|
||||
| Role | Contribution |
|
||||
|------|-------------|
|
||||
| CEO | Market selection, strategic commitment |
|
||||
| CFO | Investment sizing, ROI modeling, entity structure |
|
||||
| CRO | Revenue targets, sales model adaptation |
|
||||
| CMO | Positioning, channel strategy, local brand |
|
||||
| CPO | Localization roadmap, feature priorities |
|
||||
| CTO | Infrastructure, data residency, scaling |
|
||||
| CHRO | Local hiring, employment law, comp |
|
||||
| COO | Operations setup, process adaptation |
|
||||
|
||||
## Resources
|
||||
- `references/market-entry-playbook.md` — detailed entry playbook by market type
|
||||
- `references/regional-guide.md` — specific considerations for key regions (EU, US, APAC, LATAM)
|
||||
98
docs/skills/c-level-advisor/ma-playbook.md
Normal file
98
docs/skills/c-level-advisor/ma-playbook.md
Normal file
@@ -0,0 +1,98 @@
|
||||
---
|
||||
title: "M&A Playbook"
|
||||
description: "M&A Playbook - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# M&A Playbook
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `ma-playbook` | **Source:** [`c-level-advisor/ma-playbook/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/ma-playbook/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# M&A Playbook
|
||||
|
||||
Frameworks for both sides of M&A: acquiring companies and being acquired.
|
||||
|
||||
## Keywords
|
||||
M&A, mergers and acquisitions, due diligence, acquisition, acqui-hire, integration, deal structure, valuation, LOI, term sheet, earnout
|
||||
|
||||
## Quick Start
|
||||
|
||||
**Acquiring:** Start with strategic rationale → target screening → due diligence → valuation → negotiation → integration.
|
||||
|
||||
**Being Acquired:** Start with readiness assessment → data room prep → advisor selection → negotiation → transition.
|
||||
|
||||
## When You're Acquiring
|
||||
|
||||
### Strategic Rationale (answer before anything else)
|
||||
- **Buy vs Build:** Can you build this faster/cheaper? If yes, don't acquire.
|
||||
- **Acqui-hire vs Product vs Market:** What are you really buying? Talent? Technology? Customers?
|
||||
- **Integration complexity:** How hard is it to merge this into your company?
|
||||
|
||||
### Due Diligence Checklist
|
||||
| Domain | Key Questions | Red Flags |
|
||||
|--------|--------------|-----------|
|
||||
| Financial | Revenue quality, customer concentration, burn rate | >30% revenue from 1 customer |
|
||||
| Technical | Code quality, tech debt, architecture fit | Monolith with no tests |
|
||||
| Legal | IP ownership, pending litigation, contracts | Key IP owned by individuals |
|
||||
| People | Key person risk, culture fit, retention risk | Founders have no lockup/earnout |
|
||||
| Market | Market position, competitive threats | Declining market share |
|
||||
| Customers | Churn rate, NPS, contract terms | High churn, short contracts |
|
||||
|
||||
### Valuation Approaches
|
||||
- **Revenue multiple:** Industry-dependent (2-15x ARR for SaaS)
|
||||
- **Comparable transactions:** What similar companies sold for
|
||||
- **DCF:** For profitable companies only (most startups: use multiples)
|
||||
- **Acqui-hire:** $1-3M per engineer in hot markets
|
||||
|
||||
### Integration Frameworks
|
||||
See `references/integration-playbook.md` for the 100-day integration plan.
|
||||
|
||||
## When You're Being Acquired
|
||||
|
||||
### Readiness Signals
|
||||
- Inbound interest from strategic buyers
|
||||
- Market consolidation happening around you
|
||||
- Fundraising becomes harder than operating
|
||||
- Founder ready for a transition
|
||||
|
||||
### Preparation (6-12 months before)
|
||||
1. Clean up financials (audited if possible)
|
||||
2. Document all IP and contracts
|
||||
3. Reduce customer concentration
|
||||
4. Lock up key employees
|
||||
5. Build the data room
|
||||
6. Engage an M&A advisor
|
||||
|
||||
### Negotiation Points
|
||||
| Term | What to Watch | Your Leverage |
|
||||
|------|--------------|---------------|
|
||||
| Valuation | Earnout traps (unreachable targets) | Multiple competing offers |
|
||||
| Earnout | Milestone definitions, measurement period | Cash-heavy vs earnout-heavy split |
|
||||
| Lockup | Duration, conditions | Your replaceability |
|
||||
| Rep & warranties | Scope of liability | Escrow vs indemnification cap |
|
||||
| Employee retention | Who gets offers, at what terms | Key person dependencies |
|
||||
|
||||
## Red Flags (Both Sides)
|
||||
|
||||
- No clear strategic rationale beyond "it's a good deal"
|
||||
- Culture clash visible during due diligence and ignored
|
||||
- Key people not locked in before close
|
||||
- Integration plan doesn't exist or is "we'll figure it out"
|
||||
- Valuation based on projections, not actuals
|
||||
|
||||
## Integration with C-Suite Roles
|
||||
|
||||
| Role | Contribution to M&A |
|
||||
|------|-------------------|
|
||||
| CEO | Strategic rationale, negotiation lead |
|
||||
| CFO | Valuation, deal structure, financing |
|
||||
| CTO | Technical due diligence, integration architecture |
|
||||
| CHRO | People due diligence, retention planning |
|
||||
| COO | Integration execution, process merge |
|
||||
| CPO | Product roadmap impact, customer overlap |
|
||||
|
||||
## Resources
|
||||
- `references/integration-playbook.md` — 100-day post-acquisition integration plan
|
||||
- `references/due-diligence-checklist.md` — comprehensive DD checklist by domain
|
||||
183
docs/skills/c-level-advisor/org-health-diagnostic.md
Normal file
183
docs/skills/c-level-advisor/org-health-diagnostic.md
Normal file
@@ -0,0 +1,183 @@
|
||||
---
|
||||
title: "Org Health Diagnostic"
|
||||
description: "Org Health Diagnostic - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Org Health Diagnostic
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `org-health-diagnostic` | **Source:** [`c-level-advisor/org-health-diagnostic/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/org-health-diagnostic/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Org Health Diagnostic
|
||||
|
||||
Eight dimensions. Traffic lights. Real benchmarks. Surfaces the problems you don't know you have.
|
||||
|
||||
## Keywords
|
||||
org health, organizational health, health diagnostic, health dashboard, health check, company health, functional health, team health, startup health, health scorecard, health assessment, risk dashboard
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
python scripts/health_scorer.py # Guided CLI — enter metrics, get scored dashboard
|
||||
python scripts/health_scorer.py --json # Output raw JSON for integration
|
||||
```
|
||||
|
||||
Or describe your metrics:
|
||||
```
|
||||
/health [paste your key metrics or answer prompts]
|
||||
/health:dimension [financial|revenue|product|engineering|people|ops|security|market]
|
||||
```
|
||||
|
||||
## The 8 Dimensions
|
||||
|
||||
### 1. 💰 Financial Health (CFO)
|
||||
**What it measures:** Can we fund operations and invest in growth?
|
||||
|
||||
Key metrics:
|
||||
- **Runway** — months at current burn (Green: >12, Yellow: 6-12, Red: <6)
|
||||
- **Burn multiple** — net burn / net new ARR (Green: <1.5x, Yellow: 1.5-2.5x, Red: >2.5x)
|
||||
- **Gross margin** — SaaS target: >65% (Green: >70%, Yellow: 55-70%, Red: <55%)
|
||||
- **MoM growth rate** — contextual by stage (see benchmarks)
|
||||
- **Revenue concentration** — top customer % of ARR (Green: <15%, Yellow: 15-25%, Red: >25%)
|
||||
|
||||
### 2. 📈 Revenue Health (CRO)
|
||||
**What it measures:** Are customers staying, growing, and recommending us?
|
||||
|
||||
Key metrics:
|
||||
- **NRR (Net Revenue Retention)** — Green: >110%, Yellow: 100-110%, Red: <100%
|
||||
- **Logo churn rate (annualized)** — Green: <5%, Yellow: 5-10%, Red: >10%
|
||||
- **Pipeline coverage (next quarter)** — Green: >3x, Yellow: 2-3x, Red: <2x
|
||||
- **CAC payback period** — Green: <12 months, Yellow: 12-18, Red: >18 months
|
||||
- **Average ACV trend** — directional: growing, flat, declining
|
||||
|
||||
### 3. 🚀 Product Health (CPO)
|
||||
**What it measures:** Do customers love and use the product?
|
||||
|
||||
Key metrics:
|
||||
- **NPS** — Green: >40, Yellow: 20-40, Red: <20
|
||||
- **DAU/MAU ratio** — engagement proxy (Green: >40%, Yellow: 20-40%, Red: <20%)
|
||||
- **Core feature adoption** — % of users using primary value feature (Green: >60%)
|
||||
- **Time-to-value** — days from signup to first core action (lower is better)
|
||||
- **Customer satisfaction (CSAT)** — Green: >4.2/5, Yellow: 3.5-4.2, Red: <3.5
|
||||
|
||||
### 4. ⚙️ Engineering Health (CTO)
|
||||
**What it measures:** Can we ship reliably and sustain velocity?
|
||||
|
||||
Key metrics:
|
||||
- **Deployment frequency** — Green: daily, Yellow: weekly, Red: monthly or less
|
||||
- **Change failure rate** — % of deployments causing incidents (Green: <5%, Red: >15%)
|
||||
- **Mean time to recovery (MTTR)** — Green: <1 hour, Yellow: 1-4 hours, Red: >4 hours
|
||||
- **Tech debt ratio** — % of sprint capacity on debt (Green: <20%, Yellow: 20-35%, Red: >35%)
|
||||
- **Incident frequency** — P0/P1 per month (Green: <2, Yellow: 2-5, Red: >5)
|
||||
|
||||
### 5. 👥 People Health (CHRO)
|
||||
**What it measures:** Is the team stable, engaged, and growing?
|
||||
|
||||
Key metrics:
|
||||
- **Regrettable attrition (annualized)** — Green: <10%, Yellow: 10-20%, Red: >20%
|
||||
- **Engagement score** — (eNPS or similar; Green: >30, Yellow: 0-30, Red: <0)
|
||||
- **Time-to-fill (avg days)** — Green: <45, Yellow: 45-90, Red: >90
|
||||
- **Manager-to-IC ratio** — Green: 1:5–1:8, Yellow: 1:3–1:5 or 1:8–1:12, Red: outside
|
||||
- **Internal promotion rate** — at least 25-30% of senior roles filled internally
|
||||
|
||||
### 6. 🔄 Operational Health (COO)
|
||||
**What it measures:** Are we executing our strategy with discipline?
|
||||
|
||||
Key metrics:
|
||||
- **OKR completion rate** — % of key results hitting target (Green: >70%, Yellow: 50-70%, Red: <50%)
|
||||
- **Decision cycle time** — days from decision needed to decision made (Green: <48h, Yellow: 48h-1w)
|
||||
- **Meeting effectiveness** — % of meetings with clear outcome (qualitative)
|
||||
- **Process maturity** — level 1-5 scale (see COO advisor)
|
||||
- **Cross-functional initiative completion** — % on time, on scope
|
||||
|
||||
### 7. 🔒 Security Health (CISO)
|
||||
**What it measures:** Are we protecting customers and maintaining compliance?
|
||||
|
||||
Key metrics:
|
||||
- **Security incidents (last 90 days)** — Green: 0, Yellow: 1-2 minor, Red: 1+ major
|
||||
- **Compliance status** — certifications current/in-progress vs. overdue
|
||||
- **Vulnerability remediation SLA** — % of critical CVEs patched within SLA (Green: 100%)
|
||||
- **Security training completion** — % of team current (Green: >95%)
|
||||
- **Pen test recency** — Green: <12 months, Yellow: 12-24, Red: >24 months
|
||||
|
||||
### 8. 📣 Market Health (CMO)
|
||||
**What it measures:** Are we winning in the market and growing efficiently?
|
||||
|
||||
Key metrics:
|
||||
- **CAC trend** — improving, flat, or worsening QoQ
|
||||
- **Organic vs paid lead mix** — more organic = healthier (less fragile)
|
||||
- **Win rate** — % of qualified opportunities closed-won (Green: >25%, Yellow: 15-25%, Red: <15%)
|
||||
- **Competitive win rate** — against primary competitors specifically
|
||||
- **Brand NPS** — awareness + preference scores in ICP
|
||||
|
||||
---
|
||||
|
||||
## Scoring & Traffic Lights
|
||||
|
||||
Each dimension is scored 1-10 with traffic light:
|
||||
- 🟢 **Green (7-10):** Healthy — maintain and optimize
|
||||
- 🟡 **Yellow (4-6):** Watch — trend matters; improving or declining?
|
||||
- 🔴 **Red (1-3):** Action required — address within 30 days
|
||||
|
||||
**Overall Health Score:**
|
||||
Weighted average by company stage (see `references/health-benchmarks.md` for weights).
|
||||
|
||||
---
|
||||
|
||||
## Dimension Interactions (Why One Problem Creates Another)
|
||||
|
||||
| If this dimension is red... | Watch these dimensions next |
|
||||
|-----------------------------|----------------------------|
|
||||
| Financial Health | People (freeze hiring) → Engineering (freeze infra) → Product (cut scope) |
|
||||
| Revenue Health | Financial (cash gap) → People (attrition risk) → Market (lose positioning) |
|
||||
| People Health | Engineering (velocity drops) → Product (quality drops) → Revenue (churn rises) |
|
||||
| Engineering Health | Product (features slip) → Revenue (deals stall on product) |
|
||||
| Product Health | Revenue (NRR drops, churn rises) → Market (CAC rises; referrals dry up) |
|
||||
| Operational Health | All dimensions degrade over time (execution failure cascades everywhere) |
|
||||
|
||||
---
|
||||
|
||||
## Dashboard Output Format
|
||||
|
||||
```
|
||||
ORG HEALTH DIAGNOSTIC — [Company] — [Date]
|
||||
Stage: [Seed/A/B/C] Overall: [Score]/10 Trend: [↑ Improving / → Stable / ↓ Declining]
|
||||
|
||||
DIMENSION SCORES
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
💰 Financial 🟢 8.2 Runway 14mo, burn 1.6x — strong
|
||||
📈 Revenue 🟡 5.8 NRR 104%, pipeline thin (1.8x coverage)
|
||||
🚀 Product 🟢 7.4 NPS 42, DAU/MAU 38%
|
||||
⚙️ Engineering 🟡 5.2 Debt at 30%, MTTR 3.2h
|
||||
👥 People 🔴 3.8 Attrition 24%, eng morale low
|
||||
🔄 Operations 🟡 6.0 OKR 65% completion
|
||||
🔒 Security 🟢 7.8 SOC 2 Type II complete, 0 incidents
|
||||
📣 Market 🟡 5.5 CAC rising, win rate dropped to 22%
|
||||
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
|
||||
TOP PRIORITIES
|
||||
🔴 [1] People: attrition at 24% — engineering velocity will drop in 60 days
|
||||
Action: CHRO + CEO to run retention audit; target top 5 at-risk this week
|
||||
🟡 [2] Revenue: pipeline coverage at 1.8x — Q+1 miss risk is high
|
||||
Action: CRO to add 3 qualified opps within 30 days or shift forecast down
|
||||
🟡 [3] Engineering: tech debt at 30% of sprint — shipping will slow by Q3
|
||||
Action: CTO to propose debt sprint plan; COO to protect capacity
|
||||
|
||||
WATCH
|
||||
→ People → Engineering cascade risk if attrition continues (see dimension interactions)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Graceful Degradation
|
||||
|
||||
You don't need all metrics to run a diagnostic. The tool handles partial data:
|
||||
- Missing metric → excluded from score, flagged as "[data needed]"
|
||||
- Score still valid for available dimensions
|
||||
- Report flags which gaps to fill for next cycle
|
||||
|
||||
## References
|
||||
- `references/health-benchmarks.md` — benchmarks by stage (Seed, A, B, C)
|
||||
- `scripts/health_scorer.py` — CLI scoring tool with traffic light output
|
||||
222
docs/skills/c-level-advisor/scenario-war-room.md
Normal file
222
docs/skills/c-level-advisor/scenario-war-room.md
Normal file
@@ -0,0 +1,222 @@
|
||||
---
|
||||
title: "Scenario War Room"
|
||||
description: "Scenario War Room - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Scenario War Room
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `scenario-war-room` | **Source:** [`c-level-advisor/scenario-war-room/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/scenario-war-room/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Scenario War Room
|
||||
|
||||
Model cascading what-if scenarios across all business functions. Not single-assumption stress tests — compound adversity that shows how one problem creates the next.
|
||||
|
||||
## Keywords
|
||||
scenario planning, war room, what-if analysis, risk modeling, cascading effects, compound risk, adversity planning, contingency planning, stress test, crisis planning, multi-variable scenario, pre-mortem
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
python scripts/scenario_modeler.py # Interactive scenario builder with cascade modeling
|
||||
```
|
||||
|
||||
Or describe the scenario:
|
||||
```
|
||||
/war-room "What if we lose our top customer AND miss the Q3 fundraise?"
|
||||
/war-room "What if 3 engineers quit AND we need to ship by Q3?"
|
||||
/war-room "What if our market shrinks 30% AND a competitor raises $50M?"
|
||||
```
|
||||
|
||||
## What This Is Not
|
||||
|
||||
- **Not** a single-assumption stress test (that's `/em:stress-test`)
|
||||
- **Not** financial modeling only — every function gets modeled
|
||||
- **Not** worst-case-only — models 3 severity levels
|
||||
- **Not** paralysis by analysis — outputs concrete hedges and triggers
|
||||
|
||||
## Framework: 6-Step Cascade Model
|
||||
|
||||
### Step 1: Define Scenario Variables (max 3)
|
||||
State each variable with:
|
||||
- **What changes** — specific, quantified if possible
|
||||
- **Probability** — your best estimate
|
||||
- **Timeline** — when it hits
|
||||
|
||||
```
|
||||
Variable A: Top customer (28% ARR) gives 60-day termination notice
|
||||
Probability: 15% | Timeline: Within 90 days
|
||||
|
||||
Variable B: Series A fundraise delayed 6 months beyond target close
|
||||
Probability: 25% | Timeline: Q3
|
||||
|
||||
Variable C: Lead engineer resigns
|
||||
Probability: 20% | Timeline: Unknown
|
||||
```
|
||||
|
||||
### Step 2: Domain Impact Mapping
|
||||
|
||||
For each variable, each relevant role models impact:
|
||||
|
||||
| Domain | Owner | Models |
|
||||
|--------|-------|--------|
|
||||
| Cash & runway | CFO | Burn impact, runway change, bridge options |
|
||||
| Revenue | CRO | ARR gap, churn cascade risk, pipeline |
|
||||
| Product | CPO | Roadmap impact, PMF risk |
|
||||
| Engineering | CTO | Velocity impact, key person risk |
|
||||
| People | CHRO | Attrition cascade, hiring freeze implications |
|
||||
| Operations | COO | Capacity, OKR impact, process risk |
|
||||
| Security | CISO | Compliance timeline risk |
|
||||
| Market | CMO | CAC impact, competitive exposure |
|
||||
|
||||
### Step 3: Cascade Effect Mapping
|
||||
|
||||
This is the core. Show how Variable A triggers consequences in domains that trigger Variable B's effects:
|
||||
|
||||
```
|
||||
TRIGGER: Customer churn ($560K ARR)
|
||||
↓
|
||||
CFO: Runway drops 14 → 8 months
|
||||
↓
|
||||
CHRO: Hiring freeze; retention risk increases (morale hit)
|
||||
↓
|
||||
CTO: 3 open engineering reqs frozen; roadmap slips
|
||||
↓
|
||||
CPO: Q4 feature launch delayed → customer retention risk
|
||||
↓
|
||||
CRO: NRR drops; existing accounts see reduced velocity → more churn risk
|
||||
↓
|
||||
CFO: [Secondary cascade — potential death spiral if not interrupted]
|
||||
```
|
||||
|
||||
Name the cascade explicitly. Show where it can be interrupted.
|
||||
|
||||
### Step 4: Severity Matrix
|
||||
|
||||
Model three scenarios:
|
||||
|
||||
| Scenario | Definition | Recovery |
|
||||
|----------|------------|---------|
|
||||
| **Base** | One variable hits; others don't | Manageable with plan |
|
||||
| **Stress** | Two variables hit simultaneously | Requires significant response |
|
||||
| **Severe** | All variables hit; full cascade | Existential; requires board intervention |
|
||||
|
||||
For each severity level:
|
||||
- Runway impact
|
||||
- ARR impact
|
||||
- Headcount impact
|
||||
- Timeline to unacceptable state (trigger point)
|
||||
|
||||
### Step 5: Trigger Points (Early Warning Signals)
|
||||
|
||||
Define the measurable signal that tells you a scenario is unfolding **before** it's confirmed:
|
||||
|
||||
```
|
||||
Trigger for Customer Churn Risk:
|
||||
- Sponsor goes dark for >3 weeks
|
||||
- Usage drops >25% MoM
|
||||
- No Q1 QBR confirmed by Dec 1
|
||||
|
||||
Trigger for Fundraise Delay:
|
||||
- <3 term sheets after 60 days of process
|
||||
- Lead investor requests >30-day extension on DD
|
||||
- Competitor raises at lower valuation (market signal)
|
||||
|
||||
Trigger for Engineering Attrition:
|
||||
- Glassdoor activity from engineering team
|
||||
- 2+ referral interview requests from engineers
|
||||
- Above-market offer counter-required in last 3 months
|
||||
```
|
||||
|
||||
### Step 6: Hedging Strategies
|
||||
|
||||
For each scenario: actions to take **now** (before the scenario materializes) that reduce impact if it does.
|
||||
|
||||
| Hedge | Cost | Impact | Owner | Deadline |
|
||||
|-------|------|--------|-------|---------|
|
||||
| Establish $500K credit line | $5K/year | Buys 3 months if churn hits | CFO | 60 days |
|
||||
| 12-month retention bonus for 3 key engineers | $90K | Locks team through fundraise | CHRO | 30 days |
|
||||
| Diversify to <20% revenue concentration per customer | Sales effort | Reduces single-customer risk | CRO | 2 quarters |
|
||||
| Compress fundraise timeline, start parallel process | CEO time | Closes before runways merge | CEO | Immediate |
|
||||
|
||||
---
|
||||
|
||||
## Output Format
|
||||
|
||||
Every war room session produces:
|
||||
|
||||
```
|
||||
SCENARIO: [Name]
|
||||
Variables: [A, B, C]
|
||||
Most likely path: [which combination actually plays out, with probability]
|
||||
|
||||
SEVERITY LEVELS
|
||||
Base (A only): [runway/ARR impact] — recovery: [X actions]
|
||||
Stress (A+B): [runway/ARR impact] — recovery: [X actions]
|
||||
Severe (A+B+C): [runway/ARR impact] — existential risk: [yes/no]
|
||||
|
||||
CASCADE MAP
|
||||
[A → domain impact → B trigger → domain impact → end state]
|
||||
|
||||
EARLY WARNING SIGNALS
|
||||
- [Signal 1 → which scenario it indicates]
|
||||
- [Signal 2 → which scenario it indicates]
|
||||
- [Signal 3 → which scenario it indicates]
|
||||
|
||||
HEDGES (take these actions now)
|
||||
1. [Action] — cost: $X — impact: [what it buys] — owner: [role] — deadline: [date]
|
||||
2. [Action] — cost: $X — impact: [what it buys] — owner: [role] — deadline: [date]
|
||||
3. [Action] — cost: $X — impact: [what it buys] — owner: [role] — deadline: [date]
|
||||
|
||||
RECOMMENDED DECISION
|
||||
[One paragraph. What to do, in what order, and why.]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Rules for Good War Room Sessions
|
||||
|
||||
**Max 3 variables per scenario.** More than 3 is noise — you can't meaningfully prepare for 5-variable collapse. Model the 3 that actually worry you.
|
||||
|
||||
**Quantify or estimate.** "Revenue drops" is not useful. "$420K ARR at risk over 60 days" is. Use ranges if uncertain.
|
||||
|
||||
**Don't stop at first-order effects.** The damage is always in the cascade, not the initial hit.
|
||||
|
||||
**Model recovery, not just impact.** Every scenario should have a "what we do" path.
|
||||
|
||||
**Separate base case from sensitivity.** Don't conflate "what probably happens" with "what could happen."
|
||||
|
||||
**Don't over-model.** 3-4 scenarios per planning cycle is the right number. More creates analysis paralysis.
|
||||
|
||||
---
|
||||
|
||||
## Common Scenarios by Stage
|
||||
|
||||
**Seed:**
|
||||
- Co-founder leaves + product misses launch
|
||||
- Funding runs out + bridge terms unfavorable
|
||||
|
||||
**Series A:**
|
||||
- Miss ARR target + fundraise delayed
|
||||
- Key customer churns + competitor raises
|
||||
|
||||
**Series B:**
|
||||
- Market contraction + burn multiple spikes
|
||||
- Lead investor wants pivot + team resists
|
||||
|
||||
## Integration with C-Suite Roles
|
||||
|
||||
| Scenario Type | Primary Roles | Cascade To |
|
||||
|--------------|---------------|------------|
|
||||
| Revenue miss | CRO, CFO | CMO (pipeline), COO (cuts), CHRO (layoffs) |
|
||||
| Key person departure | CHRO, COO | CTO (if eng), CRO (if sales) |
|
||||
| Fundraise failure | CFO, CEO | COO (runway extension), CHRO (hiring freeze) |
|
||||
| Security breach | CISO, CTO | CEO (comms), CFO (cost), CRO (customer impact) |
|
||||
| Market shift | CEO, CPO | CMO (repositioning), CRO (new segments) |
|
||||
| Competitor move | CMO, CRO | CPO (roadmap response), CEO (strategy) |
|
||||
|
||||
## References
|
||||
- `references/scenario-planning.md` — Shell methodology, pre-mortem, Monte Carlo, cascade frameworks
|
||||
- `scripts/scenario_modeler.py` — CLI tool for structured scenario modeling
|
||||
192
docs/skills/c-level-advisor/strategic-alignment.md
Normal file
192
docs/skills/c-level-advisor/strategic-alignment.md
Normal file
@@ -0,0 +1,192 @@
|
||||
---
|
||||
title: "Strategic Alignment Engine"
|
||||
description: "Strategic Alignment Engine - Claude Code skill from the C-Level Advisory domain."
|
||||
---
|
||||
|
||||
# Strategic Alignment Engine
|
||||
|
||||
**Domain:** C-Level Advisory | **Skill:** `strategic-alignment` | **Source:** [`c-level-advisor/strategic-alignment/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/c-level-advisor/strategic-alignment/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Strategic Alignment Engine
|
||||
|
||||
Strategy fails at the cascade, not the boardroom. This skill detects misalignment before it becomes dysfunction and builds systems that keep strategy connected from CEO to individual contributor.
|
||||
|
||||
## Keywords
|
||||
strategic alignment, strategy cascade, OKR alignment, orphan OKRs, conflicting goals, silos, communication gap, department alignment, alignment checker, strategy articulation, cross-functional, goal cascade, misalignment, alignment score
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
python scripts/alignment_checker.py # Check OKR alignment: orphans, conflicts, coverage gaps
|
||||
```
|
||||
|
||||
## Core Framework
|
||||
|
||||
The alignment problem: **The further a goal gets from the strategy that created it, the less likely it reflects the original intent.** This is the organizational telephone game. It happens at every stage. The question is how bad it is and how to fix it.
|
||||
|
||||
### Step 1: Strategy Articulation Test
|
||||
|
||||
Before checking cascade, check the source. Ask five people from five different teams:
|
||||
**"What is the company's most important strategic priority right now?"**
|
||||
|
||||
**Scoring:**
|
||||
- All five give the same answer: ✅ Articulation is clear
|
||||
- 3–4 give similar answers: 🟡 Loose alignment — clarify and communicate
|
||||
- < 3 agree: 🔴 Strategy isn't clear enough to cascade. Fix this before fixing cascade.
|
||||
|
||||
**Format test:** The strategy should be statable in one sentence. If leadership needs a paragraph, teams won't internalize it.
|
||||
- ❌ "We focus on product-led growth while maintaining enterprise relationships and expanding our international presence and investing in platform capabilities"
|
||||
- ✅ "Win the mid-market healthcare segment in DACH before Series B"
|
||||
|
||||
### Step 2: Cascade Mapping
|
||||
|
||||
Map the flow from company strategy → each level of the organization.
|
||||
|
||||
```
|
||||
Company level: OKR-1, OKR-2, OKR-3
|
||||
↓
|
||||
Dept level: Sales OKRs, Eng OKRs, Product OKRs, CS OKRs
|
||||
↓
|
||||
Team level: Team A OKRs, Team B OKRs...
|
||||
↓
|
||||
Individual: Personal goals / rocks
|
||||
```
|
||||
|
||||
**For each goal at every level, ask:**
|
||||
- Which company-level goal does this support?
|
||||
- If this goal is 100% achieved, how much does it move the company goal?
|
||||
- Is the connection direct or theoretical?
|
||||
|
||||
### Step 3: Alignment Detection
|
||||
|
||||
Three failure patterns:
|
||||
|
||||
**Orphan goals:** Team or individual goals that don't connect to any company goal.
|
||||
- Symptom: "We've been working on this for a quarter and nobody above us seems to care"
|
||||
- Root cause: Goals set bottom-up or from last quarter's priorities without reconciling to current company OKRs
|
||||
- Fix: Connect or cut. Every goal needs a parent.
|
||||
|
||||
**Conflicting goals:** Two teams' goals, when both succeed, create a worse outcome.
|
||||
- Classic example: Sales commits to volume contracts (revenue), CS is measured on satisfaction scores. Sales closes bad-fit customers; CS scores tank.
|
||||
- Fix: Cross-functional OKR review before quarter begins. Shared metrics where teams interact.
|
||||
|
||||
**Coverage gaps:** Company has 3 OKRs. 5 teams support OKR-1, 2 support OKR-2, 0 support OKR-3.
|
||||
- Symptom: Company OKR-3 consistently misses; nobody owns it
|
||||
- Fix: Explicit ownership assignment. If no team owns a company OKR, it won't happen.
|
||||
|
||||
See `scripts/alignment_checker.py` for automated detection against your JSON-formatted OKRs.
|
||||
|
||||
### Step 4: Silo Identification
|
||||
|
||||
Silos exist when teams optimize for local metrics at the expense of company metrics.
|
||||
|
||||
**Silo signals:**
|
||||
- A department consistently hits their goals while the company misses
|
||||
- Teams don't know what other teams are working on
|
||||
- "That's not our problem" is a common phrase
|
||||
- Escalations only flow up; coordination never flows sideways
|
||||
- Data isn't shared between teams that depend on each other
|
||||
|
||||
**Silo root causes:**
|
||||
1. **Incentive misalignment:** Teams rewarded for local metrics don't optimize for company metrics
|
||||
2. **No shared goals:** When teams share a goal, they coordinate. When they don't, they drift.
|
||||
3. **No shared language:** Engineering doesn't understand sales metrics; sales doesn't understand technical debt
|
||||
4. **Geography or time zones:** Silos accelerate when teams don't interact organically
|
||||
|
||||
**Silo measurement:**
|
||||
- How often do teams request something from each other vs. proceed independently?
|
||||
- How much time does it take to resolve a cross-functional issue?
|
||||
- Can a team member describe the current priorities of an adjacent team?
|
||||
|
||||
### Step 5: Communication Gap Analysis
|
||||
|
||||
What the CEO says ≠ what teams hear. The gap grows with company size.
|
||||
|
||||
**The message decay model:**
|
||||
- CEO communicates strategy at all-hands → managers filter through their lens → teams receive modified version → individuals interpret further
|
||||
|
||||
**Gap sources:**
|
||||
- **Ambiguity:** Strategy stated at too high a level ("grow the business") lets each team fill in their own interpretation
|
||||
- **Frequency:** One all-hands per quarter isn't enough repetition to change behavior
|
||||
- **Medium mismatch:** Long written strategy doc for teams that respond to visual communication
|
||||
- **Trust deficit:** Teams don't believe the strategy is real ("we've heard this before")
|
||||
|
||||
**Gap detection:**
|
||||
- Run the Step 1 articulation test across all levels
|
||||
- Compare what leadership thinks they communicated vs. what teams say they heard
|
||||
- Survey: "What changed about how you work since the last strategy update?"
|
||||
|
||||
### Step 6: Realignment Protocol
|
||||
|
||||
How to fix misalignment without calling it a "realignment" (which creates fear).
|
||||
|
||||
**Step 6a: Don't start with what's wrong**
|
||||
Starting with "here's our misalignment" creates defensiveness. Start with "here's where we're heading and I want to make sure we're connected."
|
||||
|
||||
**Step 6b: Re-cascade in a workshop, not a memo**
|
||||
Alignment workshops are more effective than documents. Get company-level OKR owners and department leads in a room. Map connections. Find gaps together.
|
||||
|
||||
**Step 6c: Fix incentives before fixing goals**
|
||||
If department heads are rewarded for local metrics that conflict with company goals, no amount of goal-setting fixes the problem. The incentive structure must change first.
|
||||
|
||||
**Step 6d: Install a quarterly alignment check**
|
||||
After fixing, prevent recurrence. See `references/alignment-playbook.md` for quarterly cadence.
|
||||
|
||||
---
|
||||
|
||||
## Alignment Score
|
||||
|
||||
A quick health check. Score each area 0–10:
|
||||
|
||||
| Area | Question | Score |
|
||||
|------|----------|-------|
|
||||
| Strategy clarity | Can 5 people from different teams state the strategy consistently? | /10 |
|
||||
| Cascade completeness | Do all team goals connect to company goals? | /10 |
|
||||
| Conflict detection | Have cross-team OKR conflicts been reviewed and resolved? | /10 |
|
||||
| Coverage | Does each company OKR have explicit team ownership? | /10 |
|
||||
| Communication | Do teams' behaviors reflect the strategy (not just their stated understanding)? | /10 |
|
||||
|
||||
**Total: __ / 50**
|
||||
|
||||
| Score | Status |
|
||||
|-------|--------|
|
||||
| 45–50 | Excellent. Maintain the system. |
|
||||
| 35–44 | Good. Address specific weak areas. |
|
||||
| 20–34 | Misalignment is costing you. Immediate attention required. |
|
||||
| < 20 | Strategic drift. Treat as crisis. |
|
||||
|
||||
---
|
||||
|
||||
## Key Questions for Alignment
|
||||
|
||||
- "Ask your newest team member: what is the most important thing the company is trying to achieve right now?"
|
||||
- "Which company OKR does your team's top priority support? Can you trace the connection?"
|
||||
- "When Team A and Team B both hit their goals, does the company always win? Are there scenarios where they don't?"
|
||||
- "What changed in how your team works since the last strategy update?"
|
||||
- "Name a decision made last week that was influenced by the company strategy."
|
||||
|
||||
## Red Flags
|
||||
|
||||
- Teams consistently hit goals while company misses targets
|
||||
- Cross-functional projects take 3x longer than expected (coordination failure)
|
||||
- Strategy updated quarterly but team priorities don't change
|
||||
- "That's a leadership problem, not our problem" attitude at the team level
|
||||
- New initiatives announced without connecting them to existing OKRs
|
||||
- Department heads optimize for headcount or budget rather than company outcomes
|
||||
|
||||
## Integration with Other C-Suite Roles
|
||||
|
||||
| When... | Work with... | To... |
|
||||
|---------|-------------|-------|
|
||||
| New strategy is set | CEO + COO | Cascade into quarterly rocks before announcing |
|
||||
| OKR cycle starts | COO | Run cross-team conflict check before finalizing |
|
||||
| Team consistently misses goals | CHRO | Diagnose: capability gap or alignment gap? |
|
||||
| Silo identified | COO | Design shared metrics or cross-functional OKRs |
|
||||
| Post-M&A | CEO + Culture Architect | Detect strategy conflicts between merged entities |
|
||||
|
||||
## Detailed References
|
||||
- `scripts/alignment_checker.py` — Automated OKR alignment analysis (orphans, conflicts, coverage)
|
||||
- `references/alignment-playbook.md` — Cascade techniques, quarterly alignment check, common patterns
|
||||
313
docs/skills/engineering-team/aws-solution-architect.md
Normal file
313
docs/skills/engineering-team/aws-solution-architect.md
Normal file
@@ -0,0 +1,313 @@
|
||||
---
|
||||
title: "AWS Solution Architect"
|
||||
description: "AWS Solution Architect - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# AWS Solution Architect
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `aws-solution-architect` | **Source:** [`engineering-team/aws-solution-architect/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/aws-solution-architect/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# AWS Solution Architect
|
||||
|
||||
Design scalable, cost-effective AWS architectures for startups with infrastructure-as-code templates.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Trigger Terms](#trigger-terms)
|
||||
- [Workflow](#workflow)
|
||||
- [Tools](#tools)
|
||||
- [Quick Start](#quick-start)
|
||||
- [Input Requirements](#input-requirements)
|
||||
- [Output Formats](#output-formats)
|
||||
|
||||
---
|
||||
|
||||
## Trigger Terms
|
||||
|
||||
Use this skill when you encounter:
|
||||
|
||||
| Category | Terms |
|
||||
|----------|-------|
|
||||
| **Architecture Design** | serverless architecture, AWS architecture, cloud design, microservices, three-tier |
|
||||
| **IaC Generation** | CloudFormation, CDK, Terraform, infrastructure as code, deploy template |
|
||||
| **Serverless** | Lambda, API Gateway, DynamoDB, Step Functions, EventBridge, AppSync |
|
||||
| **Containers** | ECS, Fargate, EKS, container orchestration, Docker on AWS |
|
||||
| **Cost Optimization** | reduce AWS costs, optimize spending, right-sizing, Savings Plans |
|
||||
| **Database** | Aurora, RDS, DynamoDB design, database migration, data modeling |
|
||||
| **Security** | IAM policies, VPC design, encryption, Cognito, WAF |
|
||||
| **CI/CD** | CodePipeline, CodeBuild, CodeDeploy, GitHub Actions AWS |
|
||||
| **Monitoring** | CloudWatch, X-Ray, observability, alarms, dashboards |
|
||||
| **Migration** | migrate to AWS, lift and shift, replatform, DMS |
|
||||
|
||||
---
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 1: Gather Requirements
|
||||
|
||||
Collect application specifications:
|
||||
|
||||
```
|
||||
- Application type (web app, mobile backend, data pipeline, SaaS)
|
||||
- Expected users and requests per second
|
||||
- Budget constraints (monthly spend limit)
|
||||
- Team size and AWS experience level
|
||||
- Compliance requirements (GDPR, HIPAA, SOC 2)
|
||||
- Availability requirements (SLA, RPO/RTO)
|
||||
```
|
||||
|
||||
### Step 2: Design Architecture
|
||||
|
||||
Run the architecture designer to get pattern recommendations:
|
||||
|
||||
```bash
|
||||
python scripts/architecture_designer.py --input requirements.json
|
||||
```
|
||||
|
||||
Select from recommended patterns:
|
||||
- **Serverless Web**: S3 + CloudFront + API Gateway + Lambda + DynamoDB
|
||||
- **Event-Driven Microservices**: EventBridge + Lambda + SQS + Step Functions
|
||||
- **Three-Tier**: ALB + ECS Fargate + Aurora + ElastiCache
|
||||
- **GraphQL Backend**: AppSync + Lambda + DynamoDB + Cognito
|
||||
|
||||
See `references/architecture_patterns.md` for detailed pattern specifications.
|
||||
|
||||
### Step 3: Generate IaC Templates
|
||||
|
||||
Create infrastructure-as-code for the selected pattern:
|
||||
|
||||
```bash
|
||||
# Serverless stack (CloudFormation)
|
||||
python scripts/serverless_stack.py --app-name my-app --region us-east-1
|
||||
|
||||
# Output: CloudFormation YAML template ready to deploy
|
||||
```
|
||||
|
||||
### Step 4: Review Costs
|
||||
|
||||
Analyze estimated costs and optimization opportunities:
|
||||
|
||||
```bash
|
||||
python scripts/cost_optimizer.py --resources current_setup.json --monthly-spend 2000
|
||||
```
|
||||
|
||||
Output includes:
|
||||
- Monthly cost breakdown by service
|
||||
- Right-sizing recommendations
|
||||
- Savings Plans opportunities
|
||||
- Potential monthly savings
|
||||
|
||||
### Step 5: Deploy
|
||||
|
||||
Deploy the generated infrastructure:
|
||||
|
||||
```bash
|
||||
# CloudFormation
|
||||
aws cloudformation create-stack \
|
||||
--stack-name my-app-stack \
|
||||
--template-body file://template.yaml \
|
||||
--capabilities CAPABILITY_IAM
|
||||
|
||||
# CDK
|
||||
cdk deploy
|
||||
|
||||
# Terraform
|
||||
terraform init && terraform apply
|
||||
```
|
||||
|
||||
### Step 6: Validate
|
||||
|
||||
Verify deployment and set up monitoring:
|
||||
|
||||
```bash
|
||||
# Check stack status
|
||||
aws cloudformation describe-stacks --stack-name my-app-stack
|
||||
|
||||
# Set up CloudWatch alarms
|
||||
aws cloudwatch put-metric-alarm --alarm-name high-errors ...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tools
|
||||
|
||||
### architecture_designer.py
|
||||
|
||||
Generates architecture patterns based on requirements.
|
||||
|
||||
```bash
|
||||
python scripts/architecture_designer.py --input requirements.json --output design.json
|
||||
```
|
||||
|
||||
**Input:** JSON with app type, scale, budget, compliance needs
|
||||
**Output:** Recommended pattern, service stack, cost estimate, pros/cons
|
||||
|
||||
### serverless_stack.py
|
||||
|
||||
Creates serverless CloudFormation templates.
|
||||
|
||||
```bash
|
||||
python scripts/serverless_stack.py --app-name my-app --region us-east-1
|
||||
```
|
||||
|
||||
**Output:** Production-ready CloudFormation YAML with:
|
||||
- API Gateway + Lambda
|
||||
- DynamoDB table
|
||||
- Cognito user pool
|
||||
- IAM roles with least privilege
|
||||
- CloudWatch logging
|
||||
|
||||
### cost_optimizer.py
|
||||
|
||||
Analyzes costs and recommends optimizations.
|
||||
|
||||
```bash
|
||||
python scripts/cost_optimizer.py --resources inventory.json --monthly-spend 5000
|
||||
```
|
||||
|
||||
**Output:** Recommendations for:
|
||||
- Idle resource removal
|
||||
- Instance right-sizing
|
||||
- Reserved capacity purchases
|
||||
- Storage tier transitions
|
||||
- NAT Gateway alternatives
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
### MVP Architecture (< $100/month)
|
||||
|
||||
```
|
||||
Ask: "Design a serverless MVP backend for a mobile app with 1000 users"
|
||||
|
||||
Result:
|
||||
- Lambda + API Gateway for API
|
||||
- DynamoDB pay-per-request for data
|
||||
- Cognito for authentication
|
||||
- S3 + CloudFront for static assets
|
||||
- Estimated: $20-50/month
|
||||
```
|
||||
|
||||
### Scaling Architecture ($500-2000/month)
|
||||
|
||||
```
|
||||
Ask: "Design a scalable architecture for a SaaS platform with 50k users"
|
||||
|
||||
Result:
|
||||
- ECS Fargate for containerized API
|
||||
- Aurora Serverless for relational data
|
||||
- ElastiCache for session caching
|
||||
- CloudFront for CDN
|
||||
- CodePipeline for CI/CD
|
||||
- Multi-AZ deployment
|
||||
```
|
||||
|
||||
### Cost Optimization
|
||||
|
||||
```
|
||||
Ask: "Optimize my AWS setup to reduce costs by 30%. Current spend: $3000/month"
|
||||
|
||||
Provide: Current resource inventory (EC2, RDS, S3, etc.)
|
||||
|
||||
Result:
|
||||
- Idle resource identification
|
||||
- Right-sizing recommendations
|
||||
- Savings Plans analysis
|
||||
- Storage lifecycle policies
|
||||
- Target savings: $900/month
|
||||
```
|
||||
|
||||
### IaC Generation
|
||||
|
||||
```
|
||||
Ask: "Generate CloudFormation for a three-tier web app with auto-scaling"
|
||||
|
||||
Result:
|
||||
- VPC with public/private subnets
|
||||
- ALB with HTTPS
|
||||
- ECS Fargate with auto-scaling
|
||||
- Aurora with read replicas
|
||||
- Security groups and IAM roles
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Input Requirements
|
||||
|
||||
Provide these details for architecture design:
|
||||
|
||||
| Requirement | Description | Example |
|
||||
|-------------|-------------|---------|
|
||||
| Application type | What you're building | SaaS platform, mobile backend |
|
||||
| Expected scale | Users, requests/sec | 10k users, 100 RPS |
|
||||
| Budget | Monthly AWS limit | $500/month max |
|
||||
| Team context | Size, AWS experience | 3 devs, intermediate |
|
||||
| Compliance | Regulatory needs | HIPAA, GDPR, SOC 2 |
|
||||
| Availability | Uptime requirements | 99.9% SLA, 1hr RPO |
|
||||
|
||||
**JSON Format:**
|
||||
|
||||
```json
|
||||
{
|
||||
"application_type": "saas_platform",
|
||||
"expected_users": 10000,
|
||||
"requests_per_second": 100,
|
||||
"budget_monthly_usd": 500,
|
||||
"team_size": 3,
|
||||
"aws_experience": "intermediate",
|
||||
"compliance": ["SOC2"],
|
||||
"availability_sla": "99.9%"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Output Formats
|
||||
|
||||
### Architecture Design
|
||||
|
||||
- Pattern recommendation with rationale
|
||||
- Service stack diagram (ASCII)
|
||||
- Configuration specifications
|
||||
- Monthly cost estimate
|
||||
- Scaling characteristics
|
||||
- Trade-offs and limitations
|
||||
|
||||
### IaC Templates
|
||||
|
||||
- **CloudFormation YAML**: Production-ready SAM/CFN templates
|
||||
- **CDK TypeScript**: Type-safe infrastructure code
|
||||
- **Terraform HCL**: Multi-cloud compatible configs
|
||||
|
||||
### Cost Analysis
|
||||
|
||||
- Current spend breakdown
|
||||
- Optimization recommendations with savings
|
||||
- Priority action list (high/medium/low)
|
||||
- Implementation checklist
|
||||
|
||||
---
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
| Document | Contents |
|
||||
|----------|----------|
|
||||
| `references/architecture_patterns.md` | 6 patterns: serverless, microservices, three-tier, data processing, GraphQL, multi-region |
|
||||
| `references/service_selection.md` | Decision matrices for compute, database, storage, messaging |
|
||||
| `references/best_practices.md` | Serverless design, cost optimization, security hardening, scalability |
|
||||
|
||||
---
|
||||
|
||||
## Limitations
|
||||
|
||||
- Lambda: 15-minute execution, 10GB memory max
|
||||
- API Gateway: 29-second timeout, 10MB payload
|
||||
- DynamoDB: 400KB item size, eventually consistent by default
|
||||
- Regional availability varies by service
|
||||
- Some services have AWS-specific lock-in
|
||||
184
docs/skills/engineering-team/code-reviewer.md
Normal file
184
docs/skills/engineering-team/code-reviewer.md
Normal file
@@ -0,0 +1,184 @@
|
||||
---
|
||||
title: "Code Reviewer"
|
||||
description: "Code Reviewer - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Code Reviewer
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `code-reviewer` | **Source:** [`engineering-team/code-reviewer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/code-reviewer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Code Reviewer
|
||||
|
||||
Automated code review tools for analyzing pull requests, detecting code quality issues, and generating review reports.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Tools](#tools)
|
||||
- [PR Analyzer](#pr-analyzer)
|
||||
- [Code Quality Checker](#code-quality-checker)
|
||||
- [Review Report Generator](#review-report-generator)
|
||||
- [Reference Guides](#reference-guides)
|
||||
- [Languages Supported](#languages-supported)
|
||||
|
||||
---
|
||||
|
||||
## Tools
|
||||
|
||||
### PR Analyzer
|
||||
|
||||
Analyzes git diff between branches to assess review complexity and identify risks.
|
||||
|
||||
```bash
|
||||
# Analyze current branch against main
|
||||
python scripts/pr_analyzer.py /path/to/repo
|
||||
|
||||
# Compare specific branches
|
||||
python scripts/pr_analyzer.py . --base main --head feature-branch
|
||||
|
||||
# JSON output for integration
|
||||
python scripts/pr_analyzer.py /path/to/repo --json
|
||||
```
|
||||
|
||||
**What it detects:**
|
||||
- Hardcoded secrets (passwords, API keys, tokens)
|
||||
- SQL injection patterns (string concatenation in queries)
|
||||
- Debug statements (debugger, console.log)
|
||||
- ESLint rule disabling
|
||||
- TypeScript `any` types
|
||||
- TODO/FIXME comments
|
||||
|
||||
**Output includes:**
|
||||
- Complexity score (1-10)
|
||||
- Risk categorization (critical, high, medium, low)
|
||||
- File prioritization for review order
|
||||
- Commit message validation
|
||||
|
||||
---
|
||||
|
||||
### Code Quality Checker
|
||||
|
||||
Analyzes source code for structural issues, code smells, and SOLID violations.
|
||||
|
||||
```bash
|
||||
# Analyze a directory
|
||||
python scripts/code_quality_checker.py /path/to/code
|
||||
|
||||
# Analyze specific language
|
||||
python scripts/code_quality_checker.py . --language python
|
||||
|
||||
# JSON output
|
||||
python scripts/code_quality_checker.py /path/to/code --json
|
||||
```
|
||||
|
||||
**What it detects:**
|
||||
- Long functions (>50 lines)
|
||||
- Large files (>500 lines)
|
||||
- God classes (>20 methods)
|
||||
- Deep nesting (>4 levels)
|
||||
- Too many parameters (>5)
|
||||
- High cyclomatic complexity
|
||||
- Missing error handling
|
||||
- Unused imports
|
||||
- Magic numbers
|
||||
|
||||
**Thresholds:**
|
||||
|
||||
| Issue | Threshold |
|
||||
|-------|-----------|
|
||||
| Long function | >50 lines |
|
||||
| Large file | >500 lines |
|
||||
| God class | >20 methods |
|
||||
| Too many params | >5 |
|
||||
| Deep nesting | >4 levels |
|
||||
| High complexity | >10 branches |
|
||||
|
||||
---
|
||||
|
||||
### Review Report Generator
|
||||
|
||||
Combines PR analysis and code quality findings into structured review reports.
|
||||
|
||||
```bash
|
||||
# Generate report for current repo
|
||||
python scripts/review_report_generator.py /path/to/repo
|
||||
|
||||
# Markdown output
|
||||
python scripts/review_report_generator.py . --format markdown --output review.md
|
||||
|
||||
# Use pre-computed analyses
|
||||
python scripts/review_report_generator.py . \
|
||||
--pr-analysis pr_results.json \
|
||||
--quality-analysis quality_results.json
|
||||
```
|
||||
|
||||
**Report includes:**
|
||||
- Review verdict (approve, request changes, block)
|
||||
- Score (0-100)
|
||||
- Prioritized action items
|
||||
- Issue summary by severity
|
||||
- Suggested review order
|
||||
|
||||
**Verdicts:**
|
||||
|
||||
| Score | Verdict |
|
||||
|-------|---------|
|
||||
| 90+ with no high issues | Approve |
|
||||
| 75+ with ≤2 high issues | Approve with suggestions |
|
||||
| 50-74 | Request changes |
|
||||
| <50 or critical issues | Block |
|
||||
|
||||
---
|
||||
|
||||
## Reference Guides
|
||||
|
||||
### Code Review Checklist
|
||||
`references/code_review_checklist.md`
|
||||
|
||||
Systematic checklists covering:
|
||||
- Pre-review checks (build, tests, PR hygiene)
|
||||
- Correctness (logic, data handling, error handling)
|
||||
- Security (input validation, injection prevention)
|
||||
- Performance (efficiency, caching, scalability)
|
||||
- Maintainability (code quality, naming, structure)
|
||||
- Testing (coverage, quality, mocking)
|
||||
- Language-specific checks
|
||||
|
||||
### Coding Standards
|
||||
`references/coding_standards.md`
|
||||
|
||||
Language-specific standards for:
|
||||
- TypeScript (type annotations, null safety, async/await)
|
||||
- JavaScript (declarations, patterns, modules)
|
||||
- Python (type hints, exceptions, class design)
|
||||
- Go (error handling, structs, concurrency)
|
||||
- Swift (optionals, protocols, errors)
|
||||
- Kotlin (null safety, data classes, coroutines)
|
||||
|
||||
### Common Antipatterns
|
||||
`references/common_antipatterns.md`
|
||||
|
||||
Antipattern catalog with examples and fixes:
|
||||
- Structural (god class, long method, deep nesting)
|
||||
- Logic (boolean blindness, stringly typed code)
|
||||
- Security (SQL injection, hardcoded credentials)
|
||||
- Performance (N+1 queries, unbounded collections)
|
||||
- Testing (duplication, testing implementation)
|
||||
- Async (floating promises, callback hell)
|
||||
|
||||
---
|
||||
|
||||
## Languages Supported
|
||||
|
||||
| Language | Extensions |
|
||||
|----------|------------|
|
||||
| Python | `.py` |
|
||||
| TypeScript | `.ts`, `.tsx` |
|
||||
| JavaScript | `.js`, `.jsx`, `.mjs` |
|
||||
| Go | `.go` |
|
||||
| Swift | `.swift` |
|
||||
| Kotlin | `.kt`, `.kts` |
|
||||
444
docs/skills/engineering-team/email-template-builder.md
Normal file
444
docs/skills/engineering-team/email-template-builder.md
Normal file
@@ -0,0 +1,444 @@
|
||||
---
|
||||
title: "Email Template Builder"
|
||||
description: "Email Template Builder - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Email Template Builder
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `email-template-builder` | **Source:** [`engineering-team/email-template-builder/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/email-template-builder/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering Team
|
||||
**Domain:** Transactional Email / Communications Infrastructure
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Build complete transactional email systems: React Email templates, provider integration, preview server, i18n support, dark mode, spam optimization, and analytics tracking. Output production-ready code for Resend, Postmark, SendGrid, or AWS SES.
|
||||
|
||||
---
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- React Email templates (welcome, verification, password reset, invoice, notification, digest)
|
||||
- MJML templates for maximum email client compatibility
|
||||
- Multi-provider support with unified sending interface
|
||||
- Local preview server with hot reload
|
||||
- i18n/localization with typed translation keys
|
||||
- Dark mode support using media queries
|
||||
- Spam score optimization checklist
|
||||
- Open/click tracking with UTM parameters
|
||||
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
- Setting up transactional email for a new product
|
||||
- Migrating from a legacy email system
|
||||
- Adding new email types (invoice, digest, notification)
|
||||
- Debugging email deliverability issues
|
||||
- Implementing i18n for email templates
|
||||
|
||||
---
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
emails/
|
||||
├── components/
|
||||
│ ├── layout/
|
||||
│ │ ├── email-layout.tsx # Base layout with brand header/footer
|
||||
│ │ └── email-button.tsx # CTA button component
|
||||
│ ├── partials/
|
||||
│ │ ├── header.tsx
|
||||
│ │ └── footer.tsx
|
||||
├── templates/
|
||||
│ ├── welcome.tsx
|
||||
│ ├── verify-email.tsx
|
||||
│ ├── password-reset.tsx
|
||||
│ ├── invoice.tsx
|
||||
│ ├── notification.tsx
|
||||
│ └── weekly-digest.tsx
|
||||
├── lib/
|
||||
│ ├── send.ts # Unified send function
|
||||
│ ├── providers/
|
||||
│ │ ├── resend.ts
|
||||
│ │ ├── postmark.ts
|
||||
│ │ └── ses.ts
|
||||
│ └── tracking.ts # UTM + analytics
|
||||
├── i18n/
|
||||
│ ├── en.ts
|
||||
│ └── de.ts
|
||||
└── preview/ # Dev preview server
|
||||
└── server.ts
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Base Email Layout
|
||||
|
||||
```tsx
|
||||
// emails/components/layout/email-layout.tsx
|
||||
import {
|
||||
Body, Container, Head, Html, Img, Preview, Section, Text, Hr, Font
|
||||
} from "@react-email/components"
|
||||
|
||||
interface EmailLayoutProps {
|
||||
preview: string
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
export function EmailLayout({ preview, children }: EmailLayoutProps) {
|
||||
return (
|
||||
<Html lang="en">
|
||||
<Head>
|
||||
<Font
|
||||
fontFamily="Inter"
|
||||
fallbackFontFamily="Arial"
|
||||
webFont={{ url: "https://fonts.gstatic.com/s/inter/v13/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZ9hiJ-Ek-_EeA.woff2", format: "woff2" }}
|
||||
fontWeight={400}
|
||||
fontStyle="normal"
|
||||
/>
|
||||
{/* Dark mode styles */}
|
||||
<style>{`
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.email-body { background-color: #0f0f0f !important; }
|
||||
.email-container { background-color: #1a1a1a !important; }
|
||||
.email-text { color: #e5e5e5 !important; }
|
||||
.email-heading { color: #ffffff !important; }
|
||||
.email-divider { border-color: #333333 !important; }
|
||||
}
|
||||
`}</style>
|
||||
</Head>
|
||||
<Preview>{preview}</Preview>
|
||||
<Body className="email-body" style={styles.body}>
|
||||
<Container className="email-container" style={styles.container}>
|
||||
{/* Header */}
|
||||
<Section style={styles.header}>
|
||||
<Img src="https://yourapp.com/logo.png" width={120} height={40} alt="MyApp" />
|
||||
</Section>
|
||||
|
||||
{/* Content */}
|
||||
<Section style={styles.content}>
|
||||
{children}
|
||||
</Section>
|
||||
|
||||
{/* Footer */}
|
||||
<Hr style={styles.divider} />
|
||||
<Section style={styles.footer}>
|
||||
<Text style={styles.footerText}>
|
||||
MyApp Inc. · 123 Main St · San Francisco, CA 94105
|
||||
</Text>
|
||||
<Text style={styles.footerText}>
|
||||
<a href="{{unsubscribe_url}}" style={styles.link}>Unsubscribe</a>
|
||||
{" · "}
|
||||
<a href="https://yourapp.com/privacy" style={styles.link}>Privacy Policy</a>
|
||||
</Text>
|
||||
</Section>
|
||||
</Container>
|
||||
</Body>
|
||||
</Html>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = {
|
||||
body: { backgroundColor: "#f5f5f5", fontFamily: "Inter, Arial, sans-serif" },
|
||||
container: { maxWidth: "600px", margin: "0 auto", backgroundColor: "#ffffff", borderRadius: "8px", overflow: "hidden" },
|
||||
header: { padding: "24px 32px", borderBottom: "1px solid #e5e5e5" },
|
||||
content: { padding: "32px" },
|
||||
divider: { borderColor: "#e5e5e5", margin: "0 32px" },
|
||||
footer: { padding: "24px 32px" },
|
||||
footerText: { fontSize: "12px", color: "#6b7280", textAlign: "center" as const, margin: "4px 0" },
|
||||
link: { color: "#6b7280", textDecoration: "underline" },
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Welcome Email
|
||||
|
||||
```tsx
|
||||
// emails/templates/welcome.tsx
|
||||
import { Button, Heading, Text } from "@react-email/components"
|
||||
import { EmailLayout } from "../components/layout/email-layout"
|
||||
|
||||
interface WelcomeEmailProps {
|
||||
name: string
|
||||
confirmUrl: string
|
||||
trialDays?: number
|
||||
}
|
||||
|
||||
export function WelcomeEmail({ name, confirmUrl, trialDays = 14 }: WelcomeEmailProps) {
|
||||
return (
|
||||
<EmailLayout preview={`Welcome to MyApp, ${name}! Confirm your email to get started.`}>
|
||||
<Heading style={styles.h1}>Welcome to MyApp, {name}!</Heading>
|
||||
<Text style={styles.text}>
|
||||
We're excited to have you on board. You've got {trialDays} days to explore everything MyApp has to offer — no credit card required.
|
||||
</Text>
|
||||
<Text style={styles.text}>
|
||||
First, confirm your email address to activate your account:
|
||||
</Text>
|
||||
<Button href={confirmUrl} style={styles.button}>
|
||||
Confirm Email Address
|
||||
</Button>
|
||||
<Text style={styles.hint}>
|
||||
Button not working? Copy and paste this link into your browser:
|
||||
<br />
|
||||
<a href={confirmUrl} style={styles.link}>{confirmUrl}</a>
|
||||
</Text>
|
||||
<Text style={styles.text}>
|
||||
Once confirmed, you can:
|
||||
</Text>
|
||||
<ul style={styles.list}>
|
||||
<li>Connect your first project in 2 minutes</li>
|
||||
<li>Invite your team (free for up to 3 members)</li>
|
||||
<li>Set up Slack notifications</li>
|
||||
</ul>
|
||||
</EmailLayout>
|
||||
)
|
||||
}
|
||||
|
||||
export default WelcomeEmail
|
||||
|
||||
const styles = {
|
||||
h1: { fontSize: "28px", fontWeight: "700", color: "#111827", margin: "0 0 16px" },
|
||||
text: { fontSize: "16px", lineHeight: "1.6", color: "#374151", margin: "0 0 16px" },
|
||||
button: { backgroundColor: "#4f46e5", color: "#ffffff", borderRadius: "6px", fontSize: "16px", fontWeight: "600", padding: "12px 24px", textDecoration: "none", display: "inline-block", margin: "8px 0 24px" },
|
||||
hint: { fontSize: "13px", color: "#6b7280" },
|
||||
link: { color: "#4f46e5" },
|
||||
list: { fontSize: "16px", lineHeight: "1.8", color: "#374151", paddingLeft: "20px" },
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Invoice Email
|
||||
|
||||
```tsx
|
||||
// emails/templates/invoice.tsx
|
||||
import { Row, Column, Section, Heading, Text, Hr, Button } from "@react-email/components"
|
||||
import { EmailLayout } from "../components/layout/email-layout"
|
||||
|
||||
interface InvoiceItem { description: string; amount: number }
|
||||
|
||||
interface InvoiceEmailProps {
|
||||
name: string
|
||||
invoiceNumber: string
|
||||
invoiceDate: string
|
||||
dueDate: string
|
||||
items: InvoiceItem[]
|
||||
total: number
|
||||
currency: string
|
||||
downloadUrl: string
|
||||
}
|
||||
|
||||
export function InvoiceEmail({ name, invoiceNumber, invoiceDate, dueDate, items, total, currency = "USD", downloadUrl }: InvoiceEmailProps) {
|
||||
const formatter = new Intl.NumberFormat("en-US", { style: "currency", currency })
|
||||
|
||||
return (
|
||||
<EmailLayout preview={`Invoice ${invoiceNumber} - ${formatter.format(total / 100)}`}>
|
||||
<Heading style={styles.h1}>Invoice #{invoiceNumber}</Heading>
|
||||
<Text style={styles.text}>Hi {name},</Text>
|
||||
<Text style={styles.text}>Here's your invoice from MyApp. Thank you for your continued support.</Text>
|
||||
|
||||
{/* Invoice Meta */}
|
||||
<Section style={styles.metaBox}>
|
||||
<Row>
|
||||
<Column><Text style={styles.metaLabel}>Invoice Date</Text><Text style={styles.metaValue}>{invoiceDate}</Text></Column>
|
||||
<Column><Text style={styles.metaLabel}>Due Date</Text><Text style={styles.metaValue}>{dueDate}</Text></Column>
|
||||
<Column><Text style={styles.metaLabel}>Amount Due</Text><Text style={styles.metaValueLarge}>{formatter.format(total / 100)}</Text></Column>
|
||||
</Row>
|
||||
</Section>
|
||||
|
||||
{/* Line Items */}
|
||||
<Section style={styles.table}>
|
||||
<Row style={styles.tableHeader}>
|
||||
<Column><Text style={styles.tableHeaderText}>Description</Text></Column>
|
||||
<Column><Text style={{ ...styles.tableHeaderText, textAlign: "right" }}>Amount</Text></Column>
|
||||
</Row>
|
||||
{items.map((item, i) => (
|
||||
<Row key={i} style={i % 2 === 0 ? styles.tableRowEven : styles.tableRowOdd}>
|
||||
<Column><Text style={styles.tableCell}>{item.description}</Text></Column>
|
||||
<Column><Text style={{ ...styles.tableCell, textAlign: "right" }}>{formatter.format(item.amount / 100)}</Text></Column>
|
||||
</Row>
|
||||
))}
|
||||
<Hr style={styles.divider} />
|
||||
<Row>
|
||||
<Column><Text style={styles.totalLabel}>Total</Text></Column>
|
||||
<Column><Text style={styles.totalValue}>{formatter.format(total / 100)}</Text></Column>
|
||||
</Row>
|
||||
</Section>
|
||||
|
||||
<Button href={downloadUrl} style={styles.button}>Download PDF Invoice</Button>
|
||||
</EmailLayout>
|
||||
)
|
||||
}
|
||||
|
||||
export default InvoiceEmail
|
||||
|
||||
const styles = {
|
||||
h1: { fontSize: "24px", fontWeight: "700", color: "#111827", margin: "0 0 16px" },
|
||||
text: { fontSize: "15px", lineHeight: "1.6", color: "#374151", margin: "0 0 12px" },
|
||||
metaBox: { backgroundColor: "#f9fafb", borderRadius: "8px", padding: "16px", margin: "16px 0" },
|
||||
metaLabel: { fontSize: "12px", color: "#6b7280", fontWeight: "600", textTransform: "uppercase" as const, margin: "0 0 4px" },
|
||||
metaValue: { fontSize: "14px", color: "#111827", margin: 0 },
|
||||
metaValueLarge: { fontSize: "20px", fontWeight: "700", color: "#4f46e5", margin: 0 },
|
||||
table: { width: "100%", margin: "16px 0" },
|
||||
tableHeader: { backgroundColor: "#f3f4f6", borderRadius: "4px" },
|
||||
tableHeaderText: { fontSize: "12px", fontWeight: "600", color: "#374151", padding: "8px 12px", textTransform: "uppercase" as const },
|
||||
tableRowEven: { backgroundColor: "#ffffff" },
|
||||
tableRowOdd: { backgroundColor: "#f9fafb" },
|
||||
tableCell: { fontSize: "14px", color: "#374151", padding: "10px 12px" },
|
||||
divider: { borderColor: "#e5e5e5", margin: "8px 0" },
|
||||
totalLabel: { fontSize: "16px", fontWeight: "700", color: "#111827", padding: "8px 12px" },
|
||||
totalValue: { fontSize: "16px", fontWeight: "700", color: "#111827", textAlign: "right" as const, padding: "8px 12px" },
|
||||
button: { backgroundColor: "#4f46e5", color: "#fff", borderRadius: "6px", padding: "12px 24px", fontSize: "15px", fontWeight: "600", textDecoration: "none" },
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Unified Send Function
|
||||
|
||||
```typescript
|
||||
// emails/lib/send.ts
|
||||
import { Resend } from "resend"
|
||||
import { render } from "@react-email/render"
|
||||
import { WelcomeEmail } from "../templates/welcome"
|
||||
import { InvoiceEmail } from "../templates/invoice"
|
||||
import { addTrackingParams } from "./tracking"
|
||||
|
||||
const resend = new Resend(process.env.RESEND_API_KEY)
|
||||
|
||||
type EmailPayload =
|
||||
| { type: "welcome"; props: Parameters<typeof WelcomeEmail>[0] }
|
||||
| { type: "invoice"; props: Parameters<typeof InvoiceEmail>[0] }
|
||||
|
||||
export async function sendEmail(to: string, payload: EmailPayload) {
|
||||
const templates = {
|
||||
welcome: { component: WelcomeEmail, subject: "Welcome to MyApp — confirm your email" },
|
||||
invoice: { component: InvoiceEmail, subject: `Invoice from MyApp` },
|
||||
}
|
||||
|
||||
const template = templates[payload.type]
|
||||
const html = render(template.component(payload.props as any))
|
||||
const trackedHtml = addTrackingParams(html, { campaign: payload.type })
|
||||
|
||||
const result = await resend.emails.send({
|
||||
from: "MyApp <hello@yourapp.com>",
|
||||
to,
|
||||
subject: template.subject,
|
||||
html: trackedHtml,
|
||||
tags: [{ name: "email_type", value: payload.type }],
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Preview Server Setup
|
||||
|
||||
```typescript
|
||||
// package.json scripts
|
||||
{
|
||||
"scripts": {
|
||||
"email:dev": "email dev --dir emails/templates --port 3001",
|
||||
"email:build": "email export --dir emails/templates --outDir emails/out"
|
||||
}
|
||||
}
|
||||
|
||||
// Run: npm run email:dev
|
||||
// Opens: http://localhost:3001
|
||||
// Shows all templates with live preview and hot reload
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## i18n Support
|
||||
|
||||
```typescript
|
||||
// emails/i18n/en.ts
|
||||
export const en = {
|
||||
welcome: {
|
||||
preview: (name: string) => `Welcome to MyApp, ${name}!`,
|
||||
heading: (name: string) => `Welcome to MyApp, ${name}!`,
|
||||
body: (days: number) => `You've got ${days} days to explore everything.`,
|
||||
cta: "Confirm Email Address",
|
||||
},
|
||||
}
|
||||
|
||||
// emails/i18n/de.ts
|
||||
export const de = {
|
||||
welcome: {
|
||||
preview: (name: string) => `Willkommen bei MyApp, ${name}!`,
|
||||
heading: (name: string) => `Willkommen bei MyApp, ${name}!`,
|
||||
body: (days: number) => `Du hast ${days} Tage Zeit, alles zu erkunden.`,
|
||||
cta: "E-Mail-Adresse bestätigen",
|
||||
},
|
||||
}
|
||||
|
||||
// Usage in template
|
||||
import { en, de } from "../i18n"
|
||||
const t = locale === "de" ? de : en
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Spam Score Optimization Checklist
|
||||
|
||||
- [ ] Sender domain has SPF, DKIM, and DMARC records configured
|
||||
- [ ] From address uses your own domain (not gmail.com/hotmail.com)
|
||||
- [ ] Subject line under 50 characters, no ALL CAPS, no "FREE!!!"
|
||||
- [ ] Text-to-image ratio: at least 60% text
|
||||
- [ ] Plain text version included alongside HTML
|
||||
- [ ] Unsubscribe link in every marketing email (CAN-SPAM, GDPR)
|
||||
- [ ] No URL shorteners — use full branded links
|
||||
- [ ] No red-flag words: "guarantee", "no risk", "limited time offer" in subject
|
||||
- [ ] Single CTA per email — no 5 different buttons
|
||||
- [ ] Image alt text on every image
|
||||
- [ ] HTML validates — no broken tags
|
||||
- [ ] Test with Mail-Tester.com before first send (target: 9+/10)
|
||||
|
||||
---
|
||||
|
||||
## Analytics Tracking
|
||||
|
||||
```typescript
|
||||
// emails/lib/tracking.ts
|
||||
interface TrackingParams {
|
||||
campaign: string
|
||||
medium?: string
|
||||
source?: string
|
||||
}
|
||||
|
||||
export function addTrackingParams(html: string, params: TrackingParams): string {
|
||||
const utmString = new URLSearchParams({
|
||||
utm_source: params.source ?? "email",
|
||||
utm_medium: params.medium ?? "transactional",
|
||||
utm_campaign: params.campaign,
|
||||
}).toString()
|
||||
|
||||
// Add UTM params to all links in the email
|
||||
return html.replace(/href="(https?:\/\/[^"]+)"/g, (match, url) => {
|
||||
const separator = url.includes("?") ? "&" : "?"
|
||||
return `href="${url}${separator}${utmString}"`
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
- **Inline styles required** — most email clients strip `<head>` styles; React Email handles this
|
||||
- **Max width 600px** — anything wider breaks on Gmail mobile
|
||||
- **No flexbox/grid** — use `<Row>` and `<Column>` from react-email, not CSS grid
|
||||
- **Dark mode media queries** — must use `!important` to override inline styles
|
||||
- **Missing plain text** — all major providers have a plain text field; always populate it
|
||||
- **Transactional vs marketing** — use separate sending domains/IPs to protect deliverability
|
||||
678
docs/skills/engineering-team/incident-commander.md
Normal file
678
docs/skills/engineering-team/incident-commander.md
Normal file
@@ -0,0 +1,678 @@
|
||||
---
|
||||
title: "Incident Commander Skill"
|
||||
description: "Incident Commander Skill - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Incident Commander Skill
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `incident-commander` | **Source:** [`engineering-team/incident-commander/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/incident-commander/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Category:** Engineering Team
|
||||
**Tier:** POWERFUL
|
||||
**Author:** Claude Skills Team
|
||||
**Version:** 1.0.0
|
||||
**Last Updated:** February 2026
|
||||
|
||||
## Overview
|
||||
|
||||
The Incident Commander skill provides a comprehensive incident response framework for managing technology incidents from detection through resolution and post-incident review. This skill implements battle-tested practices from SRE and DevOps teams at scale, providing structured tools for severity classification, timeline reconstruction, and thorough post-incident analysis.
|
||||
|
||||
## Key Features
|
||||
|
||||
- **Automated Severity Classification** - Intelligent incident triage based on impact and urgency metrics
|
||||
- **Timeline Reconstruction** - Transform scattered logs and events into coherent incident narratives
|
||||
- **Post-Incident Review Generation** - Structured PIRs with multiple RCA frameworks
|
||||
- **Communication Templates** - Pre-built templates for stakeholder updates and escalations
|
||||
- **Runbook Integration** - Generate actionable runbooks from incident patterns
|
||||
|
||||
## Skills Included
|
||||
|
||||
### Core Tools
|
||||
|
||||
1. **Incident Classifier** (`incident_classifier.py`)
|
||||
- Analyzes incident descriptions and outputs severity levels
|
||||
- Recommends response teams and initial actions
|
||||
- Generates communication templates based on severity
|
||||
|
||||
2. **Timeline Reconstructor** (`timeline_reconstructor.py`)
|
||||
- Processes timestamped events from multiple sources
|
||||
- Reconstructs chronological incident timeline
|
||||
- Identifies gaps and provides duration analysis
|
||||
|
||||
3. **PIR Generator** (`pir_generator.py`)
|
||||
- Creates comprehensive Post-Incident Review documents
|
||||
- Applies multiple RCA frameworks (5 Whys, Fishbone, Timeline)
|
||||
- Generates actionable follow-up items
|
||||
|
||||
## Incident Response Framework
|
||||
|
||||
### Severity Classification System
|
||||
|
||||
#### SEV1 - Critical Outage
|
||||
**Definition:** Complete service failure affecting all users or critical business functions
|
||||
|
||||
**Characteristics:**
|
||||
- Customer-facing services completely unavailable
|
||||
- Data loss or corruption affecting users
|
||||
- Security breaches with customer data exposure
|
||||
- Revenue-generating systems down
|
||||
- SLA violations with financial penalties
|
||||
|
||||
**Response Requirements:**
|
||||
- Immediate escalation to on-call engineer
|
||||
- Incident Commander assigned within 5 minutes
|
||||
- Executive notification within 15 minutes
|
||||
- Public status page update within 15 minutes
|
||||
- War room established
|
||||
- All hands on deck if needed
|
||||
|
||||
**Communication Frequency:** Every 15 minutes until resolution
|
||||
|
||||
#### SEV2 - Major Impact
|
||||
**Definition:** Significant degradation affecting subset of users or non-critical functions
|
||||
|
||||
**Characteristics:**
|
||||
- Partial service degradation (>25% of users affected)
|
||||
- Performance issues causing user frustration
|
||||
- Non-critical features unavailable
|
||||
- Internal tools impacting productivity
|
||||
- Data inconsistencies not affecting user experience
|
||||
|
||||
**Response Requirements:**
|
||||
- On-call engineer response within 15 minutes
|
||||
- Incident Commander assigned within 30 minutes
|
||||
- Status page update within 30 minutes
|
||||
- Stakeholder notification within 1 hour
|
||||
- Regular team updates
|
||||
|
||||
**Communication Frequency:** Every 30 minutes during active response
|
||||
|
||||
#### SEV3 - Minor Impact
|
||||
**Definition:** Limited impact with workarounds available
|
||||
|
||||
**Characteristics:**
|
||||
- Single feature or component affected
|
||||
- <25% of users impacted
|
||||
- Workarounds available
|
||||
- Performance degradation not significantly impacting UX
|
||||
- Non-urgent monitoring alerts
|
||||
|
||||
**Response Requirements:**
|
||||
- Response within 2 hours during business hours
|
||||
- Next business day response acceptable outside hours
|
||||
- Internal team notification
|
||||
- Optional status page update
|
||||
|
||||
**Communication Frequency:** At key milestones only
|
||||
|
||||
#### SEV4 - Low Impact
|
||||
**Definition:** Minimal impact, cosmetic issues, or planned maintenance
|
||||
|
||||
**Characteristics:**
|
||||
- Cosmetic bugs
|
||||
- Documentation issues
|
||||
- Logging or monitoring gaps
|
||||
- Performance issues with no user impact
|
||||
- Development/test environment issues
|
||||
|
||||
**Response Requirements:**
|
||||
- Response within 1-2 business days
|
||||
- Standard ticket/issue tracking
|
||||
- No special escalation required
|
||||
|
||||
**Communication Frequency:** Standard development cycle updates
|
||||
|
||||
### Incident Commander Role
|
||||
|
||||
#### Primary Responsibilities
|
||||
|
||||
1. **Command and Control**
|
||||
- Own the incident response process
|
||||
- Make critical decisions about resource allocation
|
||||
- Coordinate between technical teams and stakeholders
|
||||
- Maintain situational awareness across all response streams
|
||||
|
||||
2. **Communication Hub**
|
||||
- Provide regular updates to stakeholders
|
||||
- Manage external communications (status pages, customer notifications)
|
||||
- Facilitate effective communication between response teams
|
||||
- Shield responders from external distractions
|
||||
|
||||
3. **Process Management**
|
||||
- Ensure proper incident tracking and documentation
|
||||
- Drive toward resolution while maintaining quality
|
||||
- Coordinate handoffs between team members
|
||||
- Plan and execute rollback strategies if needed
|
||||
|
||||
4. **Post-Incident Leadership**
|
||||
- Ensure thorough post-incident reviews are conducted
|
||||
- Drive implementation of preventive measures
|
||||
- Share learnings with broader organization
|
||||
|
||||
#### Decision-Making Framework
|
||||
|
||||
**Emergency Decisions (SEV1/2):**
|
||||
- Incident Commander has full authority
|
||||
- Bias toward action over analysis
|
||||
- Document decisions for later review
|
||||
- Consult subject matter experts but don't get blocked
|
||||
|
||||
**Resource Allocation:**
|
||||
- Can pull in any necessary team members
|
||||
- Authority to escalate to senior leadership
|
||||
- Can approve emergency spend for external resources
|
||||
- Make call on communication channels and timing
|
||||
|
||||
**Technical Decisions:**
|
||||
- Lean on technical leads for implementation details
|
||||
- Make final calls on trade-offs between speed and risk
|
||||
- Approve rollback vs. fix-forward strategies
|
||||
- Coordinate testing and validation approaches
|
||||
|
||||
### Communication Templates
|
||||
|
||||
#### Initial Incident Notification (SEV1/2)
|
||||
|
||||
```
|
||||
Subject: [SEV{severity}] {Service Name} - {Brief Description}
|
||||
|
||||
Incident Details:
|
||||
- Start Time: {timestamp}
|
||||
- Severity: SEV{level}
|
||||
- Impact: {user impact description}
|
||||
- Current Status: {investigating/mitigating/resolved}
|
||||
|
||||
Technical Details:
|
||||
- Affected Services: {service list}
|
||||
- Symptoms: {what users are experiencing}
|
||||
- Initial Assessment: {suspected root cause if known}
|
||||
|
||||
Response Team:
|
||||
- Incident Commander: {name}
|
||||
- Technical Lead: {name}
|
||||
- SMEs Engaged: {list}
|
||||
|
||||
Next Update: {timestamp}
|
||||
Status Page: {link}
|
||||
War Room: {bridge/chat link}
|
||||
|
||||
---
|
||||
{Incident Commander Name}
|
||||
{Contact Information}
|
||||
```
|
||||
|
||||
#### Executive Summary (SEV1)
|
||||
|
||||
```
|
||||
Subject: URGENT - Customer-Impacting Outage - {Service Name}
|
||||
|
||||
Executive Summary:
|
||||
{2-3 sentence description of customer impact and business implications}
|
||||
|
||||
Key Metrics:
|
||||
- Time to Detection: {X minutes}
|
||||
- Time to Engagement: {X minutes}
|
||||
- Estimated Customer Impact: {number/percentage}
|
||||
- Current Status: {status}
|
||||
- ETA to Resolution: {time or "investigating"}
|
||||
|
||||
Leadership Actions Required:
|
||||
- [ ] Customer communication approval
|
||||
- [ ] PR/Communications coordination
|
||||
- [ ] Resource allocation decisions
|
||||
- [ ] External vendor engagement
|
||||
|
||||
Incident Commander: {name} ({contact})
|
||||
Next Update: {time}
|
||||
|
||||
---
|
||||
This is an automated alert from our incident response system.
|
||||
```
|
||||
|
||||
#### Customer Communication Template
|
||||
|
||||
```
|
||||
We are currently experiencing {brief description of issue} affecting {scope of impact}.
|
||||
|
||||
Our engineering team was alerted at {time} and is actively working to resolve the issue. We will provide updates every {frequency} until resolved.
|
||||
|
||||
What we know:
|
||||
- {factual statement of impact}
|
||||
- {factual statement of scope}
|
||||
- {brief status of response}
|
||||
|
||||
What we're doing:
|
||||
- {primary response action}
|
||||
- {secondary response action}
|
||||
|
||||
Workaround (if available):
|
||||
{workaround steps or "No workaround currently available"}
|
||||
|
||||
We apologize for the inconvenience and will share more information as it becomes available.
|
||||
|
||||
Next update: {time}
|
||||
Status page: {link}
|
||||
```
|
||||
|
||||
### Stakeholder Management
|
||||
|
||||
#### Stakeholder Classification
|
||||
|
||||
**Internal Stakeholders:**
|
||||
- **Engineering Leadership** - Technical decisions and resource allocation
|
||||
- **Product Management** - Customer impact assessment and feature implications
|
||||
- **Customer Support** - User communication and support ticket management
|
||||
- **Sales/Account Management** - Customer relationship management for enterprise clients
|
||||
- **Executive Team** - Business impact decisions and external communication approval
|
||||
- **Legal/Compliance** - Regulatory reporting and liability assessment
|
||||
|
||||
**External Stakeholders:**
|
||||
- **Customers** - Service availability and impact communication
|
||||
- **Partners** - API availability and integration impacts
|
||||
- **Vendors** - Third-party service dependencies and support escalation
|
||||
- **Regulators** - Compliance reporting for regulated industries
|
||||
- **Public/Media** - Transparency for public-facing outages
|
||||
|
||||
#### Communication Cadence by Stakeholder
|
||||
|
||||
| Stakeholder | SEV1 | SEV2 | SEV3 | SEV4 |
|
||||
|-------------|------|------|------|------|
|
||||
| Engineering Leadership | Real-time | 30min | 4hrs | Daily |
|
||||
| Executive Team | 15min | 1hr | EOD | Weekly |
|
||||
| Customer Support | Real-time | 30min | 2hrs | As needed |
|
||||
| Customers | 15min | 1hr | Optional | None |
|
||||
| Partners | 30min | 2hrs | Optional | None |
|
||||
|
||||
### Runbook Generation Framework
|
||||
|
||||
#### Dynamic Runbook Components
|
||||
|
||||
1. **Detection Playbooks**
|
||||
- Monitoring alert definitions
|
||||
- Triage decision trees
|
||||
- Escalation trigger points
|
||||
- Initial response actions
|
||||
|
||||
2. **Response Playbooks**
|
||||
- Step-by-step mitigation procedures
|
||||
- Rollback instructions
|
||||
- Validation checkpoints
|
||||
- Communication checkpoints
|
||||
|
||||
3. **Recovery Playbooks**
|
||||
- Service restoration procedures
|
||||
- Data consistency checks
|
||||
- Performance validation
|
||||
- User notification processes
|
||||
|
||||
#### Runbook Template Structure
|
||||
|
||||
```markdown
|
||||
# {Service/Component} Incident Response Runbook
|
||||
|
||||
## Quick Reference
|
||||
- **Severity Indicators:** {list of conditions for each severity level}
|
||||
- **Key Contacts:** {on-call rotations and escalation paths}
|
||||
- **Critical Commands:** {list of emergency commands with descriptions}
|
||||
|
||||
## Detection
|
||||
### Monitoring Alerts
|
||||
- {Alert name}: {description and thresholds}
|
||||
- {Alert name}: {description and thresholds}
|
||||
|
||||
### Manual Detection Signs
|
||||
- {Symptom}: {what to look for and where}
|
||||
- {Symptom}: {what to look for and where}
|
||||
|
||||
## Initial Response (0-15 minutes)
|
||||
1. **Assess Severity**
|
||||
- [ ] Check {primary metric}
|
||||
- [ ] Verify {secondary indicator}
|
||||
- [ ] Classify as SEV{level} based on {criteria}
|
||||
|
||||
2. **Establish Command**
|
||||
- [ ] Page Incident Commander if SEV1/2
|
||||
- [ ] Create incident tracking ticket
|
||||
- [ ] Join war room: {link/bridge info}
|
||||
|
||||
3. **Initial Investigation**
|
||||
- [ ] Check recent deployments: {deployment log location}
|
||||
- [ ] Review error logs: {log location and queries}
|
||||
- [ ] Verify dependencies: {dependency check commands}
|
||||
|
||||
## Mitigation Strategies
|
||||
### Strategy 1: {Name}
|
||||
**Use when:** {conditions}
|
||||
**Steps:**
|
||||
1. {detailed step with commands}
|
||||
2. {detailed step with expected outcomes}
|
||||
3. {validation step}
|
||||
|
||||
**Rollback Plan:**
|
||||
1. {rollback step}
|
||||
2. {verification step}
|
||||
|
||||
### Strategy 2: {Name}
|
||||
{similar structure}
|
||||
|
||||
## Recovery and Validation
|
||||
1. **Service Restoration**
|
||||
- [ ] {restoration step}
|
||||
- [ ] Wait for {metric} to return to normal
|
||||
- [ ] Validate end-to-end functionality
|
||||
|
||||
2. **Communication**
|
||||
- [ ] Update status page
|
||||
- [ ] Notify stakeholders
|
||||
- [ ] Schedule PIR
|
||||
|
||||
## Common Pitfalls
|
||||
- **{Pitfall}:** {description and how to avoid}
|
||||
- **{Pitfall}:** {description and how to avoid}
|
||||
|
||||
## Reference Information
|
||||
- **Architecture Diagram:** {link}
|
||||
- **Monitoring Dashboard:** {link}
|
||||
- **Related Runbooks:** {links to dependent service runbooks}
|
||||
```
|
||||
|
||||
### Post-Incident Review (PIR) Framework
|
||||
|
||||
#### PIR Timeline and Ownership
|
||||
|
||||
**Timeline:**
|
||||
- **24 hours:** Initial PIR draft completed by Incident Commander
|
||||
- **3 business days:** Final PIR published with all stakeholder input
|
||||
- **1 week:** Action items assigned with owners and due dates
|
||||
- **4 weeks:** Follow-up review on action item progress
|
||||
|
||||
**Roles:**
|
||||
- **PIR Owner:** Incident Commander (can delegate writing but owns completion)
|
||||
- **Technical Contributors:** All engineers involved in response
|
||||
- **Review Committee:** Engineering leadership, affected product teams
|
||||
- **Action Item Owners:** Assigned based on expertise and capacity
|
||||
|
||||
#### Root Cause Analysis Frameworks
|
||||
|
||||
#### 1. Five Whys Method
|
||||
|
||||
The Five Whys technique involves asking "why" repeatedly to drill down to root causes:
|
||||
|
||||
**Example Application:**
|
||||
- **Problem:** Database became unresponsive during peak traffic
|
||||
- **Why 1:** Why did the database become unresponsive? → Connection pool was exhausted
|
||||
- **Why 2:** Why was the connection pool exhausted? → Application was creating more connections than usual
|
||||
- **Why 3:** Why was the application creating more connections? → New feature wasn't properly connection pooling
|
||||
- **Why 4:** Why wasn't the feature properly connection pooling? → Code review missed this pattern
|
||||
- **Why 5:** Why did code review miss this? → No automated checks for connection pooling patterns
|
||||
|
||||
**Best Practices:**
|
||||
- Ask "why" at least 3 times, often need 5+ iterations
|
||||
- Focus on process failures, not individual blame
|
||||
- Each "why" should point to a actionable system improvement
|
||||
- Consider multiple root cause paths, not just one linear chain
|
||||
|
||||
#### 2. Fishbone (Ishikawa) Diagram
|
||||
|
||||
Systematic analysis across multiple categories of potential causes:
|
||||
|
||||
**Categories:**
|
||||
- **People:** Training, experience, communication, handoffs
|
||||
- **Process:** Procedures, change management, review processes
|
||||
- **Technology:** Architecture, tooling, monitoring, automation
|
||||
- **Environment:** Infrastructure, dependencies, external factors
|
||||
|
||||
**Application Method:**
|
||||
1. State the problem clearly at the "head" of the fishbone
|
||||
2. For each category, brainstorm potential contributing factors
|
||||
3. For each factor, ask what caused that factor (sub-causes)
|
||||
4. Identify the factors most likely to be root causes
|
||||
5. Validate root causes with evidence from the incident
|
||||
|
||||
#### 3. Timeline Analysis
|
||||
|
||||
Reconstruct the incident chronologically to identify decision points and missed opportunities:
|
||||
|
||||
**Timeline Elements:**
|
||||
- **Detection:** When was the issue first observable? When was it first detected?
|
||||
- **Notification:** How quickly were the right people informed?
|
||||
- **Response:** What actions were taken and how effective were they?
|
||||
- **Communication:** When were stakeholders updated?
|
||||
- **Resolution:** What finally resolved the issue?
|
||||
|
||||
**Analysis Questions:**
|
||||
- Where were there delays and what caused them?
|
||||
- What decisions would we make differently with perfect information?
|
||||
- Where did communication break down?
|
||||
- What automation could have detected/resolved faster?
|
||||
|
||||
### Escalation Paths
|
||||
|
||||
#### Technical Escalation
|
||||
|
||||
**Level 1:** On-call engineer
|
||||
- **Responsibility:** Initial response and common issue resolution
|
||||
- **Escalation Trigger:** Issue not resolved within SLA timeframe
|
||||
- **Timeframe:** 15 minutes (SEV1), 30 minutes (SEV2)
|
||||
|
||||
**Level 2:** Senior engineer/Team lead
|
||||
- **Responsibility:** Complex technical issues requiring deeper expertise
|
||||
- **Escalation Trigger:** Level 1 requests help or timeout occurs
|
||||
- **Timeframe:** 30 minutes (SEV1), 1 hour (SEV2)
|
||||
|
||||
**Level 3:** Engineering Manager/Staff Engineer
|
||||
- **Responsibility:** Cross-team coordination and architectural decisions
|
||||
- **Escalation Trigger:** Issue spans multiple systems or teams
|
||||
- **Timeframe:** 45 minutes (SEV1), 2 hours (SEV2)
|
||||
|
||||
**Level 4:** Director of Engineering/CTO
|
||||
- **Responsibility:** Resource allocation and business impact decisions
|
||||
- **Escalation Trigger:** Extended outage or significant business impact
|
||||
- **Timeframe:** 1 hour (SEV1), 4 hours (SEV2)
|
||||
|
||||
#### Business Escalation
|
||||
|
||||
**Customer Impact Assessment:**
|
||||
- **High:** Revenue loss, SLA breaches, customer churn risk
|
||||
- **Medium:** User experience degradation, support ticket volume
|
||||
- **Low:** Internal tools, development impact only
|
||||
|
||||
**Escalation Matrix:**
|
||||
|
||||
| Severity | Duration | Business Escalation |
|
||||
|----------|----------|-------------------|
|
||||
| SEV1 | Immediate | VP Engineering |
|
||||
| SEV1 | 30 minutes | CTO + Customer Success VP |
|
||||
| SEV1 | 1 hour | CEO + Full Executive Team |
|
||||
| SEV2 | 2 hours | VP Engineering |
|
||||
| SEV2 | 4 hours | CTO |
|
||||
| SEV3 | 1 business day | Engineering Manager |
|
||||
|
||||
### Status Page Management
|
||||
|
||||
#### Update Principles
|
||||
|
||||
1. **Transparency:** Provide factual information without speculation
|
||||
2. **Timeliness:** Update within committed timeframes
|
||||
3. **Clarity:** Use customer-friendly language, avoid technical jargon
|
||||
4. **Completeness:** Include impact scope, status, and next update time
|
||||
|
||||
#### Status Categories
|
||||
|
||||
- **Operational:** All systems functioning normally
|
||||
- **Degraded Performance:** Some users may experience slowness
|
||||
- **Partial Outage:** Subset of features unavailable
|
||||
- **Major Outage:** Service unavailable for most/all users
|
||||
- **Under Maintenance:** Planned maintenance window
|
||||
|
||||
#### Update Template
|
||||
|
||||
```
|
||||
{Timestamp} - {Status Category}
|
||||
|
||||
{Brief description of current state}
|
||||
|
||||
Impact: {who is affected and how}
|
||||
Cause: {root cause if known, "under investigation" if not}
|
||||
Resolution: {what's being done to fix it}
|
||||
|
||||
Next update: {specific time}
|
||||
|
||||
We apologize for any inconvenience this may cause.
|
||||
```
|
||||
|
||||
### Action Item Framework
|
||||
|
||||
#### Action Item Categories
|
||||
|
||||
1. **Immediate Fixes**
|
||||
- Critical bugs discovered during incident
|
||||
- Security vulnerabilities exposed
|
||||
- Data integrity issues
|
||||
|
||||
2. **Process Improvements**
|
||||
- Communication gaps
|
||||
- Escalation procedure updates
|
||||
- Runbook additions/updates
|
||||
|
||||
3. **Technical Debt**
|
||||
- Architecture improvements
|
||||
- Monitoring enhancements
|
||||
- Automation opportunities
|
||||
|
||||
4. **Organizational Changes**
|
||||
- Team structure adjustments
|
||||
- Training requirements
|
||||
- Tool/platform investments
|
||||
|
||||
#### Action Item Template
|
||||
|
||||
```
|
||||
**Title:** {Concise description of the action}
|
||||
**Priority:** {Critical/High/Medium/Low}
|
||||
**Category:** {Fix/Process/Technical/Organizational}
|
||||
**Owner:** {Assigned person}
|
||||
**Due Date:** {Specific date}
|
||||
**Success Criteria:** {How will we know this is complete}
|
||||
**Dependencies:** {What needs to happen first}
|
||||
**Related PIRs:** {Links to other incidents this addresses}
|
||||
|
||||
**Description:**
|
||||
{Detailed description of what needs to be done and why}
|
||||
|
||||
**Implementation Plan:**
|
||||
1. {Step 1}
|
||||
2. {Step 2}
|
||||
3. {Validation step}
|
||||
|
||||
**Progress Updates:**
|
||||
- {Date}: {Progress update}
|
||||
- {Date}: {Progress update}
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Example 1: Database Connection Pool Exhaustion
|
||||
|
||||
```bash
|
||||
# Classify the incident
|
||||
echo '{"description": "Users reporting 500 errors, database connections timing out", "affected_users": "80%", "business_impact": "high"}' | python scripts/incident_classifier.py
|
||||
|
||||
# Reconstruct timeline from logs
|
||||
python scripts/timeline_reconstructor.py --input assets/db_incident_events.json --output timeline.md
|
||||
|
||||
# Generate PIR after resolution
|
||||
python scripts/pir_generator.py --incident assets/db_incident_data.json --timeline timeline.md --output pir.md
|
||||
```
|
||||
|
||||
### Example 2: API Rate Limiting Incident
|
||||
|
||||
```bash
|
||||
# Quick classification from stdin
|
||||
echo "API rate limits causing customer API calls to fail" | python scripts/incident_classifier.py --format text
|
||||
|
||||
# Build timeline from multiple sources
|
||||
python scripts/timeline_reconstructor.py --input assets/api_incident_logs.json --detect-phases --gap-analysis
|
||||
|
||||
# Generate comprehensive PIR
|
||||
python scripts/pir_generator.py --incident assets/api_incident_summary.json --rca-method fishbone --action-items
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### During Incident Response
|
||||
|
||||
1. **Maintain Calm Leadership**
|
||||
- Stay composed under pressure
|
||||
- Make decisive calls with incomplete information
|
||||
- Communicate confidence while acknowledging uncertainty
|
||||
|
||||
2. **Document Everything**
|
||||
- All actions taken and their outcomes
|
||||
- Decision rationale, especially for controversial calls
|
||||
- Timeline of events as they happen
|
||||
|
||||
3. **Effective Communication**
|
||||
- Use clear, jargon-free language
|
||||
- Provide regular updates even when there's no new information
|
||||
- Manage stakeholder expectations proactively
|
||||
|
||||
4. **Technical Excellence**
|
||||
- Prefer rollbacks to risky fixes under pressure
|
||||
- Validate fixes before declaring resolution
|
||||
- Plan for secondary failures and cascading effects
|
||||
|
||||
### Post-Incident
|
||||
|
||||
1. **Blameless Culture**
|
||||
- Focus on system failures, not individual mistakes
|
||||
- Encourage honest reporting of what went wrong
|
||||
- Celebrate learning and improvement opportunities
|
||||
|
||||
2. **Action Item Discipline**
|
||||
- Assign specific owners and due dates
|
||||
- Track progress publicly
|
||||
- Prioritize based on risk and effort
|
||||
|
||||
3. **Knowledge Sharing**
|
||||
- Share PIRs broadly within the organization
|
||||
- Update runbooks based on lessons learned
|
||||
- Conduct training sessions for common failure modes
|
||||
|
||||
4. **Continuous Improvement**
|
||||
- Look for patterns across multiple incidents
|
||||
- Invest in tooling and automation
|
||||
- Regularly review and update processes
|
||||
|
||||
## Integration with Existing Tools
|
||||
|
||||
### Monitoring and Alerting
|
||||
- PagerDuty/Opsgenie integration for escalation
|
||||
- Datadog/Grafana for metrics and dashboards
|
||||
- ELK/Splunk for log analysis and correlation
|
||||
|
||||
### Communication Platforms
|
||||
- Slack/Teams for war room coordination
|
||||
- Zoom/Meet for video bridges
|
||||
- Status page providers (Statuspage.io, etc.)
|
||||
|
||||
### Documentation Systems
|
||||
- Confluence/Notion for PIR storage
|
||||
- GitHub/GitLab for runbook version control
|
||||
- JIRA/Linear for action item tracking
|
||||
|
||||
### Change Management
|
||||
- CI/CD pipeline integration
|
||||
- Deployment tracking systems
|
||||
- Feature flag platforms for quick rollbacks
|
||||
|
||||
## Conclusion
|
||||
|
||||
The Incident Commander skill provides a comprehensive framework for managing incidents from detection through post-incident review. By implementing structured processes, clear communication templates, and thorough analysis tools, teams can improve their incident response capabilities and build more resilient systems.
|
||||
|
||||
The key to successful incident management is preparation, practice, and continuous learning. Use this framework as a starting point, but adapt it to your organization's specific needs, culture, and technical environment.
|
||||
|
||||
Remember: The goal isn't to prevent all incidents (which is impossible), but to detect them quickly, respond effectively, communicate clearly, and learn continuously.
|
||||
48
docs/skills/engineering-team/index.md
Normal file
48
docs/skills/engineering-team/index.md
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
title: "Engineering - Core Skills"
|
||||
description: "All Engineering - Core skills for Claude Code, OpenAI Codex, and OpenClaw."
|
||||
---
|
||||
|
||||
# Engineering - Core Skills
|
||||
|
||||
37 skills in this domain.
|
||||
|
||||
| Skill | Description |
|
||||
|-------|-------------|
|
||||
| [AWS Solution Architect](aws-solution-architect.md) | `aws-solution-architect` |
|
||||
| [Code Reviewer](code-reviewer.md) | `code-reviewer` |
|
||||
| [Email Template Builder](email-template-builder.md) | `email-template-builder` |
|
||||
| [Incident Commander Skill](incident-commander.md) | `incident-commander` |
|
||||
| [Microsoft 365 Tenant Manager](ms365-tenant-manager.md) | `ms365-tenant-manager` |
|
||||
| [Playwright Pro](playwright-pro.md) | `playwright-pro` |
|
||||
| [BrowserStack Integration](playwright-pro-browserstack.md) | `browserstack` (sub-skill of `playwright-pro`) |
|
||||
| [Analyze Test Coverage Gaps](playwright-pro-coverage.md) | `coverage` (sub-skill of `playwright-pro`) |
|
||||
| [Fix Failing or Flaky Tests](playwright-pro-fix.md) | `fix` (sub-skill of `playwright-pro`) |
|
||||
| [Generate Playwright Tests](playwright-pro-generate.md) | `generate` (sub-skill of `playwright-pro`) |
|
||||
| [Initialize Playwright Project](playwright-pro-init.md) | `init` (sub-skill of `playwright-pro`) |
|
||||
| [Migrate to Playwright](playwright-pro-migrate.md) | `migrate` (sub-skill of `playwright-pro`) |
|
||||
| [Smart Test Reporting](playwright-pro-report.md) | `report` (sub-skill of `playwright-pro`) |
|
||||
| [Review Playwright Tests](playwright-pro-review.md) | `review` (sub-skill of `playwright-pro`) |
|
||||
| [TestRail Integration](playwright-pro-testrail.md) | `testrail` (sub-skill of `playwright-pro`) |
|
||||
| [Self-Improving Agent](self-improving-agent.md) | `self-improving-agent` |
|
||||
| [/si:extract — Create Skills from Patterns](self-improving-agent-extract.md) | `extract` (sub-skill of `self-improving-agent`) |
|
||||
| [/si:promote — Graduate Learnings to Rules](self-improving-agent-promote.md) | `promote` (sub-skill of `self-improving-agent`) |
|
||||
| [/si:remember — Save Knowledge Explicitly](self-improving-agent-remember.md) | `remember` (sub-skill of `self-improving-agent`) |
|
||||
| [/si:review — Analyze Auto-Memory](self-improving-agent-review.md) | `review` (sub-skill of `self-improving-agent`) |
|
||||
| [/si:status — Memory Health Dashboard](self-improving-agent-status.md) | `status` (sub-skill of `self-improving-agent`) |
|
||||
| [Senior Architect](senior-architect.md) | `senior-architect` |
|
||||
| [Senior Backend Engineer](senior-backend.md) | `senior-backend` |
|
||||
| [Senior Computer Vision Engineer](senior-computer-vision.md) | `senior-computer-vision` |
|
||||
| [Senior Data Engineer](senior-data-engineer.md) | `senior-data-engineer` |
|
||||
| [Senior Data Scientist](senior-data-scientist.md) | `senior-data-scientist` |
|
||||
| [Senior Devops](senior-devops.md) | `senior-devops` |
|
||||
| [Senior Frontend](senior-frontend.md) | `senior-frontend` |
|
||||
| [Senior Fullstack](senior-fullstack.md) | `senior-fullstack` |
|
||||
| [Senior ML Engineer](senior-ml-engineer.md) | `senior-ml-engineer` |
|
||||
| [Senior Prompt Engineer](senior-prompt-engineer.md) | `senior-prompt-engineer` |
|
||||
| [Senior QA Engineer](senior-qa.md) | `senior-qa` |
|
||||
| [Senior SecOps Engineer](senior-secops.md) | `senior-secops` |
|
||||
| [Senior Security Engineer](senior-security.md) | `senior-security` |
|
||||
| [Stripe Integration Expert](stripe-integration-expert.md) | `stripe-integration-expert` |
|
||||
| [TDD Guide](tdd-guide.md) | `tdd-guide` |
|
||||
| [Technology Stack Evaluator](tech-stack-evaluator.md) | `tech-stack-evaluator` |
|
||||
302
docs/skills/engineering-team/ms365-tenant-manager.md
Normal file
302
docs/skills/engineering-team/ms365-tenant-manager.md
Normal file
@@ -0,0 +1,302 @@
|
||||
---
|
||||
title: "Microsoft 365 Tenant Manager"
|
||||
description: "Microsoft 365 Tenant Manager - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Microsoft 365 Tenant Manager
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `ms365-tenant-manager` | **Source:** [`engineering-team/ms365-tenant-manager/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/ms365-tenant-manager/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Microsoft 365 Tenant Manager
|
||||
|
||||
Expert guidance and automation for Microsoft 365 Global Administrators managing tenant setup, user lifecycle, security policies, and organizational optimization.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Trigger Phrases](#trigger-phrases)
|
||||
- [Quick Start](#quick-start)
|
||||
- [Tools](#tools)
|
||||
- [Workflows](#workflows)
|
||||
- [Best Practices](#best-practices)
|
||||
- [Reference Guides](#reference-guides)
|
||||
- [Limitations](#limitations)
|
||||
|
||||
---
|
||||
|
||||
## Trigger Phrases
|
||||
|
||||
Use this skill when you hear:
|
||||
- "set up Microsoft 365 tenant"
|
||||
- "create Office 365 users"
|
||||
- "configure Azure AD"
|
||||
- "generate PowerShell script for M365"
|
||||
- "set up Conditional Access"
|
||||
- "bulk user provisioning"
|
||||
- "M365 security audit"
|
||||
- "license management"
|
||||
- "Exchange Online configuration"
|
||||
- "Teams administration"
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Generate Security Audit Script
|
||||
|
||||
```bash
|
||||
python scripts/powershell_generator.py --action audit --output audit_script.ps1
|
||||
```
|
||||
|
||||
### Create Bulk User Provisioning Script
|
||||
|
||||
```bash
|
||||
python scripts/user_management.py --action provision --csv users.csv --license E3
|
||||
```
|
||||
|
||||
### Configure Conditional Access Policy
|
||||
|
||||
```bash
|
||||
python scripts/powershell_generator.py --action conditional-access --require-mfa --include-admins
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tools
|
||||
|
||||
### powershell_generator.py
|
||||
|
||||
Generates ready-to-use PowerShell scripts for Microsoft 365 administration.
|
||||
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
# Generate security audit script
|
||||
python scripts/powershell_generator.py --action audit
|
||||
|
||||
# Generate Conditional Access policy script
|
||||
python scripts/powershell_generator.py --action conditional-access \
|
||||
--policy-name "Require MFA for Admins" \
|
||||
--require-mfa \
|
||||
--include-users "All"
|
||||
|
||||
# Generate bulk license assignment script
|
||||
python scripts/powershell_generator.py --action license \
|
||||
--csv users.csv \
|
||||
--sku "ENTERPRISEPACK"
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Parameter | Required | Description |
|
||||
|-----------|----------|-------------|
|
||||
| `--action` | Yes | Script type: `audit`, `conditional-access`, `license`, `users` |
|
||||
| `--policy-name` | No | Name for Conditional Access policy |
|
||||
| `--require-mfa` | No | Require MFA in policy |
|
||||
| `--include-users` | No | Users to include: `All` or specific UPNs |
|
||||
| `--csv` | No | CSV file path for bulk operations |
|
||||
| `--sku` | No | License SKU for assignment |
|
||||
| `--output` | No | Output file path (default: stdout) |
|
||||
|
||||
**Output:** Complete PowerShell scripts with error handling, logging, and best practices.
|
||||
|
||||
### user_management.py
|
||||
|
||||
Automates user lifecycle operations and bulk provisioning.
|
||||
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
# Provision users from CSV
|
||||
python scripts/user_management.py --action provision --csv new_users.csv
|
||||
|
||||
# Offboard user securely
|
||||
python scripts/user_management.py --action offboard --user john.doe@company.com
|
||||
|
||||
# Generate inactive users report
|
||||
python scripts/user_management.py --action report-inactive --days 90
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Parameter | Required | Description |
|
||||
|-----------|----------|-------------|
|
||||
| `--action` | Yes | Operation: `provision`, `offboard`, `report-inactive`, `sync` |
|
||||
| `--csv` | No | CSV file for bulk operations |
|
||||
| `--user` | No | Single user UPN |
|
||||
| `--days` | No | Days for inactivity threshold (default: 90) |
|
||||
| `--license` | No | License SKU to assign |
|
||||
|
||||
### tenant_setup.py
|
||||
|
||||
Initial tenant configuration and service provisioning automation.
|
||||
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
# Generate tenant setup checklist
|
||||
python scripts/tenant_setup.py --action checklist --company "Acme Inc" --users 50
|
||||
|
||||
# Generate DNS records configuration
|
||||
python scripts/tenant_setup.py --action dns --domain acme.com
|
||||
|
||||
# Generate security baseline script
|
||||
python scripts/tenant_setup.py --action security-baseline
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Workflows
|
||||
|
||||
### Workflow 1: New Tenant Setup
|
||||
|
||||
**Step 1: Generate Setup Checklist**
|
||||
|
||||
```bash
|
||||
python scripts/tenant_setup.py --action checklist --company "Company Name" --users 100
|
||||
```
|
||||
|
||||
**Step 2: Configure DNS Records**
|
||||
|
||||
```bash
|
||||
python scripts/tenant_setup.py --action dns --domain company.com
|
||||
```
|
||||
|
||||
**Step 3: Apply Security Baseline**
|
||||
|
||||
```bash
|
||||
python scripts/powershell_generator.py --action audit > initial_audit.ps1
|
||||
```
|
||||
|
||||
**Step 4: Provision Users**
|
||||
|
||||
```bash
|
||||
python scripts/user_management.py --action provision --csv employees.csv --license E3
|
||||
```
|
||||
|
||||
### Workflow 2: Security Hardening
|
||||
|
||||
**Step 1: Run Security Audit**
|
||||
|
||||
```bash
|
||||
python scripts/powershell_generator.py --action audit --output security_audit.ps1
|
||||
```
|
||||
|
||||
**Step 2: Create MFA Policy**
|
||||
|
||||
```bash
|
||||
python scripts/powershell_generator.py --action conditional-access \
|
||||
--policy-name "Require MFA All Users" \
|
||||
--require-mfa \
|
||||
--include-users "All"
|
||||
```
|
||||
|
||||
**Step 3: Review Results**
|
||||
|
||||
Execute generated scripts and review CSV reports in output directory.
|
||||
|
||||
### Workflow 3: User Offboarding
|
||||
|
||||
**Step 1: Generate Offboarding Script**
|
||||
|
||||
```bash
|
||||
python scripts/user_management.py --action offboard --user departing.user@company.com
|
||||
```
|
||||
|
||||
**Step 2: Execute Script with -WhatIf**
|
||||
|
||||
```powershell
|
||||
.\offboard_user.ps1 -WhatIf
|
||||
```
|
||||
|
||||
**Step 3: Execute for Real**
|
||||
|
||||
```powershell
|
||||
.\offboard_user.ps1 -Confirm:$false
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Tenant Setup
|
||||
|
||||
1. Enable MFA before adding users
|
||||
2. Configure named locations for Conditional Access
|
||||
3. Use separate admin accounts with PIM
|
||||
4. Verify custom domains before bulk user creation
|
||||
5. Apply Microsoft Secure Score recommendations
|
||||
|
||||
### Security Operations
|
||||
|
||||
1. Start Conditional Access policies in report-only mode
|
||||
2. Use `-WhatIf` parameter before executing scripts
|
||||
3. Never hardcode credentials in scripts
|
||||
4. Enable audit logging for all operations
|
||||
5. Regular quarterly security reviews
|
||||
|
||||
### PowerShell Automation
|
||||
|
||||
1. Prefer Microsoft Graph over legacy MSOnline modules
|
||||
2. Include try/catch blocks for error handling
|
||||
3. Implement logging for audit trails
|
||||
4. Use Azure Key Vault for credential management
|
||||
5. Test in non-production tenant first
|
||||
|
||||
---
|
||||
|
||||
## Reference Guides
|
||||
|
||||
### When to Use Each Reference
|
||||
|
||||
**references/powershell-templates.md**
|
||||
|
||||
- Ready-to-use script templates
|
||||
- Conditional Access policy examples
|
||||
- Bulk user provisioning scripts
|
||||
- Security audit scripts
|
||||
|
||||
**references/security-policies.md**
|
||||
|
||||
- Conditional Access configuration
|
||||
- MFA enforcement strategies
|
||||
- DLP and retention policies
|
||||
- Security baseline settings
|
||||
|
||||
**references/troubleshooting.md**
|
||||
|
||||
- Common error resolutions
|
||||
- PowerShell module issues
|
||||
- Permission troubleshooting
|
||||
- DNS propagation problems
|
||||
|
||||
---
|
||||
|
||||
## Limitations
|
||||
|
||||
| Constraint | Impact |
|
||||
|------------|--------|
|
||||
| Global Admin required | Full tenant setup needs highest privilege |
|
||||
| API rate limits | Bulk operations may be throttled |
|
||||
| License dependencies | E3/E5 required for advanced features |
|
||||
| Hybrid scenarios | On-premises AD needs additional configuration |
|
||||
| PowerShell prerequisites | Microsoft.Graph module required |
|
||||
|
||||
### Required PowerShell Modules
|
||||
|
||||
```powershell
|
||||
Install-Module Microsoft.Graph -Scope CurrentUser
|
||||
Install-Module ExchangeOnlineManagement -Scope CurrentUser
|
||||
Install-Module MicrosoftTeams -Scope CurrentUser
|
||||
```
|
||||
|
||||
### Required Permissions
|
||||
|
||||
- **Global Administrator** - Full tenant setup
|
||||
- **User Administrator** - User management
|
||||
- **Security Administrator** - Security policies
|
||||
- **Exchange Administrator** - Mailbox management
|
||||
172
docs/skills/engineering-team/playwright-pro-browserstack.md
Normal file
172
docs/skills/engineering-team/playwright-pro-browserstack.md
Normal file
@@ -0,0 +1,172 @@
|
||||
---
|
||||
title: "BrowserStack Integration"
|
||||
description: "BrowserStack Integration - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# BrowserStack Integration
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `browserstack` | **Source:** [`engineering-team/playwright-pro/skills/browserstack/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/playwright-pro/skills/browserstack/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# BrowserStack Integration
|
||||
|
||||
Run Playwright tests on BrowserStack's cloud grid for cross-browser and cross-device testing.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Environment variables must be set:
|
||||
- `BROWSERSTACK_USERNAME` — your BrowserStack username
|
||||
- `BROWSERSTACK_ACCESS_KEY` — your access key
|
||||
|
||||
If not set, inform the user how to get them from [browserstack.com/accounts/settings](https://www.browserstack.com/accounts/settings) and stop.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### 1. Configure for BrowserStack
|
||||
|
||||
```
|
||||
/pw:browserstack setup
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Check current `playwright.config.ts`
|
||||
2. Add BrowserStack connect options:
|
||||
|
||||
```typescript
|
||||
// Add to playwright.config.ts
|
||||
import { defineConfig } from '@playwright/test';
|
||||
|
||||
const isBS = !!process.env.BROWSERSTACK_USERNAME;
|
||||
|
||||
export default defineConfig({
|
||||
// ... existing config
|
||||
projects: isBS ? [
|
||||
{
|
||||
name: 'chrome@latest:Windows 11',
|
||||
use: {
|
||||
connectOptions: {
|
||||
wsEndpoint: `wss://cdp.browserstack.com/playwright?caps=${encodeURIComponent(JSON.stringify({
|
||||
'browser': 'chrome',
|
||||
'browser_version': 'latest',
|
||||
'os': 'Windows',
|
||||
'os_version': '11',
|
||||
'browserstack.username': process.env.BROWSERSTACK_USERNAME,
|
||||
'browserstack.accessKey': process.env.BROWSERSTACK_ACCESS_KEY,
|
||||
}))}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'firefox@latest:Windows 11',
|
||||
use: {
|
||||
connectOptions: {
|
||||
wsEndpoint: `wss://cdp.browserstack.com/playwright?caps=${encodeURIComponent(JSON.stringify({
|
||||
'browser': 'playwright-firefox',
|
||||
'browser_version': 'latest',
|
||||
'os': 'Windows',
|
||||
'os_version': '11',
|
||||
'browserstack.username': process.env.BROWSERSTACK_USERNAME,
|
||||
'browserstack.accessKey': process.env.BROWSERSTACK_ACCESS_KEY,
|
||||
}))}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'webkit@latest:OS X Ventura',
|
||||
use: {
|
||||
connectOptions: {
|
||||
wsEndpoint: `wss://cdp.browserstack.com/playwright?caps=${encodeURIComponent(JSON.stringify({
|
||||
'browser': 'playwright-webkit',
|
||||
'browser_version': 'latest',
|
||||
'os': 'OS X',
|
||||
'os_version': 'Ventura',
|
||||
'browserstack.username': process.env.BROWSERSTACK_USERNAME,
|
||||
'browserstack.accessKey': process.env.BROWSERSTACK_ACCESS_KEY,
|
||||
}))}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
] : [
|
||||
// ... local projects fallback
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
3. Add npm script: `"test:e2e:cloud": "npx playwright test --project='chrome@*' --project='firefox@*' --project='webkit@*'"`
|
||||
|
||||
### 2. Run Tests on BrowserStack
|
||||
|
||||
```
|
||||
/pw:browserstack run
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Verify credentials are set
|
||||
2. Run tests with BrowserStack projects:
|
||||
```bash
|
||||
BROWSERSTACK_USERNAME=$BROWSERSTACK_USERNAME \
|
||||
BROWSERSTACK_ACCESS_KEY=$BROWSERSTACK_ACCESS_KEY \
|
||||
npx playwright test --project='chrome@*' --project='firefox@*'
|
||||
```
|
||||
3. Monitor execution
|
||||
4. Report results per browser
|
||||
|
||||
### 3. Get Build Results
|
||||
|
||||
```
|
||||
/pw:browserstack results
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Call `browserstack_get_builds` MCP tool
|
||||
2. Get latest build's sessions
|
||||
3. For each session:
|
||||
- Status (pass/fail)
|
||||
- Browser and OS
|
||||
- Duration
|
||||
- Video URL
|
||||
- Log URLs
|
||||
4. Format as summary table
|
||||
|
||||
### 4. Check Available Browsers
|
||||
|
||||
```
|
||||
/pw:browserstack browsers
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Call `browserstack_get_browsers` MCP tool
|
||||
2. Filter for Playwright-compatible browsers
|
||||
3. Display available browser/OS combinations
|
||||
|
||||
### 5. Local Testing
|
||||
|
||||
```
|
||||
/pw:browserstack local
|
||||
```
|
||||
|
||||
For testing localhost or staging behind firewall:
|
||||
1. Install BrowserStack Local: `npm install -D browserstack-local`
|
||||
2. Add local tunnel to config
|
||||
3. Provide setup instructions
|
||||
|
||||
## MCP Tools Used
|
||||
|
||||
| Tool | When |
|
||||
|---|---|
|
||||
| `browserstack_get_plan` | Check account limits |
|
||||
| `browserstack_get_browsers` | List available browsers |
|
||||
| `browserstack_get_builds` | List recent builds |
|
||||
| `browserstack_get_sessions` | Get sessions in a build |
|
||||
| `browserstack_get_session` | Get session details (video, logs) |
|
||||
| `browserstack_update_session` | Mark pass/fail |
|
||||
| `browserstack_get_logs` | Get text/network logs |
|
||||
|
||||
## Output
|
||||
|
||||
- Cross-browser test results table
|
||||
- Per-browser pass/fail status
|
||||
- Links to BrowserStack dashboard for video/screenshots
|
||||
- Any browser-specific failures highlighted
|
||||
102
docs/skills/engineering-team/playwright-pro-coverage.md
Normal file
102
docs/skills/engineering-team/playwright-pro-coverage.md
Normal file
@@ -0,0 +1,102 @@
|
||||
---
|
||||
title: "Analyze Test Coverage Gaps"
|
||||
description: "Analyze Test Coverage Gaps - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Analyze Test Coverage Gaps
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `coverage` | **Source:** [`engineering-team/playwright-pro/skills/coverage/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/playwright-pro/skills/coverage/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Analyze Test Coverage Gaps
|
||||
|
||||
Map all testable surfaces in the application and identify what's tested vs. what's missing.
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Map Application Surface
|
||||
|
||||
Use the `Explore` subagent to catalog:
|
||||
|
||||
**Routes/Pages:**
|
||||
- Scan route definitions (Next.js `app/`, React Router config, Vue Router, etc.)
|
||||
- List all user-facing pages with their paths
|
||||
|
||||
**Components:**
|
||||
- Identify interactive components (forms, modals, dropdowns, tables)
|
||||
- Note components with complex state logic
|
||||
|
||||
**API Endpoints:**
|
||||
- Scan API route files or backend controllers
|
||||
- List all endpoints with their methods
|
||||
|
||||
**User Flows:**
|
||||
- Identify critical paths: auth, checkout, onboarding, core features
|
||||
- Map multi-step workflows
|
||||
|
||||
### 2. Map Existing Tests
|
||||
|
||||
Scan all `*.spec.ts` / `*.spec.js` files:
|
||||
|
||||
- Extract which pages/routes are covered (by `page.goto()` calls)
|
||||
- Extract which components are tested (by locator usage)
|
||||
- Extract which API endpoints are mocked or hit
|
||||
- Count tests per area
|
||||
|
||||
### 3. Generate Coverage Matrix
|
||||
|
||||
```
|
||||
## Coverage Matrix
|
||||
|
||||
| Area | Route | Tests | Status |
|
||||
|---|---|---|---|
|
||||
| Auth | /login | 5 | ✅ Covered |
|
||||
| Auth | /register | 0 | ❌ Missing |
|
||||
| Auth | /forgot-password | 0 | ❌ Missing |
|
||||
| Dashboard | /dashboard | 3 | ⚠️ Partial (no error states) |
|
||||
| Settings | /settings | 0 | ❌ Missing |
|
||||
| Checkout | /checkout | 8 | ✅ Covered |
|
||||
```
|
||||
|
||||
### 4. Prioritize Gaps
|
||||
|
||||
Rank uncovered areas by business impact:
|
||||
|
||||
1. **Critical** — auth, payment, core features → test first
|
||||
2. **High** — user-facing CRUD, search, navigation
|
||||
3. **Medium** — settings, preferences, edge cases
|
||||
4. **Low** — static pages, about, terms
|
||||
|
||||
### 5. Suggest Test Plan
|
||||
|
||||
For each gap, recommend:
|
||||
- Number of tests needed
|
||||
- Which template from `templates/` to use
|
||||
- Estimated effort (quick/medium/complex)
|
||||
|
||||
```
|
||||
## Recommended Test Plan
|
||||
|
||||
### Priority 1: Critical
|
||||
1. /register (4 tests) — use auth/registration template — quick
|
||||
2. /forgot-password (3 tests) — use auth/password-reset template — quick
|
||||
|
||||
### Priority 2: High
|
||||
3. /settings (4 tests) — use settings/ templates — medium
|
||||
4. Dashboard error states (2 tests) — use dashboard/data-loading template — quick
|
||||
```
|
||||
|
||||
### 6. Auto-Generate (Optional)
|
||||
|
||||
Ask user: "Generate tests for the top N gaps? [Yes/No/Pick specific]"
|
||||
|
||||
If yes, invoke `/pw:generate` for each gap with the recommended template.
|
||||
|
||||
## Output
|
||||
|
||||
- Coverage matrix (table format)
|
||||
- Coverage percentage estimate
|
||||
- Prioritized gap list with effort estimates
|
||||
- Option to auto-generate missing tests
|
||||
117
docs/skills/engineering-team/playwright-pro-fix.md
Normal file
117
docs/skills/engineering-team/playwright-pro-fix.md
Normal file
@@ -0,0 +1,117 @@
|
||||
---
|
||||
title: "Fix Failing or Flaky Tests"
|
||||
description: "Fix Failing or Flaky Tests - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Fix Failing or Flaky Tests
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `fix` | **Source:** [`engineering-team/playwright-pro/skills/fix/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/playwright-pro/skills/fix/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Fix Failing or Flaky Tests
|
||||
|
||||
Diagnose and fix a Playwright test that fails or passes intermittently using a systematic taxonomy.
|
||||
|
||||
## Input
|
||||
|
||||
`$ARGUMENTS` contains:
|
||||
- A test file path: `e2e/login.spec.ts`
|
||||
- A test name: `"should redirect after login"`
|
||||
- A description: `"the checkout test fails in CI but passes locally"`
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Reproduce the Failure
|
||||
|
||||
Run the test to capture the error:
|
||||
|
||||
```bash
|
||||
npx playwright test <file> --reporter=list
|
||||
```
|
||||
|
||||
If the test passes, it's likely flaky. Run burn-in:
|
||||
|
||||
```bash
|
||||
npx playwright test <file> --repeat-each=10 --reporter=list
|
||||
```
|
||||
|
||||
If it still passes, try with parallel workers:
|
||||
|
||||
```bash
|
||||
npx playwright test --fully-parallel --workers=4 --repeat-each=5
|
||||
```
|
||||
|
||||
### 2. Capture Trace
|
||||
|
||||
Run with full tracing:
|
||||
|
||||
```bash
|
||||
npx playwright test <file> --trace=on --retries=0
|
||||
```
|
||||
|
||||
Read the trace output. Use `/debug` to analyze trace files if available.
|
||||
|
||||
### 3. Categorize the Failure
|
||||
|
||||
Load `flaky-taxonomy.md` from this skill directory.
|
||||
|
||||
Every failing test falls into one of four categories:
|
||||
|
||||
| Category | Symptom | Diagnosis |
|
||||
|---|---|---|
|
||||
| **Timing/Async** | Fails intermittently everywhere | `--repeat-each=20` reproduces locally |
|
||||
| **Test Isolation** | Fails in suite, passes alone | `--workers=1 --grep "test name"` passes |
|
||||
| **Environment** | Fails in CI, passes locally | Compare CI vs local screenshots/traces |
|
||||
| **Infrastructure** | Random, no pattern | Error references browser internals |
|
||||
|
||||
### 4. Apply Targeted Fix
|
||||
|
||||
**Timing/Async:**
|
||||
- Replace `waitForTimeout()` with web-first assertions
|
||||
- Add `await` to missing Playwright calls
|
||||
- Wait for specific network responses before asserting
|
||||
- Use `toBeVisible()` before interacting with elements
|
||||
|
||||
**Test Isolation:**
|
||||
- Remove shared mutable state between tests
|
||||
- Create test data per-test via API or fixtures
|
||||
- Use unique identifiers (timestamps, random strings) for test data
|
||||
- Check for database state leaks
|
||||
|
||||
**Environment:**
|
||||
- Match viewport sizes between local and CI
|
||||
- Account for font rendering differences in screenshots
|
||||
- Use `docker` locally to match CI environment
|
||||
- Check for timezone-dependent assertions
|
||||
|
||||
**Infrastructure:**
|
||||
- Increase timeout for slow CI runners
|
||||
- Add retries in CI config (`retries: 2`)
|
||||
- Check for browser OOM (reduce parallel workers)
|
||||
- Ensure browser dependencies are installed
|
||||
|
||||
### 5. Verify the Fix
|
||||
|
||||
Run the test 10 times to confirm stability:
|
||||
|
||||
```bash
|
||||
npx playwright test <file> --repeat-each=10 --reporter=list
|
||||
```
|
||||
|
||||
All 10 must pass. If any fail, go back to step 3.
|
||||
|
||||
### 6. Prevent Recurrence
|
||||
|
||||
Suggest:
|
||||
- Add to CI with `retries: 2` if not already
|
||||
- Enable `trace: 'on-first-retry'` in config
|
||||
- Add the fix pattern to project's test conventions doc
|
||||
|
||||
## Output
|
||||
|
||||
- Root cause category and specific issue
|
||||
- The fix applied (with diff)
|
||||
- Verification result (10/10 passes)
|
||||
- Prevention recommendation
|
||||
148
docs/skills/engineering-team/playwright-pro-generate.md
Normal file
148
docs/skills/engineering-team/playwright-pro-generate.md
Normal file
@@ -0,0 +1,148 @@
|
||||
---
|
||||
title: "Generate Playwright Tests"
|
||||
description: "Generate Playwright Tests - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Generate Playwright Tests
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `generate` | **Source:** [`engineering-team/playwright-pro/skills/generate/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/playwright-pro/skills/generate/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Generate Playwright Tests
|
||||
|
||||
Generate production-ready Playwright tests from a user story, URL, component name, or feature description.
|
||||
|
||||
## Input
|
||||
|
||||
`$ARGUMENTS` contains what to test. Examples:
|
||||
- `"user can log in with email and password"`
|
||||
- `"the checkout flow"`
|
||||
- `"src/components/UserProfile.tsx"`
|
||||
- `"the search page with filters"`
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Understand the Target
|
||||
|
||||
Parse `$ARGUMENTS` to determine:
|
||||
- **User story**: Extract the behavior to verify
|
||||
- **Component path**: Read the component source code
|
||||
- **Page/URL**: Identify the route and its elements
|
||||
- **Feature name**: Map to relevant app areas
|
||||
|
||||
### 2. Explore the Codebase
|
||||
|
||||
Use the `Explore` subagent to gather context:
|
||||
|
||||
- Read `playwright.config.ts` for `testDir`, `baseURL`, `projects`
|
||||
- Check existing tests in `testDir` for patterns, fixtures, and conventions
|
||||
- If a component path is given, read the component to understand its props, states, and interactions
|
||||
- Check for existing page objects in `pages/`
|
||||
- Check for existing fixtures in `fixtures/`
|
||||
- Check for auth setup (`auth.setup.ts` or `storageState` config)
|
||||
|
||||
### 3. Select Templates
|
||||
|
||||
Check `templates/` in this plugin for matching patterns:
|
||||
|
||||
| If testing... | Load template from |
|
||||
|---|---|
|
||||
| Login/auth flow | `templates/auth/login.md` |
|
||||
| CRUD operations | `templates/crud/` |
|
||||
| Checkout/payment | `templates/checkout/` |
|
||||
| Search/filter UI | `templates/search/` |
|
||||
| Form submission | `templates/forms/` |
|
||||
| Dashboard/data | `templates/dashboard/` |
|
||||
| Settings page | `templates/settings/` |
|
||||
| Onboarding flow | `templates/onboarding/` |
|
||||
| API endpoints | `templates/api/` |
|
||||
| Accessibility | `templates/accessibility/` |
|
||||
|
||||
Adapt the template to the specific app — replace `{{placeholders}}` with actual selectors, URLs, and data.
|
||||
|
||||
### 4. Generate the Test
|
||||
|
||||
Follow these rules:
|
||||
|
||||
**Structure:**
|
||||
```typescript
|
||||
import { test, expect } from '@playwright/test';
|
||||
// Import custom fixtures if the project uses them
|
||||
|
||||
test.describe('Feature Name', () => {
|
||||
// Group related behaviors
|
||||
|
||||
test('should <expected behavior>', async ({ page }) => {
|
||||
// Arrange: navigate, set up state
|
||||
// Act: perform user action
|
||||
// Assert: verify outcome
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
**Locator priority** (use the first that works):
|
||||
1. `getByRole()` — buttons, links, headings, form elements
|
||||
2. `getByLabel()` — form fields with labels
|
||||
3. `getByText()` — non-interactive text content
|
||||
4. `getByPlaceholder()` — inputs with placeholder text
|
||||
5. `getByTestId()` — when semantic options aren't available
|
||||
|
||||
**Assertions** — always web-first:
|
||||
```typescript
|
||||
// GOOD — auto-retries
|
||||
await expect(page.getByRole('heading')).toBeVisible();
|
||||
await expect(page.getByRole('alert')).toHaveText('Success');
|
||||
|
||||
// BAD — no retry
|
||||
const text = await page.textContent('.msg');
|
||||
expect(text).toBe('Success');
|
||||
```
|
||||
|
||||
**Never use:**
|
||||
- `page.waitForTimeout()`
|
||||
- `page.$(selector)` or `page.$$(selector)`
|
||||
- Bare CSS selectors unless absolutely necessary
|
||||
- `page.evaluate()` for things locators can do
|
||||
|
||||
**Always include:**
|
||||
- Descriptive test names that explain the behavior
|
||||
- Error/edge case tests alongside happy path
|
||||
- Proper `await` on every Playwright call
|
||||
- `baseURL`-relative navigation (`page.goto('/')` not `page.goto('http://...')`)
|
||||
|
||||
### 5. Match Project Conventions
|
||||
|
||||
- If project uses TypeScript → generate `.spec.ts`
|
||||
- If project uses JavaScript → generate `.spec.js` with `require()` imports
|
||||
- If project has page objects → use them instead of inline locators
|
||||
- If project has custom fixtures → import and use them
|
||||
- If project has a test data directory → create test data files there
|
||||
|
||||
### 6. Generate Supporting Files (If Needed)
|
||||
|
||||
- **Page object**: If the test touches 5+ unique locators on one page, create a page object
|
||||
- **Fixture**: If the test needs shared setup (auth, data), create or extend a fixture
|
||||
- **Test data**: If the test uses structured data, create a JSON file in `test-data/`
|
||||
|
||||
### 7. Verify
|
||||
|
||||
Run the generated test:
|
||||
|
||||
```bash
|
||||
npx playwright test <generated-file> --reporter=list
|
||||
```
|
||||
|
||||
If it fails:
|
||||
1. Read the error
|
||||
2. Fix the test (not the app)
|
||||
3. Run again
|
||||
4. If it's an app issue, report it to the user
|
||||
|
||||
## Output
|
||||
|
||||
- Generated test file(s) with path
|
||||
- Any supporting files created (page objects, fixtures, data)
|
||||
- Test run result
|
||||
- Coverage note: what behaviors are now tested
|
||||
205
docs/skills/engineering-team/playwright-pro-init.md
Normal file
205
docs/skills/engineering-team/playwright-pro-init.md
Normal file
@@ -0,0 +1,205 @@
|
||||
---
|
||||
title: "Initialize Playwright Project"
|
||||
description: "Initialize Playwright Project - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Initialize Playwright Project
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `init` | **Source:** [`engineering-team/playwright-pro/skills/init/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/playwright-pro/skills/init/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Initialize Playwright Project
|
||||
|
||||
Set up a production-ready Playwright testing environment. Detect the framework, generate config, folder structure, example test, and CI workflow.
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Analyze the Project
|
||||
|
||||
Use the `Explore` subagent to scan the project:
|
||||
|
||||
- Check `package.json` for framework (React, Next.js, Vue, Angular, Svelte)
|
||||
- Check for `tsconfig.json` → use TypeScript; otherwise JavaScript
|
||||
- Check if Playwright is already installed (`@playwright/test` in dependencies)
|
||||
- Check for existing test directories (`tests/`, `e2e/`, `__tests__/`)
|
||||
- Check for existing CI config (`.github/workflows/`, `.gitlab-ci.yml`)
|
||||
|
||||
### 2. Install Playwright
|
||||
|
||||
If not already installed:
|
||||
|
||||
```bash
|
||||
npm init playwright@latest -- --quiet
|
||||
```
|
||||
|
||||
Or if the user prefers manual setup:
|
||||
|
||||
```bash
|
||||
npm install -D @playwright/test
|
||||
npx playwright install --with-deps chromium
|
||||
```
|
||||
|
||||
### 3. Generate `playwright.config.ts`
|
||||
|
||||
Adapt to the detected framework:
|
||||
|
||||
**Next.js:**
|
||||
```typescript
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './e2e',
|
||||
fullyParallel: true,
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
reporter: [
|
||||
['html', { open: 'never' }],
|
||||
['list'],
|
||||
],
|
||||
use: {
|
||||
baseURL: 'http://localhost:3000',
|
||||
trace: 'on-first-retry',
|
||||
screenshot: 'only-on-failure',
|
||||
},
|
||||
projects: [
|
||||
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
|
||||
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
|
||||
{ name: 'webkit', use: { ...devices['Desktop Safari'] } },
|
||||
],
|
||||
webServer: {
|
||||
command: 'npm run dev',
|
||||
url: 'http://localhost:3000',
|
||||
reuseExistingServer: !process.env.CI,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
**React (Vite):**
|
||||
- Change `baseURL` to `http://localhost:5173`
|
||||
- Change `webServer.command` to `npm run dev`
|
||||
|
||||
**Vue/Nuxt:**
|
||||
- Change `baseURL` to `http://localhost:3000`
|
||||
- Change `webServer.command` to `npm run dev`
|
||||
|
||||
**Angular:**
|
||||
- Change `baseURL` to `http://localhost:4200`
|
||||
- Change `webServer.command` to `npm run start`
|
||||
|
||||
**No framework detected:**
|
||||
- Omit `webServer` block
|
||||
- Set `baseURL` from user input or leave as placeholder
|
||||
|
||||
### 4. Create Folder Structure
|
||||
|
||||
```
|
||||
e2e/
|
||||
├── fixtures/
|
||||
│ └── index.ts # Custom fixtures
|
||||
├── pages/
|
||||
│ └── .gitkeep # Page object models
|
||||
├── test-data/
|
||||
│ └── .gitkeep # Test data files
|
||||
└── example.spec.ts # First example test
|
||||
```
|
||||
|
||||
### 5. Generate Example Test
|
||||
|
||||
```typescript
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Homepage', () => {
|
||||
test('should load successfully', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await expect(page).toHaveTitle(/.+/);
|
||||
});
|
||||
|
||||
test('should have visible navigation', async ({ page }) => {
|
||||
await page.goto('/');
|
||||
await expect(page.getByRole('navigation')).toBeVisible();
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
### 6. Generate CI Workflow
|
||||
|
||||
If `.github/workflows/` exists, create `playwright.yml`:
|
||||
|
||||
```yaml
|
||||
name: Playwright Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, dev]
|
||||
pull_request:
|
||||
branches: [main, dev]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
timeout-minutes: 60
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: lts/*
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Install Playwright Browsers
|
||||
run: npx playwright install --with-deps
|
||||
- name: Run Playwright tests
|
||||
run: npx playwright test
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: ${{ !cancelled() }}
|
||||
with:
|
||||
name: playwright-report
|
||||
path: playwright-report/
|
||||
retention-days: 30
|
||||
```
|
||||
|
||||
If `.gitlab-ci.yml` exists, add a Playwright stage instead.
|
||||
|
||||
### 7. Update `.gitignore`
|
||||
|
||||
Append if not already present:
|
||||
|
||||
```
|
||||
/test-results/
|
||||
/playwright-report/
|
||||
/blob-report/
|
||||
/playwright/.cache/
|
||||
```
|
||||
|
||||
### 8. Add npm Scripts
|
||||
|
||||
Add to `package.json` scripts:
|
||||
|
||||
```json
|
||||
{
|
||||
"test:e2e": "playwright test",
|
||||
"test:e2e:ui": "playwright test --ui",
|
||||
"test:e2e:debug": "playwright test --debug"
|
||||
}
|
||||
```
|
||||
|
||||
### 9. Verify Setup
|
||||
|
||||
Run the example test:
|
||||
|
||||
```bash
|
||||
npx playwright test
|
||||
```
|
||||
|
||||
Report the result. If it fails, diagnose and fix before completing.
|
||||
|
||||
## Output
|
||||
|
||||
Confirm what was created:
|
||||
- Config file path and key settings
|
||||
- Test directory and example test
|
||||
- CI workflow (if applicable)
|
||||
- npm scripts added
|
||||
- How to run: `npx playwright test` or `npm run test:e2e`
|
||||
139
docs/skills/engineering-team/playwright-pro-migrate.md
Normal file
139
docs/skills/engineering-team/playwright-pro-migrate.md
Normal file
@@ -0,0 +1,139 @@
|
||||
---
|
||||
title: "Migrate to Playwright"
|
||||
description: "Migrate to Playwright - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Migrate to Playwright
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `migrate` | **Source:** [`engineering-team/playwright-pro/skills/migrate/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/playwright-pro/skills/migrate/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Migrate to Playwright
|
||||
|
||||
Interactive migration from Cypress or Selenium to Playwright with file-by-file conversion.
|
||||
|
||||
## Input
|
||||
|
||||
`$ARGUMENTS` can be:
|
||||
- `"from cypress"` — migrate Cypress test suite
|
||||
- `"from selenium"` — migrate Selenium/WebDriver tests
|
||||
- A file path: convert a specific test file
|
||||
- Empty: auto-detect source framework
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Detect Source Framework
|
||||
|
||||
Use `Explore` subagent to scan:
|
||||
- `cypress/` directory or `cypress.config.ts` → Cypress
|
||||
- `selenium`, `webdriver` in `package.json` deps → Selenium
|
||||
- `.py` test files with `selenium` imports → Selenium (Python)
|
||||
|
||||
### 2. Assess Migration Scope
|
||||
|
||||
Count files and categorize:
|
||||
|
||||
```
|
||||
Migration Assessment:
|
||||
- Total test files: X
|
||||
- Cypress custom commands: Y
|
||||
- Cypress fixtures: Z
|
||||
- Estimated effort: [small|medium|large]
|
||||
```
|
||||
|
||||
| Size | Files | Approach |
|
||||
|---|---|---|
|
||||
| Small (1-10) | Convert sequentially | Direct conversion |
|
||||
| Medium (11-30) | Batch in groups of 5 | Use sub-agents |
|
||||
| Large (31+) | Use `/batch` | Parallel conversion with `/batch` |
|
||||
|
||||
### 3. Set Up Playwright (If Not Present)
|
||||
|
||||
Run `/pw:init` first if Playwright isn't configured.
|
||||
|
||||
### 4. Convert Files
|
||||
|
||||
For each file, apply the appropriate mapping:
|
||||
|
||||
#### Cypress → Playwright
|
||||
|
||||
Load `cypress-mapping.md` for complete reference.
|
||||
|
||||
Key translations:
|
||||
```
|
||||
cy.visit(url) → page.goto(url)
|
||||
cy.get(selector) → page.locator(selector) or page.getByRole(...)
|
||||
cy.contains(text) → page.getByText(text)
|
||||
cy.find(selector) → locator.locator(selector)
|
||||
cy.click() → locator.click()
|
||||
cy.type(text) → locator.fill(text)
|
||||
cy.should('be.visible') → expect(locator).toBeVisible()
|
||||
cy.should('have.text') → expect(locator).toHaveText(text)
|
||||
cy.intercept() → page.route()
|
||||
cy.wait('@alias') → page.waitForResponse()
|
||||
cy.fixture() → JSON import or test data file
|
||||
```
|
||||
|
||||
**Cypress custom commands** → Playwright fixtures or helper functions
|
||||
**Cypress plugins** → Playwright config or fixtures
|
||||
**`before`/`beforeEach`** → `test.beforeAll()` / `test.beforeEach()`
|
||||
|
||||
#### Selenium → Playwright
|
||||
|
||||
Load `selenium-mapping.md` for complete reference.
|
||||
|
||||
Key translations:
|
||||
```
|
||||
driver.get(url) → page.goto(url)
|
||||
driver.findElement(By.id('x')) → page.locator('#x') or page.getByTestId('x')
|
||||
driver.findElement(By.css('.x')) → page.locator('.x') or page.getByRole(...)
|
||||
element.click() → locator.click()
|
||||
element.sendKeys(text) → locator.fill(text)
|
||||
element.getText() → locator.textContent()
|
||||
WebDriverWait + ExpectedConditions → expect(locator).toBeVisible()
|
||||
driver.switchTo().frame() → page.frameLocator()
|
||||
Actions → locator.hover(), locator.dragTo()
|
||||
```
|
||||
|
||||
### 5. Upgrade Locators
|
||||
|
||||
During conversion, upgrade selectors to Playwright best practices:
|
||||
- `#id` → `getByTestId()` or `getByRole()`
|
||||
- `.class` → `getByRole()` or `getByText()`
|
||||
- `[data-testid]` → `getByTestId()`
|
||||
- XPath → role-based locators
|
||||
|
||||
### 6. Convert Custom Commands / Utilities
|
||||
|
||||
- Cypress custom commands → Playwright custom fixtures via `test.extend()`
|
||||
- Selenium page objects → Playwright page objects (keep structure, update API)
|
||||
- Shared helpers → TypeScript utility functions
|
||||
|
||||
### 7. Verify Each Converted File
|
||||
|
||||
After converting each file:
|
||||
|
||||
```bash
|
||||
npx playwright test <converted-file> --reporter=list
|
||||
```
|
||||
|
||||
Fix any compilation or runtime errors before moving to the next file.
|
||||
|
||||
### 8. Clean Up
|
||||
|
||||
After all files are converted:
|
||||
- Remove Cypress/Selenium dependencies from `package.json`
|
||||
- Remove old config files (`cypress.config.ts`, etc.)
|
||||
- Update CI workflow to use Playwright
|
||||
- Update README with new test commands
|
||||
|
||||
Ask user before deleting anything.
|
||||
|
||||
## Output
|
||||
|
||||
- Conversion summary: files converted, total tests migrated
|
||||
- Any tests that couldn't be auto-converted (manual intervention needed)
|
||||
- Updated CI config
|
||||
- Before/after comparison of test run results
|
||||
131
docs/skills/engineering-team/playwright-pro-report.md
Normal file
131
docs/skills/engineering-team/playwright-pro-report.md
Normal file
@@ -0,0 +1,131 @@
|
||||
---
|
||||
title: "Smart Test Reporting"
|
||||
description: "Smart Test Reporting - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Smart Test Reporting
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `report` | **Source:** [`engineering-team/playwright-pro/skills/report/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/playwright-pro/skills/report/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Smart Test Reporting
|
||||
|
||||
Generate test reports that plug into the user's existing workflow. Zero new tools.
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Run Tests (If Not Already Run)
|
||||
|
||||
Check if recent test results exist:
|
||||
|
||||
```bash
|
||||
ls -la test-results/ playwright-report/ 2>/dev/null
|
||||
```
|
||||
|
||||
If no recent results, run tests:
|
||||
|
||||
```bash
|
||||
npx playwright test --reporter=json,html,list 2>&1 | tee test-output.log
|
||||
```
|
||||
|
||||
### 2. Parse Results
|
||||
|
||||
Read the JSON report:
|
||||
|
||||
```bash
|
||||
npx playwright test --reporter=json 2> /dev/null
|
||||
```
|
||||
|
||||
Extract:
|
||||
- Total tests, passed, failed, skipped, flaky
|
||||
- Duration per test and total
|
||||
- Failed test names with error messages
|
||||
- Flaky tests (passed on retry)
|
||||
|
||||
### 3. Detect Report Destination
|
||||
|
||||
Check what's configured and route automatically:
|
||||
|
||||
| Check | If found | Action |
|
||||
|---|---|---|
|
||||
| `TESTRAIL_URL` env var | TestRail configured | Push results via `/pw:testrail push` |
|
||||
| `SLACK_WEBHOOK_URL` env var | Slack configured | Post summary to Slack |
|
||||
| `.github/workflows/` | GitHub Actions | Results go to PR comment via artifacts |
|
||||
| `playwright-report/` | HTML reporter | Open or serve the report |
|
||||
| None of the above | Default | Generate markdown report |
|
||||
|
||||
### 4. Generate Report
|
||||
|
||||
#### Markdown Report (Always Generated)
|
||||
|
||||
```markdown
|
||||
# Test Results — {{date}}
|
||||
|
||||
## Summary
|
||||
- ✅ Passed: {{passed}}
|
||||
- ❌ Failed: {{failed}}
|
||||
- ⏭️ Skipped: {{skipped}}
|
||||
- 🔄 Flaky: {{flaky}}
|
||||
- ⏱️ Duration: {{duration}}
|
||||
|
||||
## Failed Tests
|
||||
| Test | Error | File |
|
||||
|---|---|---|
|
||||
| {{name}} | {{error}} | {{file}}:{{line}} |
|
||||
|
||||
## Flaky Tests
|
||||
| Test | Retries | File |
|
||||
|---|---|---|
|
||||
| {{name}} | {{retries}} | {{file}} |
|
||||
|
||||
## By Project
|
||||
| Browser | Passed | Failed | Duration |
|
||||
|---|---|---|---|
|
||||
| Chromium | X | Y | Zs |
|
||||
| Firefox | X | Y | Zs |
|
||||
| WebKit | X | Y | Zs |
|
||||
```
|
||||
|
||||
Save to `test-reports/{{date}}-report.md`.
|
||||
|
||||
#### Slack Summary (If Webhook Configured)
|
||||
|
||||
```bash
|
||||
curl -X POST "$SLACK_WEBHOOK_URL" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"text": "🧪 Test Results: ✅ {{passed}} | ❌ {{failed}} | ⏱️ {{duration}}\n{{failed_details}}"
|
||||
}'
|
||||
```
|
||||
|
||||
#### TestRail Push (If Configured)
|
||||
|
||||
Invoke `/pw:testrail push` with the JSON results.
|
||||
|
||||
#### HTML Report
|
||||
|
||||
```bash
|
||||
npx playwright show-report
|
||||
```
|
||||
|
||||
Or if in CI:
|
||||
```bash
|
||||
echo "HTML report available at: playwright-report/index.html"
|
||||
```
|
||||
|
||||
### 5. Trend Analysis (If Historical Data Exists)
|
||||
|
||||
If previous reports exist in `test-reports/`:
|
||||
- Compare pass rate over time
|
||||
- Identify tests that became flaky recently
|
||||
- Highlight new failures vs. recurring failures
|
||||
|
||||
## Output
|
||||
|
||||
- Summary with pass/fail/skip/flaky counts
|
||||
- Failed test details with error messages
|
||||
- Report destination confirmation
|
||||
- Trend comparison (if historical data available)
|
||||
- Next action recommendation (fix failures or celebrate green)
|
||||
106
docs/skills/engineering-team/playwright-pro-review.md
Normal file
106
docs/skills/engineering-team/playwright-pro-review.md
Normal file
@@ -0,0 +1,106 @@
|
||||
---
|
||||
title: "Review Playwright Tests"
|
||||
description: "Review Playwright Tests - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Review Playwright Tests
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `review` | **Source:** [`engineering-team/playwright-pro/skills/review/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/playwright-pro/skills/review/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Review Playwright Tests
|
||||
|
||||
Systematically review Playwright test files for anti-patterns, missed best practices, and coverage gaps.
|
||||
|
||||
## Input
|
||||
|
||||
`$ARGUMENTS` can be:
|
||||
- A file path: review that specific test file
|
||||
- A directory: review all test files in the directory
|
||||
- Empty: review all tests in the project's `testDir`
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Gather Context
|
||||
|
||||
- Read `playwright.config.ts` for project settings
|
||||
- List all `*.spec.ts` / `*.spec.js` files in scope
|
||||
- If reviewing a single file, also check related page objects and fixtures
|
||||
|
||||
### 2. Check Each File Against Anti-Patterns
|
||||
|
||||
Load `anti-patterns.md` from this skill directory. Check for all 20 anti-patterns.
|
||||
|
||||
**Critical (must fix):**
|
||||
1. `waitForTimeout()` usage
|
||||
2. Non-web-first assertions (`expect(await ...)`)
|
||||
3. Hardcoded URLs instead of `baseURL`
|
||||
4. CSS/XPath selectors when role-based exists
|
||||
5. Missing `await` on Playwright calls
|
||||
6. Shared mutable state between tests
|
||||
7. Test execution order dependencies
|
||||
|
||||
**Warning (should fix):**
|
||||
8. Tests longer than 50 lines (consider splitting)
|
||||
9. Magic strings without named constants
|
||||
10. Missing error/edge case tests
|
||||
11. `page.evaluate()` for things locators can do
|
||||
12. Nested `test.describe()` more than 2 levels deep
|
||||
13. Generic test names ("should work", "test 1")
|
||||
|
||||
**Info (consider):**
|
||||
14. No page objects for pages with 5+ locators
|
||||
15. Inline test data instead of factory/fixture
|
||||
16. Missing accessibility assertions
|
||||
17. No visual regression tests for UI-heavy pages
|
||||
18. Console error assertions not checked
|
||||
19. Network idle waits instead of specific assertions
|
||||
20. Missing `test.describe()` grouping
|
||||
|
||||
### 3. Score Each File
|
||||
|
||||
Rate 1-10 based on:
|
||||
- **9-10**: Production-ready, follows all golden rules
|
||||
- **7-8**: Good, minor improvements possible
|
||||
- **5-6**: Functional but has anti-patterns
|
||||
- **3-4**: Significant issues, likely flaky
|
||||
- **1-2**: Needs rewrite
|
||||
|
||||
### 4. Generate Review Report
|
||||
|
||||
For each file:
|
||||
```
|
||||
## <filename> — Score: X/10
|
||||
|
||||
### Critical
|
||||
- Line 15: `waitForTimeout(2000)` → use `expect(locator).toBeVisible()`
|
||||
- Line 28: CSS selector `.btn-submit` → `getByRole('button', { name: 'Submit' })`
|
||||
|
||||
### Warning
|
||||
- Line 42: Test name "test login" → "should redirect to dashboard after login"
|
||||
|
||||
### Suggestions
|
||||
- Consider adding error case: what happens with invalid credentials?
|
||||
```
|
||||
|
||||
### 5. For Project-Wide Review
|
||||
|
||||
If reviewing an entire test suite:
|
||||
- Spawn sub-agents per file for parallel review (up to 5 concurrent)
|
||||
- Or use `/batch` for very large suites
|
||||
- Aggregate results into a summary table
|
||||
|
||||
### 6. Offer Fixes
|
||||
|
||||
For each critical issue, provide the corrected code. Ask user: "Apply these fixes? [Yes/No]"
|
||||
|
||||
If yes, apply all fixes using `Edit` tool.
|
||||
|
||||
## Output
|
||||
|
||||
- File-by-file review with scores
|
||||
- Summary: total files, average score, critical issue count
|
||||
- Actionable fix list
|
||||
- Coverage gaps identified (pages/features with no tests)
|
||||
133
docs/skills/engineering-team/playwright-pro-testrail.md
Normal file
133
docs/skills/engineering-team/playwright-pro-testrail.md
Normal file
@@ -0,0 +1,133 @@
|
||||
---
|
||||
title: "TestRail Integration"
|
||||
description: "TestRail Integration - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# TestRail Integration
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `testrail` | **Source:** [`engineering-team/playwright-pro/skills/testrail/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/playwright-pro/skills/testrail/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# TestRail Integration
|
||||
|
||||
Bidirectional sync between Playwright tests and TestRail test management.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Environment variables must be set:
|
||||
- `TESTRAIL_URL` — e.g., `https://your-instance.testrail.io`
|
||||
- `TESTRAIL_USER` — your email
|
||||
- `TESTRAIL_API_KEY` — API key from TestRail
|
||||
|
||||
If not set, inform the user how to configure them and stop.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### 1. Import Test Cases → Generate Playwright Tests
|
||||
|
||||
```
|
||||
/pw:testrail import --project <id> --suite <id>
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Call `testrail_get_cases` MCP tool to fetch test cases
|
||||
2. For each test case:
|
||||
- Read title, preconditions, steps, expected results
|
||||
- Map to a Playwright test using appropriate template
|
||||
- Include TestRail case ID as test annotation: `test.info().annotations.push({ type: 'testrail', description: 'C12345' })`
|
||||
3. Generate test files grouped by section
|
||||
4. Report: X cases imported, Y tests generated
|
||||
|
||||
### 2. Push Test Results → TestRail
|
||||
|
||||
```
|
||||
/pw:testrail push --run <id>
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Run Playwright tests with JSON reporter:
|
||||
```bash
|
||||
npx playwright test --reporter=json > test-results.json
|
||||
```
|
||||
2. Parse results: map each test to its TestRail case ID (from annotations)
|
||||
3. Call `testrail_add_result` MCP tool for each test:
|
||||
- Pass → status_id: 1
|
||||
- Fail → status_id: 5, include error message
|
||||
- Skip → status_id: 2
|
||||
4. Report: X results pushed, Y passed, Z failed
|
||||
|
||||
### 3. Create Test Run
|
||||
|
||||
```
|
||||
/pw:testrail run --project <id> --name "Sprint 42 Regression"
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Call `testrail_add_run` MCP tool
|
||||
2. Include all test case IDs found in Playwright test annotations
|
||||
3. Return run ID for result pushing
|
||||
|
||||
### 4. Sync Status
|
||||
|
||||
```
|
||||
/pw:testrail status --project <id>
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Fetch test cases from TestRail
|
||||
2. Scan local Playwright tests for TestRail annotations
|
||||
3. Report coverage:
|
||||
```
|
||||
TestRail cases: 150
|
||||
Playwright tests with TestRail IDs: 120
|
||||
Unlinked TestRail cases: 30
|
||||
Playwright tests without TestRail IDs: 15
|
||||
```
|
||||
|
||||
### 5. Update Test Cases in TestRail
|
||||
|
||||
```
|
||||
/pw:testrail update --case <id>
|
||||
```
|
||||
|
||||
Steps:
|
||||
1. Read the Playwright test for this case ID
|
||||
2. Extract steps and expected results from test code
|
||||
3. Call `testrail_update_case` MCP tool to update steps
|
||||
|
||||
## MCP Tools Used
|
||||
|
||||
| Tool | When |
|
||||
|---|---|
|
||||
| `testrail_get_projects` | List available projects |
|
||||
| `testrail_get_suites` | List suites in project |
|
||||
| `testrail_get_cases` | Read test cases |
|
||||
| `testrail_add_case` | Create new test case |
|
||||
| `testrail_update_case` | Update existing case |
|
||||
| `testrail_add_run` | Create test run |
|
||||
| `testrail_add_result` | Push individual result |
|
||||
| `testrail_get_results` | Read historical results |
|
||||
|
||||
## Test Annotation Format
|
||||
|
||||
All Playwright tests linked to TestRail include:
|
||||
|
||||
```typescript
|
||||
test('should login successfully', async ({ page }) => {
|
||||
test.info().annotations.push({
|
||||
type: 'testrail',
|
||||
description: 'C12345',
|
||||
});
|
||||
// ... test code
|
||||
});
|
||||
```
|
||||
|
||||
This annotation is the bridge between Playwright and TestRail.
|
||||
|
||||
## Output
|
||||
|
||||
- Operation summary with counts
|
||||
- Any errors or unmatched cases
|
||||
- Link to TestRail run/results
|
||||
92
docs/skills/engineering-team/playwright-pro.md
Normal file
92
docs/skills/engineering-team/playwright-pro.md
Normal file
@@ -0,0 +1,92 @@
|
||||
---
|
||||
title: "Playwright Pro"
|
||||
description: "Playwright Pro - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Playwright Pro
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `playwright-pro` | **Source:** [`engineering-team/playwright-pro/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/playwright-pro/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Playwright Pro
|
||||
|
||||
Production-grade Playwright testing toolkit for AI coding agents.
|
||||
|
||||
## Available Commands
|
||||
|
||||
When installed as a Claude Code plugin, these are available as `/pw:` commands:
|
||||
|
||||
| Command | What it does |
|
||||
|---|---|
|
||||
| `/pw:init` | Set up Playwright — detects framework, generates config, CI, first test |
|
||||
| `/pw:generate <spec>` | Generate tests from user story, URL, or component |
|
||||
| `/pw:review` | Review tests for anti-patterns and coverage gaps |
|
||||
| `/pw:fix <test>` | Diagnose and fix failing or flaky tests |
|
||||
| `/pw:migrate` | Migrate from Cypress or Selenium to Playwright |
|
||||
| `/pw:coverage` | Analyze what's tested vs. what's missing |
|
||||
| `/pw:testrail` | Sync with TestRail — read cases, push results |
|
||||
| `/pw:browserstack` | Run on BrowserStack, pull cross-browser reports |
|
||||
| `/pw:report` | Generate test report in your preferred format |
|
||||
|
||||
## Golden Rules
|
||||
|
||||
1. `getByRole()` over CSS/XPath — resilient to markup changes
|
||||
2. Never `page.waitForTimeout()` — use web-first assertions
|
||||
3. `expect(locator)` auto-retries; `expect(await locator.textContent())` does not
|
||||
4. Isolate every test — no shared state between tests
|
||||
5. `baseURL` in config — zero hardcoded URLs
|
||||
6. Retries: `2` in CI, `0` locally
|
||||
7. Traces: `'on-first-retry'` — rich debugging without slowdown
|
||||
8. Fixtures over globals — `test.extend()` for shared state
|
||||
9. One behavior per test — multiple related assertions are fine
|
||||
10. Mock external services only — never mock your own app
|
||||
|
||||
## Locator Priority
|
||||
|
||||
```
|
||||
1. getByRole() — buttons, links, headings, form elements
|
||||
2. getByLabel() — form fields with labels
|
||||
3. getByText() — non-interactive text
|
||||
4. getByPlaceholder() — inputs with placeholder
|
||||
5. getByTestId() — when no semantic option exists
|
||||
6. page.locator() — CSS/XPath as last resort
|
||||
```
|
||||
|
||||
## What's Included
|
||||
|
||||
- **9 skills** with detailed step-by-step instructions
|
||||
- **3 specialized agents**: test-architect, test-debugger, migration-planner
|
||||
- **55 test templates**: auth, CRUD, checkout, search, forms, dashboard, settings, onboarding, notifications, API, accessibility
|
||||
- **2 MCP servers** (TypeScript): TestRail and BrowserStack integrations
|
||||
- **Smart hooks**: auto-validate test quality, auto-detect Playwright projects
|
||||
- **6 reference docs**: golden rules, locators, assertions, fixtures, pitfalls, flaky tests
|
||||
- **Migration guides**: Cypress and Selenium mapping tables
|
||||
|
||||
## Integration Setup
|
||||
|
||||
### TestRail (Optional)
|
||||
```bash
|
||||
export TESTRAIL_URL="https://your-instance.testrail.io"
|
||||
export TESTRAIL_USER="your@email.com"
|
||||
export TESTRAIL_API_KEY="your-api-key"
|
||||
```
|
||||
|
||||
### BrowserStack (Optional)
|
||||
```bash
|
||||
export BROWSERSTACK_USERNAME="your-username"
|
||||
export BROWSERSTACK_ACCESS_KEY="your-access-key"
|
||||
```
|
||||
|
||||
## Quick Reference
|
||||
|
||||
See `reference/` directory for:
|
||||
- `golden-rules.md` — The 10 non-negotiable rules
|
||||
- `locators.md` — Complete locator priority with cheat sheet
|
||||
- `assertions.md` — Web-first assertions reference
|
||||
- `fixtures.md` — Custom fixtures and storageState patterns
|
||||
- `common-pitfalls.md` — Top 10 mistakes and fixes
|
||||
- `flaky-tests.md` — Diagnosis commands and quick fixes
|
||||
|
||||
See `templates/README.md` for the full template index.
|
||||
185
docs/skills/engineering-team/self-improving-agent-extract.md
Normal file
185
docs/skills/engineering-team/self-improving-agent-extract.md
Normal file
@@ -0,0 +1,185 @@
|
||||
---
|
||||
title: "/si:extract — Create Skills from Patterns"
|
||||
description: "/si:extract — Create Skills from Patterns - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# /si:extract — Create Skills from Patterns
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `extract` | **Source:** [`engineering-team/self-improving-agent/skills/extract/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/self-improving-agent/skills/extract/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# /si:extract — Create Skills from Patterns
|
||||
|
||||
Transforms a recurring pattern or debugging solution into a standalone, portable skill that can be installed in any project.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/si:extract <pattern description> # Interactive extraction
|
||||
/si:extract <pattern> --name docker-m1-fixes # Specify skill name
|
||||
/si:extract <pattern> --output ./skills/ # Custom output directory
|
||||
/si:extract <pattern> --dry-run # Preview without creating files
|
||||
```
|
||||
|
||||
## When to Extract
|
||||
|
||||
A learning qualifies for skill extraction when ANY of these are true:
|
||||
|
||||
| Criterion | Signal |
|
||||
|---|---|
|
||||
| **Recurring** | Same issue across 2+ projects |
|
||||
| **Non-obvious** | Required real debugging to discover |
|
||||
| **Broadly applicable** | Not tied to one specific codebase |
|
||||
| **Complex solution** | Multi-step fix that's easy to forget |
|
||||
| **User-flagged** | "Save this as a skill", "I want to reuse this" |
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 1: Identify the pattern
|
||||
|
||||
Read the user's description. Search auto-memory for related entries:
|
||||
|
||||
```bash
|
||||
MEMORY_DIR="$HOME/.claude/projects/$(pwd | sed 's|/|%2F|g; s|%2F|/|; s|^/||')/memory"
|
||||
grep -rni "<keywords>" "$MEMORY_DIR/"
|
||||
```
|
||||
|
||||
If found in auto-memory, use those entries as source material. If not, use the user's description directly.
|
||||
|
||||
### Step 2: Determine skill scope
|
||||
|
||||
Ask (max 2 questions):
|
||||
- "What problem does this solve?" (if not clear)
|
||||
- "Should this include code examples?" (if applicable)
|
||||
|
||||
### Step 3: Generate skill name
|
||||
|
||||
Rules for naming:
|
||||
- Lowercase, hyphens between words
|
||||
- Descriptive but concise (2-4 words)
|
||||
- Examples: `docker-m1-fixes`, `api-timeout-patterns`, `pnpm-workspace-setup`
|
||||
|
||||
### Step 4: Create the skill files
|
||||
|
||||
**Spawn the `skill-extractor` agent** for the actual file generation.
|
||||
|
||||
The agent creates:
|
||||
|
||||
```
|
||||
<skill-name>/
|
||||
├── SKILL.md # Main skill file with frontmatter
|
||||
├── README.md # Human-readable overview
|
||||
└── reference/ # (optional) Supporting documentation
|
||||
└── examples.md # Concrete examples and edge cases
|
||||
```
|
||||
|
||||
### Step 5: SKILL.md structure
|
||||
|
||||
The generated SKILL.md must follow this format:
|
||||
|
||||
```markdown
|
||||
---
|
||||
name: <skill-name>
|
||||
description: "<one-line description>. Use when: <trigger conditions>."
|
||||
---
|
||||
|
||||
# <Skill Title>
|
||||
|
||||
> One-line summary of what this skill solves.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Problem | Solution |
|
||||
|---------|----------|
|
||||
| {{problem 1}} | {{solution 1}} |
|
||||
| {{problem 2}} | {{solution 2}} |
|
||||
|
||||
## The Problem
|
||||
|
||||
{{2-3 sentences explaining what goes wrong and why it's non-obvious.}}
|
||||
|
||||
## Solutions
|
||||
|
||||
### Option 1: {{Name}} (Recommended)
|
||||
|
||||
{{Step-by-step with code examples.}}
|
||||
|
||||
### Option 2: {{Alternative}}
|
||||
|
||||
{{For when Option 1 doesn't apply.}}
|
||||
|
||||
## Trade-offs
|
||||
|
||||
| Approach | Pros | Cons |
|
||||
|----------|------|------|
|
||||
| Option 1 | {{pros}} | {{cons}} |
|
||||
| Option 2 | {{pros}} | {{cons}} |
|
||||
|
||||
## Edge Cases
|
||||
|
||||
- {{edge case 1 and how to handle it}}
|
||||
- {{edge case 2 and how to handle it}}
|
||||
```
|
||||
|
||||
### Step 6: Quality gates
|
||||
|
||||
Before finalizing, verify:
|
||||
|
||||
- [ ] SKILL.md has valid YAML frontmatter with `name` and `description`
|
||||
- [ ] `name` matches the folder name (lowercase, hyphens)
|
||||
- [ ] Description includes "Use when:" trigger conditions
|
||||
- [ ] Solutions are self-contained (no external context needed)
|
||||
- [ ] Code examples are complete and copy-pasteable
|
||||
- [ ] No project-specific hardcoded values (paths, URLs, credentials)
|
||||
- [ ] No unnecessary dependencies
|
||||
|
||||
### Step 7: Report
|
||||
|
||||
```
|
||||
✅ Skill extracted: {{skill-name}}
|
||||
|
||||
Files created:
|
||||
{{path}}/SKILL.md ({{lines}} lines)
|
||||
{{path}}/README.md ({{lines}} lines)
|
||||
{{path}}/reference/examples.md ({{lines}} lines)
|
||||
|
||||
Install: /plugin install (copy to your skills directory)
|
||||
Publish: clawhub publish {{path}}
|
||||
|
||||
Source: MEMORY.md entries at lines {{n, m, ...}} (retained — the skill is portable, the memory is project-specific)
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Extracting a debugging pattern
|
||||
|
||||
```
|
||||
/si:extract "Fix for Docker builds failing on Apple Silicon with platform mismatch"
|
||||
```
|
||||
|
||||
Creates `docker-m1-fixes/SKILL.md` with:
|
||||
- The platform mismatch error message
|
||||
- Three solutions (build flag, Dockerfile, docker-compose)
|
||||
- Trade-offs table
|
||||
- Performance note about Rosetta 2 emulation
|
||||
|
||||
### Extracting a workflow pattern
|
||||
|
||||
```
|
||||
/si:extract "Always regenerate TypeScript API client after modifying OpenAPI spec"
|
||||
```
|
||||
|
||||
Creates `api-client-regen/SKILL.md` with:
|
||||
- Why manual regen is needed
|
||||
- The exact command sequence
|
||||
- CI integration snippet
|
||||
- Common failure modes
|
||||
|
||||
## Tips
|
||||
|
||||
- Extract patterns that would save time in a *different* project
|
||||
- Keep skills focused — one problem per skill
|
||||
- Include the error messages people would search for
|
||||
- Test the skill by reading it without the original context — does it make sense?
|
||||
151
docs/skills/engineering-team/self-improving-agent-promote.md
Normal file
151
docs/skills/engineering-team/self-improving-agent-promote.md
Normal file
@@ -0,0 +1,151 @@
|
||||
---
|
||||
title: "/si:promote — Graduate Learnings to Rules"
|
||||
description: "/si:promote — Graduate Learnings to Rules - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# /si:promote — Graduate Learnings to Rules
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `promote` | **Source:** [`engineering-team/self-improving-agent/skills/promote/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/self-improving-agent/skills/promote/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# /si:promote — Graduate Learnings to Rules
|
||||
|
||||
Moves a proven pattern from Claude's auto-memory into the project's rule system, where it becomes an enforced instruction rather than a background note.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/si:promote <pattern description> # Auto-detect best target
|
||||
/si:promote <pattern> --target claude.md # Promote to CLAUDE.md
|
||||
/si:promote <pattern> --target rules/testing.md # Promote to scoped rule
|
||||
/si:promote <pattern> --target rules/api.md --paths "src/api/**/*.ts" # Scoped with paths
|
||||
```
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 1: Understand the pattern
|
||||
|
||||
Parse the user's description. If vague, ask one clarifying question:
|
||||
- "What specific behavior should Claude follow?"
|
||||
- "Does this apply to all files or specific paths?"
|
||||
|
||||
### Step 2: Find the pattern in auto-memory
|
||||
|
||||
```bash
|
||||
# Search MEMORY.md for related entries
|
||||
MEMORY_DIR="$HOME/.claude/projects/$(pwd | sed 's|/|%2F|g; s|%2F|/|; s|^/||')/memory"
|
||||
grep -ni "<keywords>" "$MEMORY_DIR/MEMORY.md"
|
||||
```
|
||||
|
||||
Show the matching entries and confirm they're what the user means.
|
||||
|
||||
### Step 3: Determine the right target
|
||||
|
||||
| Pattern scope | Target | Example |
|
||||
|---|---|---|
|
||||
| Applies to entire project | `./CLAUDE.md` | "Use pnpm, not npm" |
|
||||
| Applies to specific file types | `.claude/rules/<topic>.md` | "API handlers need validation" |
|
||||
| Applies to all your projects | `~/.claude/CLAUDE.md` | "Prefer explicit error handling" |
|
||||
|
||||
If the user didn't specify a target, recommend one based on scope.
|
||||
|
||||
### Step 4: Distill into a concise rule
|
||||
|
||||
Transform the learning from auto-memory's note format into CLAUDE.md's instruction format:
|
||||
|
||||
**Before** (MEMORY.md — descriptive):
|
||||
> The project uses pnpm workspaces. When I tried npm install it failed. The lock file is pnpm-lock.yaml. Must use pnpm install for dependencies.
|
||||
|
||||
**After** (CLAUDE.md — prescriptive):
|
||||
```markdown
|
||||
## Build & Dependencies
|
||||
- Package manager: pnpm (not npm). Use `pnpm install`.
|
||||
```
|
||||
|
||||
**Rules for distillation:**
|
||||
- One line per rule when possible
|
||||
- Imperative voice ("Use X", "Always Y", "Never Z")
|
||||
- Include the command or example, not just the concept
|
||||
- No backstory — just the instruction
|
||||
|
||||
### Step 5: Write to target
|
||||
|
||||
**For CLAUDE.md:**
|
||||
1. Read existing CLAUDE.md
|
||||
2. Find the appropriate section (or create one)
|
||||
3. Append the new rule under the right heading
|
||||
4. If file would exceed 200 lines, suggest using `.claude/rules/` instead
|
||||
|
||||
**For `.claude/rules/`:**
|
||||
1. Create the file if it doesn't exist
|
||||
2. Add YAML frontmatter with `paths` if scoped
|
||||
3. Write the rule content
|
||||
|
||||
```markdown
|
||||
---
|
||||
paths:
|
||||
- "src/api/**/*.ts"
|
||||
- "tests/api/**/*"
|
||||
---
|
||||
|
||||
# API Development Rules
|
||||
|
||||
- All endpoints must validate input with Zod schemas
|
||||
- Use `ApiError` class for error responses (not raw Error)
|
||||
- Include OpenAPI JSDoc comments on handler functions
|
||||
```
|
||||
|
||||
### Step 6: Clean up auto-memory
|
||||
|
||||
After promoting, remove or mark the original entry in MEMORY.md:
|
||||
|
||||
```bash
|
||||
# Show what will be removed
|
||||
grep -n "<pattern>" "$MEMORY_DIR/MEMORY.md"
|
||||
```
|
||||
|
||||
Ask the user to confirm removal. Then edit MEMORY.md to remove the promoted entry. This frees space for new learnings.
|
||||
|
||||
### Step 7: Confirm
|
||||
|
||||
```
|
||||
✅ Promoted to {{target}}
|
||||
|
||||
Rule: "{{distilled rule}}"
|
||||
Source: MEMORY.md line {{n}} (removed)
|
||||
MEMORY.md: {{lines}}/200 lines remaining
|
||||
|
||||
The pattern is now an enforced instruction. Claude will follow it in all future sessions.
|
||||
```
|
||||
|
||||
## Promotion Decision Guide
|
||||
|
||||
### Promote when:
|
||||
- Pattern appeared 3+ times in auto-memory
|
||||
- You corrected Claude about it more than once
|
||||
- It's a project convention that any contributor should know
|
||||
- It prevents a recurring mistake
|
||||
|
||||
### Don't promote when:
|
||||
- It's a one-time debugging note (leave in auto-memory)
|
||||
- It's session-specific context (session memory handles this)
|
||||
- It might change soon (e.g., during a migration)
|
||||
- It's already covered by existing rules
|
||||
|
||||
### CLAUDE.md vs .claude/rules/
|
||||
|
||||
| Use CLAUDE.md for | Use .claude/rules/ for |
|
||||
|---|---|
|
||||
| Global project rules | File-type-specific patterns |
|
||||
| Build commands | Testing conventions |
|
||||
| Architecture decisions | API design rules |
|
||||
| Team conventions | Framework-specific gotchas |
|
||||
|
||||
## Tips
|
||||
|
||||
- Keep CLAUDE.md under 200 lines — use rules/ for overflow
|
||||
- One rule per line is easier to maintain than paragraphs
|
||||
- Include the concrete command, not just the concept
|
||||
- Review promoted rules quarterly — remove what's no longer relevant
|
||||
105
docs/skills/engineering-team/self-improving-agent-remember.md
Normal file
105
docs/skills/engineering-team/self-improving-agent-remember.md
Normal file
@@ -0,0 +1,105 @@
|
||||
---
|
||||
title: "/si:remember — Save Knowledge Explicitly"
|
||||
description: "/si:remember — Save Knowledge Explicitly - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# /si:remember — Save Knowledge Explicitly
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `remember` | **Source:** [`engineering-team/self-improving-agent/skills/remember/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/self-improving-agent/skills/remember/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# /si:remember — Save Knowledge Explicitly
|
||||
|
||||
Writes an explicit entry to auto-memory when something is important enough that you don't want to rely on Claude noticing it automatically.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/si:remember <what to remember>
|
||||
/si:remember "This project's CI requires Node 20 LTS — v22 breaks the build"
|
||||
/si:remember "The /api/auth endpoint uses a custom JWT library, not passport"
|
||||
/si:remember "Reza prefers explicit error handling over try-catch-all patterns"
|
||||
```
|
||||
|
||||
## When to Use
|
||||
|
||||
| Situation | Example |
|
||||
|-----------|---------|
|
||||
| Hard-won debugging insight | "CORS errors on /api/upload are caused by the CDN, not the backend" |
|
||||
| Project convention not in CLAUDE.md | "We use barrel exports in src/components/" |
|
||||
| Tool-specific gotcha | "Jest needs `--forceExit` flag or it hangs on DB tests" |
|
||||
| Architecture decision | "We chose Drizzle over Prisma for type-safe SQL" |
|
||||
| Preference you want Claude to learn | "Don't add comments explaining obvious code" |
|
||||
|
||||
## Workflow
|
||||
|
||||
### Step 1: Parse the knowledge
|
||||
|
||||
Extract from the user's input:
|
||||
- **What**: The concrete fact or pattern
|
||||
- **Why it matters**: Context (if provided)
|
||||
- **Scope**: Project-specific or global?
|
||||
|
||||
### Step 2: Check for duplicates
|
||||
|
||||
```bash
|
||||
MEMORY_DIR="$HOME/.claude/projects/$(pwd | sed 's|/|%2F|g; s|%2F|/|; s|^/||')/memory"
|
||||
grep -ni "<keywords>" "$MEMORY_DIR/MEMORY.md" 2>/dev/null
|
||||
```
|
||||
|
||||
If a similar entry exists:
|
||||
- Show it to the user
|
||||
- Ask: "Update the existing entry or add a new one?"
|
||||
|
||||
### Step 3: Write to MEMORY.md
|
||||
|
||||
Append to the end of `MEMORY.md`:
|
||||
|
||||
```markdown
|
||||
- {{concise fact or pattern}}
|
||||
```
|
||||
|
||||
Keep entries concise — one line when possible. Auto-memory entries don't need timestamps, IDs, or metadata. They're notes, not database records.
|
||||
|
||||
If MEMORY.md is over 180 lines, warn the user:
|
||||
|
||||
```
|
||||
⚠️ MEMORY.md is at {{n}}/200 lines. Consider running /si:review to free space.
|
||||
```
|
||||
|
||||
### Step 4: Suggest promotion
|
||||
|
||||
If the knowledge sounds like a rule (imperative, always/never, convention):
|
||||
|
||||
```
|
||||
💡 This sounds like it could be a CLAUDE.md rule rather than a memory entry.
|
||||
Rules are enforced with higher priority. Want to /si:promote it instead?
|
||||
```
|
||||
|
||||
### Step 5: Confirm
|
||||
|
||||
```
|
||||
✅ Saved to auto-memory
|
||||
|
||||
"{{entry}}"
|
||||
|
||||
MEMORY.md: {{n}}/200 lines
|
||||
Claude will see this at the start of every session in this project.
|
||||
```
|
||||
|
||||
## What NOT to use /si:remember for
|
||||
|
||||
- **Temporary context**: Use session memory or just tell Claude in conversation
|
||||
- **Enforced rules**: Use `/si:promote` to write directly to CLAUDE.md
|
||||
- **Cross-project knowledge**: Use `~/.claude/CLAUDE.md` for global rules
|
||||
- **Sensitive data**: Never store credentials, tokens, or secrets in memory files
|
||||
|
||||
## Tips
|
||||
|
||||
- Be concise — one line beats a paragraph
|
||||
- Include the concrete command or value, not just the concept
|
||||
- ✅ "Build with `pnpm build`, tests with `pnpm test:e2e`"
|
||||
- ❌ "The project uses pnpm for building and testing"
|
||||
- If you're remembering the same thing twice, promote it to CLAUDE.md
|
||||
133
docs/skills/engineering-team/self-improving-agent-review.md
Normal file
133
docs/skills/engineering-team/self-improving-agent-review.md
Normal file
@@ -0,0 +1,133 @@
|
||||
---
|
||||
title: "/si:review — Analyze Auto-Memory"
|
||||
description: "/si:review — Analyze Auto-Memory - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# /si:review — Analyze Auto-Memory
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `review` | **Source:** [`engineering-team/self-improving-agent/skills/review/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/self-improving-agent/skills/review/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# /si:review — Analyze Auto-Memory
|
||||
|
||||
Performs a comprehensive audit of Claude Code's auto-memory and produces actionable recommendations.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/si:review # Full review
|
||||
/si:review --quick # Summary only (counts + top 3 candidates)
|
||||
/si:review --stale # Focus on stale/outdated entries
|
||||
/si:review --candidates # Show only promotion candidates
|
||||
```
|
||||
|
||||
## What It Does
|
||||
|
||||
### Step 1: Locate memory directory
|
||||
|
||||
```bash
|
||||
# Find the project's auto-memory directory
|
||||
MEMORY_DIR="$HOME/.claude/projects/$(pwd | sed 's|/|%2F|g; s|%2F|/|; s|^/||')/memory"
|
||||
|
||||
# Fallback: check common path patterns
|
||||
# ~/.claude/projects/<user>/<project>/memory/
|
||||
# ~/.claude/projects/<absolute-path>/memory/
|
||||
|
||||
# List all memory files
|
||||
ls -la "$MEMORY_DIR"/
|
||||
```
|
||||
|
||||
If memory directory doesn't exist, report that auto-memory may be disabled. Suggest checking with `/memory`.
|
||||
|
||||
### Step 2: Read and analyze MEMORY.md
|
||||
|
||||
Read the full `MEMORY.md` file. Count lines and check against the 200-line startup limit.
|
||||
|
||||
Analyze each entry for:
|
||||
|
||||
1. **Recurrence indicators**
|
||||
- Same concept appears multiple times (different wording)
|
||||
- References to "again" or "still" or "keeps happening"
|
||||
- Similar entries across topic files
|
||||
|
||||
2. **Staleness indicators**
|
||||
- References files that no longer exist (`find` to verify)
|
||||
- Mentions outdated tools, versions, or commands
|
||||
- Contradicts current CLAUDE.md rules
|
||||
|
||||
3. **Consolidation opportunities**
|
||||
- Multiple entries about the same topic (e.g., three lines about testing)
|
||||
- Entries that could merge into one concise rule
|
||||
|
||||
4. **Promotion candidates** — entries that meet ALL criteria:
|
||||
- Appeared in 2+ sessions (check wording patterns)
|
||||
- Not project-specific trivia (broadly useful)
|
||||
- Actionable (can be written as a concrete rule)
|
||||
- Not already in CLAUDE.md or `.claude/rules/`
|
||||
|
||||
### Step 3: Read topic files
|
||||
|
||||
If `MEMORY.md` references or the directory contains additional files (`debugging.md`, `patterns.md`, etc.):
|
||||
- Read each one
|
||||
- Cross-reference with MEMORY.md for duplicates
|
||||
- Check for entries that belong in the main file (high value) vs. topic files (details)
|
||||
|
||||
### Step 4: Cross-reference with CLAUDE.md
|
||||
|
||||
Read the project's `CLAUDE.md` (if it exists) and compare:
|
||||
- Are there MEMORY.md entries that duplicate CLAUDE.md rules? (→ remove from memory)
|
||||
- Are there MEMORY.md entries that contradict CLAUDE.md? (→ flag conflict)
|
||||
- Are there MEMORY.md patterns not yet in CLAUDE.md that should be? (→ promotion candidate)
|
||||
|
||||
Also check `.claude/rules/` directory for existing scoped rules.
|
||||
|
||||
### Step 5: Generate report
|
||||
|
||||
Output format:
|
||||
|
||||
```
|
||||
📊 Auto-Memory Review
|
||||
|
||||
Memory Health:
|
||||
MEMORY.md: {{lines}}/200 lines ({{percent}}%)
|
||||
Topic files: {{count}} ({{names}})
|
||||
CLAUDE.md: {{lines}} lines
|
||||
Rules: {{count}} files in .claude/rules/
|
||||
|
||||
🎯 Promotion Candidates ({{count}}):
|
||||
1. "{{pattern}}" — seen {{n}}x, applies broadly
|
||||
→ Suggest: {{target}} (CLAUDE.md / .claude/rules/{{name}}.md)
|
||||
2. ...
|
||||
|
||||
🗑️ Stale Entries ({{count}}):
|
||||
1. Line {{n}}: "{{entry}}" — {{reason}}
|
||||
2. ...
|
||||
|
||||
🔄 Consolidation ({{count}} groups):
|
||||
1. Lines {{a}}, {{b}}, {{c}} all about {{topic}} → merge into 1 entry
|
||||
2. ...
|
||||
|
||||
⚠️ Conflicts ({{count}}):
|
||||
1. MEMORY.md line {{n}} contradicts CLAUDE.md: {{detail}}
|
||||
|
||||
💡 Recommendations:
|
||||
- {{actionable suggestion}}
|
||||
- {{actionable suggestion}}
|
||||
```
|
||||
|
||||
## When to Use
|
||||
|
||||
- After completing a major feature or debugging session
|
||||
- When `/si:status` shows MEMORY.md is over 150 lines
|
||||
- Weekly during active development
|
||||
- Before starting a new project phase
|
||||
- After onboarding a new team member (review what Claude learned)
|
||||
|
||||
## Tips
|
||||
|
||||
- Run `/si:review --quick` frequently (low overhead)
|
||||
- Full review is most valuable when MEMORY.md is getting crowded
|
||||
- Act on promotion candidates promptly — they're proven patterns
|
||||
- Don't hesitate to delete stale entries — auto-memory will re-learn if needed
|
||||
110
docs/skills/engineering-team/self-improving-agent-status.md
Normal file
110
docs/skills/engineering-team/self-improving-agent-status.md
Normal file
@@ -0,0 +1,110 @@
|
||||
---
|
||||
title: "/si:status — Memory Health Dashboard"
|
||||
description: "/si:status — Memory Health Dashboard - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# /si:status — Memory Health Dashboard
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `status` | **Source:** [`engineering-team/self-improving-agent/skills/status/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/self-improving-agent/skills/status/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# /si:status — Memory Health Dashboard
|
||||
|
||||
Quick overview of your project's memory state across all memory systems.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/si:status # Full dashboard
|
||||
/si:status --brief # One-line summary
|
||||
```
|
||||
|
||||
## What It Reports
|
||||
|
||||
### Step 1: Locate all memory files
|
||||
|
||||
```bash
|
||||
# Auto-memory directory
|
||||
MEMORY_DIR="$HOME/.claude/projects/$(pwd | sed 's|/|%2F|g; s|%2F|/|; s|^/||')/memory"
|
||||
|
||||
# Count lines in MEMORY.md
|
||||
wc -l "$MEMORY_DIR/MEMORY.md" 2>/dev/null || echo "0"
|
||||
|
||||
# List topic files
|
||||
ls "$MEMORY_DIR/"*.md 2>/dev/null | grep -v MEMORY.md
|
||||
|
||||
# CLAUDE.md
|
||||
wc -l ./CLAUDE.md 2>/dev/null || echo "0"
|
||||
wc -l ~/.claude/CLAUDE.md 2>/dev/null || echo "0"
|
||||
|
||||
# Rules directory
|
||||
ls .claude/rules/*.md 2>/dev/null | wc -l
|
||||
```
|
||||
|
||||
### Step 2: Analyze capacity
|
||||
|
||||
| Metric | Healthy | Warning | Critical |
|
||||
|--------|---------|---------|----------|
|
||||
| MEMORY.md lines | < 120 | 120-180 | > 180 |
|
||||
| CLAUDE.md lines | < 150 | 150-200 | > 200 |
|
||||
| Topic files | 0-3 | 4-6 | > 6 |
|
||||
| Stale entries | 0 | 1-3 | > 3 |
|
||||
|
||||
### Step 3: Quick stale check
|
||||
|
||||
For each MEMORY.md entry that references a file path:
|
||||
```bash
|
||||
# Verify referenced files still exist
|
||||
grep -oE '[a-zA-Z0-9_/.-]+\.(ts|js|py|md|json|yaml|yml)' "$MEMORY_DIR/MEMORY.md" | while read f; do
|
||||
[ ! -f "$f" ] && echo "STALE: $f"
|
||||
done
|
||||
```
|
||||
|
||||
### Step 4: Output
|
||||
|
||||
```
|
||||
📊 Memory Status
|
||||
|
||||
Auto-Memory (MEMORY.md):
|
||||
Lines: {{n}}/200 ({{bar}}) {{emoji}}
|
||||
Topic files: {{count}} ({{names}})
|
||||
Last updated: {{date}}
|
||||
|
||||
Project Rules:
|
||||
CLAUDE.md: {{n}} lines
|
||||
Rules: {{count}} files in .claude/rules/
|
||||
User global: {{n}} lines (~/.claude/CLAUDE.md)
|
||||
|
||||
Health:
|
||||
Capacity: {{healthy/warning/critical}}
|
||||
Stale refs: {{count}} (files no longer exist)
|
||||
Duplicates: {{count}} (entries repeated across files)
|
||||
|
||||
{{if recommendations}}
|
||||
💡 Recommendations:
|
||||
- {{recommendation}}
|
||||
{{endif}}
|
||||
```
|
||||
|
||||
### Brief mode
|
||||
|
||||
```
|
||||
/si:status --brief
|
||||
```
|
||||
|
||||
Output: `📊 Memory: {{n}}/200 lines | {{count}} rules | {{status_emoji}} {{status_word}}`
|
||||
|
||||
## Interpretation
|
||||
|
||||
- **Green (< 60%)**: Plenty of room. Auto-memory is working well.
|
||||
- **Yellow (60-90%)**: Getting full. Consider running `/si:review` to promote or clean up.
|
||||
- **Red (> 90%)**: Near capacity. Auto-memory may start dropping older entries. Run `/si:review` now.
|
||||
|
||||
## Tips
|
||||
|
||||
- Run `/si:status --brief` as a quick check anytime
|
||||
- If capacity is yellow+, run `/si:review` to identify promotion candidates
|
||||
- Stale entries waste space — delete references to files that no longer exist
|
||||
- Topic files are fine — Claude creates them to keep MEMORY.md under 200 lines
|
||||
169
docs/skills/engineering-team/self-improving-agent.md
Normal file
169
docs/skills/engineering-team/self-improving-agent.md
Normal file
@@ -0,0 +1,169 @@
|
||||
---
|
||||
title: "Self-Improving Agent"
|
||||
description: "Self-Improving Agent - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Self-Improving Agent
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `self-improving-agent` | **Source:** [`engineering-team/self-improving-agent/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/self-improving-agent/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Self-Improving Agent
|
||||
|
||||
> Auto-memory captures. This plugin curates.
|
||||
|
||||
Claude Code's auto-memory (v2.1.32+) automatically records project patterns, debugging insights, and your preferences in `MEMORY.md`. This plugin adds the intelligence layer: it analyzes what Claude has learned, promotes proven patterns into project rules, and extracts recurring solutions into reusable skills.
|
||||
|
||||
## Quick Reference
|
||||
|
||||
| Command | What it does |
|
||||
|---------|-------------|
|
||||
| `/si:review` | Analyze MEMORY.md — find promotion candidates, stale entries, consolidation opportunities |
|
||||
| `/si:promote` | Graduate a pattern from MEMORY.md → CLAUDE.md or `.claude/rules/` |
|
||||
| `/si:extract` | Turn a proven pattern into a standalone skill |
|
||||
| `/si:status` | Memory health dashboard — line counts, topic files, recommendations |
|
||||
| `/si:remember` | Explicitly save important knowledge to auto-memory |
|
||||
|
||||
## How It Fits Together
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────┐
|
||||
│ Claude Code Memory Stack │
|
||||
├─────────────┬──────────────────┬────────────────────────┤
|
||||
│ CLAUDE.md │ Auto Memory │ Session Memory │
|
||||
│ (you write)│ (Claude writes)│ (Claude writes) │
|
||||
│ Rules & │ MEMORY.md │ Conversation logs │
|
||||
│ standards │ + topic files │ + continuity │
|
||||
│ Full load │ First 200 lines│ Contextual load │
|
||||
├─────────────┴──────────────────┴────────────────────────┤
|
||||
│ ↑ /si:promote ↑ /si:review │
|
||||
│ Self-Improving Agent (this plugin) │
|
||||
│ ↓ /si:extract ↓ /si:remember │
|
||||
├─────────────────────────────────────────────────────────┤
|
||||
│ .claude/rules/ │ New Skills │ Error Logs │
|
||||
│ (scoped rules) │ (extracted) │ (auto-captured)│
|
||||
└─────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
### Claude Code (Plugin)
|
||||
```
|
||||
/plugin marketplace add alirezarezvani/claude-skills
|
||||
/plugin install self-improving-agent@claude-code-skills
|
||||
```
|
||||
|
||||
### OpenClaw
|
||||
```bash
|
||||
clawhub install self-improving-agent
|
||||
```
|
||||
|
||||
### Codex CLI
|
||||
```bash
|
||||
./scripts/codex-install.sh --skill self-improving-agent
|
||||
```
|
||||
|
||||
## Memory Architecture
|
||||
|
||||
### Where things live
|
||||
|
||||
| File | Who writes | Scope | Loaded |
|
||||
|------|-----------|-------|--------|
|
||||
| `./CLAUDE.md` | You (+ `/si:promote`) | Project rules | Full file, every session |
|
||||
| `~/.claude/CLAUDE.md` | You | Global preferences | Full file, every session |
|
||||
| `~/.claude/projects/<path>/memory/MEMORY.md` | Claude (auto) | Project learnings | First 200 lines |
|
||||
| `~/.claude/projects/<path>/memory/*.md` | Claude (overflow) | Topic-specific notes | On demand |
|
||||
| `.claude/rules/*.md` | You (+ `/si:promote`) | Scoped rules | When matching files open |
|
||||
|
||||
### The promotion lifecycle
|
||||
|
||||
```
|
||||
1. Claude discovers pattern → auto-memory (MEMORY.md)
|
||||
2. Pattern recurs 2-3x → /si:review flags it as promotion candidate
|
||||
3. You approve → /si:promote graduates it to CLAUDE.md or rules/
|
||||
4. Pattern becomes an enforced rule, not just a note
|
||||
5. MEMORY.md entry removed → frees space for new learnings
|
||||
```
|
||||
|
||||
## Core Concepts
|
||||
|
||||
### Auto-memory is capture, not curation
|
||||
|
||||
Auto-memory is excellent at recording what Claude learns. But it has no judgment about:
|
||||
- Which learnings are temporary vs. permanent
|
||||
- Which patterns should become enforced rules
|
||||
- When the 200-line limit is wasting space on stale entries
|
||||
- Which solutions are good enough to become reusable skills
|
||||
|
||||
That's what this plugin does.
|
||||
|
||||
### Promotion = graduation
|
||||
|
||||
When you promote a learning, it moves from Claude's scratchpad (MEMORY.md) to your project's rule system (CLAUDE.md or `.claude/rules/`). The difference matters:
|
||||
|
||||
- **MEMORY.md**: "I noticed this project uses pnpm" (background context)
|
||||
- **CLAUDE.md**: "Use pnpm, not npm" (enforced instruction)
|
||||
|
||||
Promoted rules have higher priority and load in full (not truncated at 200 lines).
|
||||
|
||||
### Rules directory for scoped knowledge
|
||||
|
||||
Not everything belongs in CLAUDE.md. Use `.claude/rules/` for patterns that only apply to specific file types:
|
||||
|
||||
```yaml
|
||||
# .claude/rules/api-testing.md
|
||||
---
|
||||
paths:
|
||||
- "src/api/**/*.test.ts"
|
||||
- "tests/api/**/*"
|
||||
---
|
||||
- Use supertest for API endpoint testing
|
||||
- Mock external services with msw
|
||||
- Always test error responses, not just happy paths
|
||||
```
|
||||
|
||||
This loads only when Claude works with API test files — zero overhead otherwise.
|
||||
|
||||
## Agents
|
||||
|
||||
### memory-analyst
|
||||
Analyzes MEMORY.md and topic files to identify:
|
||||
- Entries that recur across sessions (promotion candidates)
|
||||
- Stale entries referencing deleted files or old patterns
|
||||
- Related entries that should be consolidated
|
||||
- Gaps between what MEMORY.md knows and what CLAUDE.md enforces
|
||||
|
||||
### skill-extractor
|
||||
Takes a proven pattern and generates a complete skill:
|
||||
- SKILL.md with proper frontmatter
|
||||
- Reference documentation
|
||||
- Examples and edge cases
|
||||
- Ready for `/plugin install` or `clawhub publish`
|
||||
|
||||
## Hooks
|
||||
|
||||
### error-capture (PostToolUse → Bash)
|
||||
Monitors command output for errors. When detected, appends a structured entry to auto-memory with:
|
||||
- The command that failed
|
||||
- Error output (truncated)
|
||||
- Timestamp and context
|
||||
- Suggested category
|
||||
|
||||
**Token overhead:** Zero on success. ~30 tokens only when an error is detected.
|
||||
|
||||
## Platform Support
|
||||
|
||||
| Platform | Memory System | Plugin Works? |
|
||||
|----------|--------------|---------------|
|
||||
| Claude Code | Auto-memory (MEMORY.md) | ✅ Full support |
|
||||
| OpenClaw | workspace/MEMORY.md | ✅ Adapted (reads workspace memory) |
|
||||
| Codex CLI | AGENTS.md | ✅ Adapted (reads AGENTS.md patterns) |
|
||||
| GitHub Copilot | `.github/copilot-instructions.md` | ⚠️ Manual promotion only |
|
||||
|
||||
## Related
|
||||
|
||||
- [Claude Code Memory Docs](https://code.claude.com/docs/en/memory)
|
||||
- [pskoett/self-improving-agent](https://clawhub.ai/pskoett/self-improving-agent) — inspiration
|
||||
- [playwright-pro](../playwright-pro/) — sister plugin in this repo
|
||||
350
docs/skills/engineering-team/senior-architect.md
Normal file
350
docs/skills/engineering-team/senior-architect.md
Normal file
@@ -0,0 +1,350 @@
|
||||
---
|
||||
title: "Senior Architect"
|
||||
description: "Senior Architect - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior Architect
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-architect` | **Source:** [`engineering-team/senior-architect/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-architect/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior Architect
|
||||
|
||||
Architecture design and analysis tools for making informed technical decisions.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Quick Start](#quick-start)
|
||||
- [Tools Overview](#tools-overview)
|
||||
- [Architecture Diagram Generator](#1-architecture-diagram-generator)
|
||||
- [Dependency Analyzer](#2-dependency-analyzer)
|
||||
- [Project Architect](#3-project-architect)
|
||||
- [Decision Workflows](#decision-workflows)
|
||||
- [Database Selection](#database-selection-workflow)
|
||||
- [Architecture Pattern Selection](#architecture-pattern-selection-workflow)
|
||||
- [Monolith vs Microservices](#monolith-vs-microservices-decision)
|
||||
- [Reference Documentation](#reference-documentation)
|
||||
- [Tech Stack Coverage](#tech-stack-coverage)
|
||||
- [Common Commands](#common-commands)
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Generate architecture diagram from project
|
||||
python scripts/architecture_diagram_generator.py ./my-project --format mermaid
|
||||
|
||||
# Analyze dependencies for issues
|
||||
python scripts/dependency_analyzer.py ./my-project --output json
|
||||
|
||||
# Get architecture assessment
|
||||
python scripts/project_architect.py ./my-project --verbose
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tools Overview
|
||||
|
||||
### 1. Architecture Diagram Generator
|
||||
|
||||
Generates architecture diagrams from project structure in multiple formats.
|
||||
|
||||
**Solves:** "I need to visualize my system architecture for documentation or team discussion"
|
||||
|
||||
**Input:** Project directory path
|
||||
**Output:** Diagram code (Mermaid, PlantUML, or ASCII)
|
||||
|
||||
**Supported diagram types:**
|
||||
- `component` - Shows modules and their relationships
|
||||
- `layer` - Shows architectural layers (presentation, business, data)
|
||||
- `deployment` - Shows deployment topology
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Mermaid format (default)
|
||||
python scripts/architecture_diagram_generator.py ./project --format mermaid --type component
|
||||
|
||||
# PlantUML format
|
||||
python scripts/architecture_diagram_generator.py ./project --format plantuml --type layer
|
||||
|
||||
# ASCII format (terminal-friendly)
|
||||
python scripts/architecture_diagram_generator.py ./project --format ascii
|
||||
|
||||
# Save to file
|
||||
python scripts/architecture_diagram_generator.py ./project -o architecture.md
|
||||
```
|
||||
|
||||
**Example output (Mermaid):**
|
||||
```mermaid
|
||||
graph TD
|
||||
A[API Gateway] --> B[Auth Service]
|
||||
A --> C[User Service]
|
||||
B --> D[(PostgreSQL)]
|
||||
C --> D
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 2. Dependency Analyzer
|
||||
|
||||
Analyzes project dependencies for coupling, circular dependencies, and outdated packages.
|
||||
|
||||
**Solves:** "I need to understand my dependency tree and identify potential issues"
|
||||
|
||||
**Input:** Project directory path
|
||||
**Output:** Analysis report (JSON or human-readable)
|
||||
|
||||
**Analyzes:**
|
||||
- Dependency tree (direct and transitive)
|
||||
- Circular dependencies between modules
|
||||
- Coupling score (0-100)
|
||||
- Outdated packages
|
||||
|
||||
**Supported package managers:**
|
||||
- npm/yarn (`package.json`)
|
||||
- Python (`requirements.txt`, `pyproject.toml`)
|
||||
- Go (`go.mod`)
|
||||
- Rust (`Cargo.toml`)
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Human-readable report
|
||||
python scripts/dependency_analyzer.py ./project
|
||||
|
||||
# JSON output for CI/CD integration
|
||||
python scripts/dependency_analyzer.py ./project --output json
|
||||
|
||||
# Check only for circular dependencies
|
||||
python scripts/dependency_analyzer.py ./project --check circular
|
||||
|
||||
# Verbose mode with recommendations
|
||||
python scripts/dependency_analyzer.py ./project --verbose
|
||||
```
|
||||
|
||||
**Example output:**
|
||||
```
|
||||
Dependency Analysis Report
|
||||
==========================
|
||||
Total dependencies: 47 (32 direct, 15 transitive)
|
||||
Coupling score: 72/100 (moderate)
|
||||
|
||||
Issues found:
|
||||
- CIRCULAR: auth → user → permissions → auth
|
||||
- OUTDATED: lodash 4.17.15 → 4.17.21 (security)
|
||||
|
||||
Recommendations:
|
||||
1. Extract shared interface to break circular dependency
|
||||
2. Update lodash to fix CVE-2020-8203
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 3. Project Architect
|
||||
|
||||
Analyzes project structure and detects architectural patterns, code smells, and improvement opportunities.
|
||||
|
||||
**Solves:** "I want to understand the current architecture and identify areas for improvement"
|
||||
|
||||
**Input:** Project directory path
|
||||
**Output:** Architecture assessment report
|
||||
|
||||
**Detects:**
|
||||
- Architectural patterns (MVC, layered, hexagonal, microservices indicators)
|
||||
- Code organization issues (god classes, mixed concerns)
|
||||
- Layer violations
|
||||
- Missing architectural components
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Full assessment
|
||||
python scripts/project_architect.py ./project
|
||||
|
||||
# Verbose with detailed recommendations
|
||||
python scripts/project_architect.py ./project --verbose
|
||||
|
||||
# JSON output
|
||||
python scripts/project_architect.py ./project --output json
|
||||
|
||||
# Check specific aspect
|
||||
python scripts/project_architect.py ./project --check layers
|
||||
```
|
||||
|
||||
**Example output:**
|
||||
```
|
||||
Architecture Assessment
|
||||
=======================
|
||||
Detected pattern: Layered Architecture (confidence: 85%)
|
||||
|
||||
Structure analysis:
|
||||
✓ controllers/ - Presentation layer detected
|
||||
✓ services/ - Business logic layer detected
|
||||
✓ repositories/ - Data access layer detected
|
||||
⚠ models/ - Mixed domain and DTOs
|
||||
|
||||
Issues:
|
||||
- LARGE FILE: UserService.ts (1,847 lines) - consider splitting
|
||||
- MIXED CONCERNS: PaymentController contains business logic
|
||||
|
||||
Recommendations:
|
||||
1. Split UserService into focused services
|
||||
2. Move business logic from controllers to services
|
||||
3. Separate domain models from DTOs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Decision Workflows
|
||||
|
||||
### Database Selection Workflow
|
||||
|
||||
Use when choosing a database for a new project or migrating existing data.
|
||||
|
||||
**Step 1: Identify data characteristics**
|
||||
| Characteristic | Points to SQL | Points to NoSQL |
|
||||
|----------------|---------------|-----------------|
|
||||
| Structured with relationships | ✓ | |
|
||||
| ACID transactions required | ✓ | |
|
||||
| Flexible/evolving schema | | ✓ |
|
||||
| Document-oriented data | | ✓ |
|
||||
| Time-series data | | ✓ (specialized) |
|
||||
|
||||
**Step 2: Evaluate scale requirements**
|
||||
- <1M records, single region → PostgreSQL or MySQL
|
||||
- 1M-100M records, read-heavy → PostgreSQL with read replicas
|
||||
- >100M records, global distribution → CockroachDB, Spanner, or DynamoDB
|
||||
- High write throughput (>10K/sec) → Cassandra or ScyllaDB
|
||||
|
||||
**Step 3: Check consistency requirements**
|
||||
- Strong consistency required → SQL or CockroachDB
|
||||
- Eventual consistency acceptable → DynamoDB, Cassandra, MongoDB
|
||||
|
||||
**Step 4: Document decision**
|
||||
Create an ADR (Architecture Decision Record) with:
|
||||
- Context and requirements
|
||||
- Options considered
|
||||
- Decision and rationale
|
||||
- Trade-offs accepted
|
||||
|
||||
**Quick reference:**
|
||||
```
|
||||
PostgreSQL → Default choice for most applications
|
||||
MongoDB → Document store, flexible schema
|
||||
Redis → Caching, sessions, real-time features
|
||||
DynamoDB → Serverless, auto-scaling, AWS-native
|
||||
TimescaleDB → Time-series data with SQL interface
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Architecture Pattern Selection Workflow
|
||||
|
||||
Use when designing a new system or refactoring existing architecture.
|
||||
|
||||
**Step 1: Assess team and project size**
|
||||
| Team Size | Recommended Starting Point |
|
||||
|-----------|---------------------------|
|
||||
| 1-3 developers | Modular monolith |
|
||||
| 4-10 developers | Modular monolith or service-oriented |
|
||||
| 10+ developers | Consider microservices |
|
||||
|
||||
**Step 2: Evaluate deployment requirements**
|
||||
- Single deployment unit acceptable → Monolith
|
||||
- Independent scaling needed → Microservices
|
||||
- Mixed (some services scale differently) → Hybrid
|
||||
|
||||
**Step 3: Consider data boundaries**
|
||||
- Shared database acceptable → Monolith or modular monolith
|
||||
- Strict data isolation required → Microservices with separate DBs
|
||||
- Event-driven communication fits → Event-sourcing/CQRS
|
||||
|
||||
**Step 4: Match pattern to requirements**
|
||||
|
||||
| Requirement | Recommended Pattern |
|
||||
|-------------|-------------------|
|
||||
| Rapid MVP development | Modular Monolith |
|
||||
| Independent team deployment | Microservices |
|
||||
| Complex domain logic | Domain-Driven Design |
|
||||
| High read/write ratio difference | CQRS |
|
||||
| Audit trail required | Event Sourcing |
|
||||
| Third-party integrations | Hexagonal/Ports & Adapters |
|
||||
|
||||
See `references/architecture_patterns.md` for detailed pattern descriptions.
|
||||
|
||||
---
|
||||
|
||||
### Monolith vs Microservices Decision
|
||||
|
||||
**Choose Monolith when:**
|
||||
- [ ] Team is small (<10 developers)
|
||||
- [ ] Domain boundaries are unclear
|
||||
- [ ] Rapid iteration is priority
|
||||
- [ ] Operational complexity must be minimized
|
||||
- [ ] Shared database is acceptable
|
||||
|
||||
**Choose Microservices when:**
|
||||
- [ ] Teams can own services end-to-end
|
||||
- [ ] Independent deployment is critical
|
||||
- [ ] Different scaling requirements per component
|
||||
- [ ] Technology diversity is needed
|
||||
- [ ] Domain boundaries are well understood
|
||||
|
||||
**Hybrid approach:**
|
||||
Start with a modular monolith. Extract services only when:
|
||||
1. A module has significantly different scaling needs
|
||||
2. A team needs independent deployment
|
||||
3. Technology constraints require separation
|
||||
|
||||
---
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
Load these files for detailed information:
|
||||
|
||||
| File | Contains | Load when user asks about |
|
||||
|------|----------|--------------------------|
|
||||
| `references/architecture_patterns.md` | 9 architecture patterns with trade-offs, code examples, and when to use | "which pattern?", "microservices vs monolith", "event-driven", "CQRS" |
|
||||
| `references/system_design_workflows.md` | 6 step-by-step workflows for system design tasks | "how to design?", "capacity planning", "API design", "migration" |
|
||||
| `references/tech_decision_guide.md` | Decision matrices for technology choices | "which database?", "which framework?", "which cloud?", "which cache?" |
|
||||
|
||||
---
|
||||
|
||||
## Tech Stack Coverage
|
||||
|
||||
**Languages:** TypeScript, JavaScript, Python, Go, Swift, Kotlin, Rust
|
||||
**Frontend:** React, Next.js, Vue, Angular, React Native, Flutter
|
||||
**Backend:** Node.js, Express, FastAPI, Go, GraphQL, REST
|
||||
**Databases:** PostgreSQL, MySQL, MongoDB, Redis, DynamoDB, Cassandra
|
||||
**Infrastructure:** Docker, Kubernetes, Terraform, AWS, GCP, Azure
|
||||
**CI/CD:** GitHub Actions, GitLab CI, CircleCI, Jenkins
|
||||
|
||||
---
|
||||
|
||||
## Common Commands
|
||||
|
||||
```bash
|
||||
# Architecture visualization
|
||||
python scripts/architecture_diagram_generator.py . --format mermaid
|
||||
python scripts/architecture_diagram_generator.py . --format plantuml
|
||||
python scripts/architecture_diagram_generator.py . --format ascii
|
||||
|
||||
# Dependency analysis
|
||||
python scripts/dependency_analyzer.py . --verbose
|
||||
python scripts/dependency_analyzer.py . --check circular
|
||||
python scripts/dependency_analyzer.py . --output json
|
||||
|
||||
# Architecture assessment
|
||||
python scripts/project_architect.py . --verbose
|
||||
python scripts/project_architect.py . --check layers
|
||||
python scripts/project_architect.py . --output json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Getting Help
|
||||
|
||||
1. Run any script with `--help` for usage information
|
||||
2. Check reference documentation for detailed patterns and workflows
|
||||
3. Use `--verbose` flag for detailed explanations and recommendations
|
||||
441
docs/skills/engineering-team/senior-backend.md
Normal file
441
docs/skills/engineering-team/senior-backend.md
Normal file
@@ -0,0 +1,441 @@
|
||||
---
|
||||
title: "Senior Backend Engineer"
|
||||
description: "Senior Backend Engineer - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior Backend Engineer
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-backend` | **Source:** [`engineering-team/senior-backend/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-backend/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior Backend Engineer
|
||||
|
||||
Backend development patterns, API design, database optimization, and security practices.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Quick Start](#quick-start)
|
||||
- [Tools Overview](#tools-overview)
|
||||
- [API Scaffolder](#1-api-scaffolder)
|
||||
- [Database Migration Tool](#2-database-migration-tool)
|
||||
- [API Load Tester](#3-api-load-tester)
|
||||
- [Backend Development Workflows](#backend-development-workflows)
|
||||
- [API Design Workflow](#api-design-workflow)
|
||||
- [Database Optimization Workflow](#database-optimization-workflow)
|
||||
- [Security Hardening Workflow](#security-hardening-workflow)
|
||||
- [Reference Documentation](#reference-documentation)
|
||||
- [Common Patterns Quick Reference](#common-patterns-quick-reference)
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Generate API routes from OpenAPI spec
|
||||
python scripts/api_scaffolder.py openapi.yaml --framework express --output src/routes/
|
||||
|
||||
# Analyze database schema and generate migrations
|
||||
python scripts/database_migration_tool.py --connection postgres://localhost/mydb --analyze
|
||||
|
||||
# Load test an API endpoint
|
||||
python scripts/api_load_tester.py https://api.example.com/users --concurrency 50 --duration 30
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tools Overview
|
||||
|
||||
### 1. API Scaffolder
|
||||
|
||||
Generates API route handlers, middleware, and OpenAPI specifications from schema definitions.
|
||||
|
||||
**Input:** OpenAPI spec (YAML/JSON) or database schema
|
||||
**Output:** Route handlers, validation middleware, TypeScript types
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Generate Express routes from OpenAPI spec
|
||||
python scripts/api_scaffolder.py openapi.yaml --framework express --output src/routes/
|
||||
|
||||
# Output:
|
||||
# Generated 12 route handlers in src/routes/
|
||||
# - GET /users (listUsers)
|
||||
# - POST /users (createUser)
|
||||
# - GET /users/{id} (getUser)
|
||||
# - PUT /users/{id} (updateUser)
|
||||
# - DELETE /users/{id} (deleteUser)
|
||||
# ...
|
||||
# Created validation middleware: src/middleware/validators.ts
|
||||
# Created TypeScript types: src/types/api.ts
|
||||
|
||||
# Generate from database schema
|
||||
python scripts/api_scaffolder.py --from-db postgres://localhost/mydb --output src/routes/
|
||||
|
||||
# Generate OpenAPI spec from existing routes
|
||||
python scripts/api_scaffolder.py src/routes/ --generate-spec --output openapi.yaml
|
||||
```
|
||||
|
||||
**Supported Frameworks:**
|
||||
- Express.js (`--framework express`)
|
||||
- Fastify (`--framework fastify`)
|
||||
- Koa (`--framework koa`)
|
||||
|
||||
---
|
||||
|
||||
### 2. Database Migration Tool
|
||||
|
||||
Analyzes database schemas, detects changes, and generates migration files with rollback support.
|
||||
|
||||
**Input:** Database connection string or schema files
|
||||
**Output:** Migration files, schema diff report, optimization suggestions
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Analyze current schema and suggest optimizations
|
||||
python scripts/database_migration_tool.py --connection postgres://localhost/mydb --analyze
|
||||
|
||||
# Output:
|
||||
# === Database Analysis Report ===
|
||||
# Tables: 24
|
||||
# Total rows: 1,247,832
|
||||
#
|
||||
# MISSING INDEXES (5 found):
|
||||
# orders.user_id - 847ms avg query time, ADD INDEX recommended
|
||||
# products.category_id - 234ms avg query time, ADD INDEX recommended
|
||||
#
|
||||
# N+1 QUERY RISKS (3 found):
|
||||
# users -> orders relationship (no eager loading)
|
||||
#
|
||||
# SUGGESTED MIGRATIONS:
|
||||
# 1. Add index on orders(user_id)
|
||||
# 2. Add index on products(category_id)
|
||||
# 3. Add composite index on order_items(order_id, product_id)
|
||||
|
||||
# Generate migration from schema diff
|
||||
python scripts/database_migration_tool.py --connection postgres://localhost/mydb \
|
||||
--compare schema/v2.sql --output migrations/
|
||||
|
||||
# Output:
|
||||
# Generated migration: migrations/20240115_add_user_indexes.sql
|
||||
# Generated rollback: migrations/20240115_add_user_indexes_rollback.sql
|
||||
|
||||
# Dry-run a migration
|
||||
python scripts/database_migration_tool.py --connection postgres://localhost/mydb \
|
||||
--migrate migrations/20240115_add_user_indexes.sql --dry-run
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 3. API Load Tester
|
||||
|
||||
Performs HTTP load testing with configurable concurrency, measuring latency percentiles and throughput.
|
||||
|
||||
**Input:** API endpoint URL and test configuration
|
||||
**Output:** Performance report with latency distribution, error rates, throughput metrics
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Basic load test
|
||||
python scripts/api_load_tester.py https://api.example.com/users --concurrency 50 --duration 30
|
||||
|
||||
# Output:
|
||||
# === Load Test Results ===
|
||||
# Target: https://api.example.com/users
|
||||
# Duration: 30s | Concurrency: 50
|
||||
#
|
||||
# THROUGHPUT:
|
||||
# Total requests: 15,247
|
||||
# Requests/sec: 508.2
|
||||
# Successful: 15,102 (99.0%)
|
||||
# Failed: 145 (1.0%)
|
||||
#
|
||||
# LATENCY (ms):
|
||||
# Min: 12
|
||||
# Avg: 89
|
||||
# P50: 67
|
||||
# P95: 198
|
||||
# P99: 423
|
||||
# Max: 1,247
|
||||
#
|
||||
# ERRORS:
|
||||
# Connection timeout: 89
|
||||
# HTTP 503: 56
|
||||
#
|
||||
# RECOMMENDATION: P99 latency (423ms) exceeds 200ms target.
|
||||
# Consider: connection pooling, query optimization, or horizontal scaling.
|
||||
|
||||
# Test with custom headers and body
|
||||
python scripts/api_load_tester.py https://api.example.com/orders \
|
||||
--method POST \
|
||||
--header "Authorization: Bearer token123" \
|
||||
--body '{"product_id": 1, "quantity": 2}' \
|
||||
--concurrency 100 \
|
||||
--duration 60
|
||||
|
||||
# Compare two endpoints
|
||||
python scripts/api_load_tester.py https://api.example.com/v1/users https://api.example.com/v2/users \
|
||||
--compare --concurrency 50 --duration 30
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Backend Development Workflows
|
||||
|
||||
### API Design Workflow
|
||||
|
||||
Use when designing a new API or refactoring existing endpoints.
|
||||
|
||||
**Step 1: Define resources and operations**
|
||||
```yaml
|
||||
# openapi.yaml
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: User Service API
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/users:
|
||||
get:
|
||||
summary: List users
|
||||
parameters:
|
||||
- name: limit
|
||||
in: query
|
||||
schema:
|
||||
type: integer
|
||||
default: 20
|
||||
post:
|
||||
summary: Create user
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CreateUser'
|
||||
```
|
||||
|
||||
**Step 2: Generate route scaffolding**
|
||||
```bash
|
||||
python scripts/api_scaffolder.py openapi.yaml --framework express --output src/routes/
|
||||
```
|
||||
|
||||
**Step 3: Implement business logic**
|
||||
```typescript
|
||||
// src/routes/users.ts (generated, then customized)
|
||||
export const createUser = async (req: Request, res: Response) => {
|
||||
const { email, name } = req.body;
|
||||
|
||||
// Add business logic
|
||||
const user = await userService.create({ email, name });
|
||||
|
||||
res.status(201).json(user);
|
||||
};
|
||||
```
|
||||
|
||||
**Step 4: Add validation middleware**
|
||||
```bash
|
||||
# Validation is auto-generated from OpenAPI schema
|
||||
# src/middleware/validators.ts includes:
|
||||
# - Request body validation
|
||||
# - Query parameter validation
|
||||
# - Path parameter validation
|
||||
```
|
||||
|
||||
**Step 5: Generate updated OpenAPI spec**
|
||||
```bash
|
||||
python scripts/api_scaffolder.py src/routes/ --generate-spec --output openapi.yaml
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Database Optimization Workflow
|
||||
|
||||
Use when queries are slow or database performance needs improvement.
|
||||
|
||||
**Step 1: Analyze current performance**
|
||||
```bash
|
||||
python scripts/database_migration_tool.py --connection $DATABASE_URL --analyze
|
||||
```
|
||||
|
||||
**Step 2: Identify slow queries**
|
||||
```sql
|
||||
-- Check query execution plans
|
||||
EXPLAIN ANALYZE SELECT * FROM orders
|
||||
WHERE user_id = 123
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 10;
|
||||
|
||||
-- Look for: Seq Scan (bad), Index Scan (good)
|
||||
```
|
||||
|
||||
**Step 3: Generate index migrations**
|
||||
```bash
|
||||
python scripts/database_migration_tool.py --connection $DATABASE_URL \
|
||||
--suggest-indexes --output migrations/
|
||||
```
|
||||
|
||||
**Step 4: Test migration (dry-run)**
|
||||
```bash
|
||||
python scripts/database_migration_tool.py --connection $DATABASE_URL \
|
||||
--migrate migrations/add_indexes.sql --dry-run
|
||||
```
|
||||
|
||||
**Step 5: Apply and verify**
|
||||
```bash
|
||||
# Apply migration
|
||||
python scripts/database_migration_tool.py --connection $DATABASE_URL \
|
||||
--migrate migrations/add_indexes.sql
|
||||
|
||||
# Verify improvement
|
||||
python scripts/database_migration_tool.py --connection $DATABASE_URL --analyze
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Security Hardening Workflow
|
||||
|
||||
Use when preparing an API for production or after a security review.
|
||||
|
||||
**Step 1: Review authentication setup**
|
||||
```typescript
|
||||
// Verify JWT configuration
|
||||
const jwtConfig = {
|
||||
secret: process.env.JWT_SECRET, // Must be from env, never hardcoded
|
||||
expiresIn: '1h', // Short-lived tokens
|
||||
algorithm: 'RS256' // Prefer asymmetric
|
||||
};
|
||||
```
|
||||
|
||||
**Step 2: Add rate limiting**
|
||||
```typescript
|
||||
import rateLimit from 'express-rate-limit';
|
||||
|
||||
const apiLimiter = rateLimit({
|
||||
windowMs: 15 * 60 * 1000, // 15 minutes
|
||||
max: 100, // 100 requests per window
|
||||
standardHeaders: true,
|
||||
legacyHeaders: false,
|
||||
});
|
||||
|
||||
app.use('/api/', apiLimiter);
|
||||
```
|
||||
|
||||
**Step 3: Validate all inputs**
|
||||
```typescript
|
||||
import { z } from 'zod';
|
||||
|
||||
const CreateUserSchema = z.object({
|
||||
email: z.string().email().max(255),
|
||||
name: z.string().min(1).max(100),
|
||||
age: z.number().int().positive().optional()
|
||||
});
|
||||
|
||||
// Use in route handler
|
||||
const data = CreateUserSchema.parse(req.body);
|
||||
```
|
||||
|
||||
**Step 4: Load test with attack patterns**
|
||||
```bash
|
||||
# Test rate limiting
|
||||
python scripts/api_load_tester.py https://api.example.com/login \
|
||||
--concurrency 200 --duration 10 --expect-rate-limit
|
||||
|
||||
# Test input validation
|
||||
python scripts/api_load_tester.py https://api.example.com/users \
|
||||
--method POST \
|
||||
--body '{"email": "not-an-email"}' \
|
||||
--expect-status 400
|
||||
```
|
||||
|
||||
**Step 5: Review security headers**
|
||||
```typescript
|
||||
import helmet from 'helmet';
|
||||
|
||||
app.use(helmet({
|
||||
contentSecurityPolicy: true,
|
||||
crossOriginEmbedderPolicy: true,
|
||||
crossOriginOpenerPolicy: true,
|
||||
crossOriginResourcePolicy: true,
|
||||
hsts: { maxAge: 31536000, includeSubDomains: true },
|
||||
}));
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
| File | Contains | Use When |
|
||||
|------|----------|----------|
|
||||
| `references/api_design_patterns.md` | REST vs GraphQL, versioning, error handling, pagination | Designing new APIs |
|
||||
| `references/database_optimization_guide.md` | Indexing strategies, query optimization, N+1 solutions | Fixing slow queries |
|
||||
| `references/backend_security_practices.md` | OWASP Top 10, auth patterns, input validation | Security hardening |
|
||||
|
||||
---
|
||||
|
||||
## Common Patterns Quick Reference
|
||||
|
||||
### REST API Response Format
|
||||
```json
|
||||
{
|
||||
"data": { "id": 1, "name": "John" },
|
||||
"meta": { "requestId": "abc-123" }
|
||||
}
|
||||
```
|
||||
|
||||
### Error Response Format
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "VALIDATION_ERROR",
|
||||
"message": "Invalid email format",
|
||||
"details": [{ "field": "email", "message": "must be valid email" }]
|
||||
},
|
||||
"meta": { "requestId": "abc-123" }
|
||||
}
|
||||
```
|
||||
|
||||
### HTTP Status Codes
|
||||
| Code | Use Case |
|
||||
|------|----------|
|
||||
| 200 | Success (GET, PUT, PATCH) |
|
||||
| 201 | Created (POST) |
|
||||
| 204 | No Content (DELETE) |
|
||||
| 400 | Validation error |
|
||||
| 401 | Authentication required |
|
||||
| 403 | Permission denied |
|
||||
| 404 | Resource not found |
|
||||
| 429 | Rate limit exceeded |
|
||||
| 500 | Internal server error |
|
||||
|
||||
### Database Index Strategy
|
||||
```sql
|
||||
-- Single column (equality lookups)
|
||||
CREATE INDEX idx_users_email ON users(email);
|
||||
|
||||
-- Composite (multi-column queries)
|
||||
CREATE INDEX idx_orders_user_status ON orders(user_id, status);
|
||||
|
||||
-- Partial (filtered queries)
|
||||
CREATE INDEX idx_orders_active ON orders(created_at) WHERE status = 'active';
|
||||
|
||||
-- Covering (avoid table lookup)
|
||||
CREATE INDEX idx_users_email_name ON users(email) INCLUDE (name);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common Commands
|
||||
|
||||
```bash
|
||||
# API Development
|
||||
python scripts/api_scaffolder.py openapi.yaml --framework express
|
||||
python scripts/api_scaffolder.py src/routes/ --generate-spec
|
||||
|
||||
# Database Operations
|
||||
python scripts/database_migration_tool.py --connection $DATABASE_URL --analyze
|
||||
python scripts/database_migration_tool.py --connection $DATABASE_URL --migrate file.sql
|
||||
|
||||
# Performance Testing
|
||||
python scripts/api_load_tester.py https://api.example.com/endpoint --concurrency 50
|
||||
python scripts/api_load_tester.py https://api.example.com/endpoint --compare baseline.json
|
||||
```
|
||||
538
docs/skills/engineering-team/senior-computer-vision.md
Normal file
538
docs/skills/engineering-team/senior-computer-vision.md
Normal file
@@ -0,0 +1,538 @@
|
||||
---
|
||||
title: "Senior Computer Vision Engineer"
|
||||
description: "Senior Computer Vision Engineer - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior Computer Vision Engineer
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-computer-vision` | **Source:** [`engineering-team/senior-computer-vision/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-computer-vision/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior Computer Vision Engineer
|
||||
|
||||
Production computer vision engineering skill for object detection, image segmentation, and visual AI system deployment.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Quick Start](#quick-start)
|
||||
- [Core Expertise](#core-expertise)
|
||||
- [Tech Stack](#tech-stack)
|
||||
- [Workflow 1: Object Detection Pipeline](#workflow-1-object-detection-pipeline)
|
||||
- [Workflow 2: Model Optimization and Deployment](#workflow-2-model-optimization-and-deployment)
|
||||
- [Workflow 3: Custom Dataset Preparation](#workflow-3-custom-dataset-preparation)
|
||||
- [Architecture Selection Guide](#architecture-selection-guide)
|
||||
- [Reference Documentation](#reference-documentation)
|
||||
- [Common Commands](#common-commands)
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Generate training configuration for YOLO or Faster R-CNN
|
||||
python scripts/vision_model_trainer.py models/ --task detection --arch yolov8
|
||||
|
||||
# Analyze model for optimization opportunities (quantization, pruning)
|
||||
python scripts/inference_optimizer.py model.pt --target onnx --benchmark
|
||||
|
||||
# Build dataset pipeline with augmentations
|
||||
python scripts/dataset_pipeline_builder.py images/ --format coco --augment
|
||||
```
|
||||
|
||||
## Core Expertise
|
||||
|
||||
This skill provides guidance on:
|
||||
|
||||
- **Object Detection**: YOLO family (v5-v11), Faster R-CNN, DETR, RT-DETR
|
||||
- **Instance Segmentation**: Mask R-CNN, YOLACT, SOLOv2
|
||||
- **Semantic Segmentation**: DeepLabV3+, SegFormer, SAM (Segment Anything)
|
||||
- **Image Classification**: ResNet, EfficientNet, Vision Transformers (ViT, DeiT)
|
||||
- **Video Analysis**: Object tracking (ByteTrack, SORT), action recognition
|
||||
- **3D Vision**: Depth estimation, point cloud processing, NeRF
|
||||
- **Production Deployment**: ONNX, TensorRT, OpenVINO, CoreML
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Category | Technologies |
|
||||
|----------|--------------|
|
||||
| Frameworks | PyTorch, torchvision, timm |
|
||||
| Detection | Ultralytics (YOLO), Detectron2, MMDetection |
|
||||
| Segmentation | segment-anything, mmsegmentation |
|
||||
| Optimization | ONNX, TensorRT, OpenVINO, torch.compile |
|
||||
| Image Processing | OpenCV, Pillow, albumentations |
|
||||
| Annotation | CVAT, Label Studio, Roboflow |
|
||||
| Experiment Tracking | MLflow, Weights & Biases |
|
||||
| Serving | Triton Inference Server, TorchServe |
|
||||
|
||||
## Workflow 1: Object Detection Pipeline
|
||||
|
||||
Use this workflow when building an object detection system from scratch.
|
||||
|
||||
### Step 1: Define Detection Requirements
|
||||
|
||||
Analyze the detection task requirements:
|
||||
|
||||
```
|
||||
Detection Requirements Analysis:
|
||||
- Target objects: [list specific classes to detect]
|
||||
- Real-time requirement: [yes/no, target FPS]
|
||||
- Accuracy priority: [speed vs accuracy trade-off]
|
||||
- Deployment target: [cloud GPU, edge device, mobile]
|
||||
- Dataset size: [number of images, annotations per class]
|
||||
```
|
||||
|
||||
### Step 2: Select Detection Architecture
|
||||
|
||||
Choose architecture based on requirements:
|
||||
|
||||
| Requirement | Recommended Architecture | Why |
|
||||
|-------------|-------------------------|-----|
|
||||
| Real-time (>30 FPS) | YOLOv8/v11, RT-DETR | Single-stage, optimized for speed |
|
||||
| High accuracy | Faster R-CNN, DINO | Two-stage, better localization |
|
||||
| Small objects | YOLO + SAHI, Faster R-CNN + FPN | Multi-scale detection |
|
||||
| Edge deployment | YOLOv8n, MobileNetV3-SSD | Lightweight architectures |
|
||||
| Transformer-based | DETR, DINO, RT-DETR | End-to-end, no NMS required |
|
||||
|
||||
### Step 3: Prepare Dataset
|
||||
|
||||
Convert annotations to required format:
|
||||
|
||||
```bash
|
||||
# COCO format (recommended)
|
||||
python scripts/dataset_pipeline_builder.py data/images/ \
|
||||
--annotations data/labels/ \
|
||||
--format coco \
|
||||
--split 0.8 0.1 0.1 \
|
||||
--output data/coco/
|
||||
|
||||
# Verify dataset
|
||||
python -c "from pycocotools.coco import COCO; coco = COCO('data/coco/train.json'); print(f'Images: {len(coco.imgs)}, Categories: {len(coco.cats)}')"
|
||||
```
|
||||
|
||||
### Step 4: Configure Training
|
||||
|
||||
Generate training configuration:
|
||||
|
||||
```bash
|
||||
# For Ultralytics YOLO
|
||||
python scripts/vision_model_trainer.py data/coco/ \
|
||||
--task detection \
|
||||
--arch yolov8m \
|
||||
--epochs 100 \
|
||||
--batch 16 \
|
||||
--imgsz 640 \
|
||||
--output configs/
|
||||
|
||||
# For Detectron2
|
||||
python scripts/vision_model_trainer.py data/coco/ \
|
||||
--task detection \
|
||||
--arch faster_rcnn_R_50_FPN \
|
||||
--framework detectron2 \
|
||||
--output configs/
|
||||
```
|
||||
|
||||
### Step 5: Train and Validate
|
||||
|
||||
```bash
|
||||
# Ultralytics training
|
||||
yolo detect train data=data.yaml model=yolov8m.pt epochs=100 imgsz=640
|
||||
|
||||
# Detectron2 training
|
||||
python train_net.py --config-file configs/faster_rcnn.yaml --num-gpus 1
|
||||
|
||||
# Validate on test set
|
||||
yolo detect val model=runs/detect/train/weights/best.pt data=data.yaml
|
||||
```
|
||||
|
||||
### Step 6: Evaluate Results
|
||||
|
||||
Key metrics to analyze:
|
||||
|
||||
| Metric | Target | Description |
|
||||
|--------|--------|-------------|
|
||||
| mAP@50 | >0.7 | Mean Average Precision at IoU 0.5 |
|
||||
| mAP@50:95 | >0.5 | COCO primary metric |
|
||||
| Precision | >0.8 | Low false positives |
|
||||
| Recall | >0.8 | Low missed detections |
|
||||
| Inference time | <33ms | For 30 FPS real-time |
|
||||
|
||||
## Workflow 2: Model Optimization and Deployment
|
||||
|
||||
Use this workflow when preparing a trained model for production deployment.
|
||||
|
||||
### Step 1: Benchmark Baseline Performance
|
||||
|
||||
```bash
|
||||
# Measure current model performance
|
||||
python scripts/inference_optimizer.py model.pt \
|
||||
--benchmark \
|
||||
--input-size 640 640 \
|
||||
--batch-sizes 1 4 8 16 \
|
||||
--warmup 10 \
|
||||
--iterations 100
|
||||
```
|
||||
|
||||
Expected output:
|
||||
|
||||
```
|
||||
Baseline Performance (PyTorch FP32):
|
||||
- Batch 1: 45.2ms (22.1 FPS)
|
||||
- Batch 4: 89.4ms (44.7 FPS)
|
||||
- Batch 8: 165.3ms (48.4 FPS)
|
||||
- Memory: 2.1 GB
|
||||
- Parameters: 25.9M
|
||||
```
|
||||
|
||||
### Step 2: Select Optimization Strategy
|
||||
|
||||
| Deployment Target | Optimization Path |
|
||||
|-------------------|-------------------|
|
||||
| NVIDIA GPU (cloud) | PyTorch → ONNX → TensorRT FP16 |
|
||||
| NVIDIA GPU (edge) | PyTorch → TensorRT INT8 |
|
||||
| Intel CPU | PyTorch → ONNX → OpenVINO |
|
||||
| Apple Silicon | PyTorch → CoreML |
|
||||
| Generic CPU | PyTorch → ONNX Runtime |
|
||||
| Mobile | PyTorch → TFLite or ONNX Mobile |
|
||||
|
||||
### Step 3: Export to ONNX
|
||||
|
||||
```bash
|
||||
# Export with dynamic batch size
|
||||
python scripts/inference_optimizer.py model.pt \
|
||||
--export onnx \
|
||||
--input-size 640 640 \
|
||||
--dynamic-batch \
|
||||
--simplify \
|
||||
--output model.onnx
|
||||
|
||||
# Verify ONNX model
|
||||
python -c "import onnx; model = onnx.load('model.onnx'); onnx.checker.check_model(model); print('ONNX model valid')"
|
||||
```
|
||||
|
||||
### Step 4: Apply Quantization (Optional)
|
||||
|
||||
For INT8 quantization with calibration:
|
||||
|
||||
```bash
|
||||
# Generate calibration dataset
|
||||
python scripts/inference_optimizer.py model.onnx \
|
||||
--quantize int8 \
|
||||
--calibration-data data/calibration/ \
|
||||
--calibration-samples 500 \
|
||||
--output model_int8.onnx
|
||||
```
|
||||
|
||||
Quantization impact analysis:
|
||||
|
||||
| Precision | Size | Speed | Accuracy Drop |
|
||||
|-----------|------|-------|---------------|
|
||||
| FP32 | 100% | 1x | 0% |
|
||||
| FP16 | 50% | 1.5-2x | <0.5% |
|
||||
| INT8 | 25% | 2-4x | 1-3% |
|
||||
|
||||
### Step 5: Convert to Target Runtime
|
||||
|
||||
```bash
|
||||
# TensorRT (NVIDIA GPU)
|
||||
trtexec --onnx=model.onnx --saveEngine=model.engine --fp16
|
||||
|
||||
# OpenVINO (Intel)
|
||||
mo --input_model model.onnx --output_dir openvino/
|
||||
|
||||
# CoreML (Apple)
|
||||
python -c "import coremltools as ct; model = ct.convert('model.onnx'); model.save('model.mlpackage')"
|
||||
```
|
||||
|
||||
### Step 6: Benchmark Optimized Model
|
||||
|
||||
```bash
|
||||
python scripts/inference_optimizer.py model.engine \
|
||||
--benchmark \
|
||||
--runtime tensorrt \
|
||||
--compare model.pt
|
||||
```
|
||||
|
||||
Expected speedup:
|
||||
|
||||
```
|
||||
Optimization Results:
|
||||
- Original (PyTorch FP32): 45.2ms
|
||||
- Optimized (TensorRT FP16): 12.8ms
|
||||
- Speedup: 3.5x
|
||||
- Accuracy change: -0.3% mAP
|
||||
```
|
||||
|
||||
## Workflow 3: Custom Dataset Preparation
|
||||
|
||||
Use this workflow when preparing a computer vision dataset for training.
|
||||
|
||||
### Step 1: Audit Raw Data
|
||||
|
||||
```bash
|
||||
# Analyze image dataset
|
||||
python scripts/dataset_pipeline_builder.py data/raw/ \
|
||||
--analyze \
|
||||
--output analysis/
|
||||
```
|
||||
|
||||
Analysis report includes:
|
||||
|
||||
```
|
||||
Dataset Analysis:
|
||||
- Total images: 5,234
|
||||
- Image sizes: 640x480 to 4096x3072 (variable)
|
||||
- Formats: JPEG (4,891), PNG (343)
|
||||
- Corrupted: 12 files
|
||||
- Duplicates: 45 pairs
|
||||
|
||||
Annotation Analysis:
|
||||
- Format detected: Pascal VOC XML
|
||||
- Total annotations: 28,456
|
||||
- Classes: 5 (car, person, bicycle, dog, cat)
|
||||
- Distribution: car (12,340), person (8,234), bicycle (3,456), dog (2,890), cat (1,536)
|
||||
- Empty images: 234
|
||||
```
|
||||
|
||||
### Step 2: Clean and Validate
|
||||
|
||||
```bash
|
||||
# Remove corrupted and duplicate images
|
||||
python scripts/dataset_pipeline_builder.py data/raw/ \
|
||||
--clean \
|
||||
--remove-corrupted \
|
||||
--remove-duplicates \
|
||||
--output data/cleaned/
|
||||
```
|
||||
|
||||
### Step 3: Convert Annotation Format
|
||||
|
||||
```bash
|
||||
# Convert VOC to COCO format
|
||||
python scripts/dataset_pipeline_builder.py data/cleaned/ \
|
||||
--annotations data/annotations/ \
|
||||
--input-format voc \
|
||||
--output-format coco \
|
||||
--output data/coco/
|
||||
```
|
||||
|
||||
Supported format conversions:
|
||||
|
||||
| From | To |
|
||||
|------|-----|
|
||||
| Pascal VOC XML | COCO JSON |
|
||||
| YOLO TXT | COCO JSON |
|
||||
| COCO JSON | YOLO TXT |
|
||||
| LabelMe JSON | COCO JSON |
|
||||
| CVAT XML | COCO JSON |
|
||||
|
||||
### Step 4: Apply Augmentations
|
||||
|
||||
```bash
|
||||
# Generate augmentation config
|
||||
python scripts/dataset_pipeline_builder.py data/coco/ \
|
||||
--augment \
|
||||
--aug-config configs/augmentation.yaml \
|
||||
--output data/augmented/
|
||||
```
|
||||
|
||||
Recommended augmentations for detection:
|
||||
|
||||
```yaml
|
||||
# configs/augmentation.yaml
|
||||
augmentations:
|
||||
geometric:
|
||||
- horizontal_flip: { p: 0.5 }
|
||||
- vertical_flip: { p: 0.1 } # Only if orientation invariant
|
||||
- rotate: { limit: 15, p: 0.3 }
|
||||
- scale: { scale_limit: 0.2, p: 0.5 }
|
||||
|
||||
color:
|
||||
- brightness_contrast: { brightness_limit: 0.2, contrast_limit: 0.2, p: 0.5 }
|
||||
- hue_saturation: { hue_shift_limit: 20, sat_shift_limit: 30, p: 0.3 }
|
||||
- blur: { blur_limit: 3, p: 0.1 }
|
||||
|
||||
advanced:
|
||||
- mosaic: { p: 0.5 } # YOLO-style mosaic
|
||||
- mixup: { p: 0.1 } # Image mixing
|
||||
- cutout: { num_holes: 8, max_h_size: 32, max_w_size: 32, p: 0.3 }
|
||||
```
|
||||
|
||||
### Step 5: Create Train/Val/Test Splits
|
||||
|
||||
```bash
|
||||
python scripts/dataset_pipeline_builder.py data/augmented/ \
|
||||
--split 0.8 0.1 0.1 \
|
||||
--stratify \
|
||||
--seed 42 \
|
||||
--output data/final/
|
||||
```
|
||||
|
||||
Split strategy guidelines:
|
||||
|
||||
| Dataset Size | Train | Val | Test |
|
||||
|--------------|-------|-----|------|
|
||||
| <1,000 images | 70% | 15% | 15% |
|
||||
| 1,000-10,000 | 80% | 10% | 10% |
|
||||
| >10,000 | 90% | 5% | 5% |
|
||||
|
||||
### Step 6: Generate Dataset Configuration
|
||||
|
||||
```bash
|
||||
# For Ultralytics YOLO
|
||||
python scripts/dataset_pipeline_builder.py data/final/ \
|
||||
--generate-config yolo \
|
||||
--output data.yaml
|
||||
|
||||
# For Detectron2
|
||||
python scripts/dataset_pipeline_builder.py data/final/ \
|
||||
--generate-config detectron2 \
|
||||
--output detectron2_config.py
|
||||
```
|
||||
|
||||
## Architecture Selection Guide
|
||||
|
||||
### Object Detection Architectures
|
||||
|
||||
| Architecture | Speed | Accuracy | Best For |
|
||||
|--------------|-------|----------|----------|
|
||||
| YOLOv8n | 1.2ms | 37.3 mAP | Edge, mobile, real-time |
|
||||
| YOLOv8s | 2.1ms | 44.9 mAP | Balanced speed/accuracy |
|
||||
| YOLOv8m | 4.2ms | 50.2 mAP | General purpose |
|
||||
| YOLOv8l | 6.8ms | 52.9 mAP | High accuracy |
|
||||
| YOLOv8x | 10.1ms | 53.9 mAP | Maximum accuracy |
|
||||
| RT-DETR-L | 5.3ms | 53.0 mAP | Transformer, no NMS |
|
||||
| Faster R-CNN R50 | 46ms | 40.2 mAP | Two-stage, high quality |
|
||||
| DINO-4scale | 85ms | 49.0 mAP | SOTA transformer |
|
||||
|
||||
### Segmentation Architectures
|
||||
|
||||
| Architecture | Type | Speed | Best For |
|
||||
|--------------|------|-------|----------|
|
||||
| YOLOv8-seg | Instance | 4.5ms | Real-time instance seg |
|
||||
| Mask R-CNN | Instance | 67ms | High-quality masks |
|
||||
| SAM | Promptable | 50ms | Zero-shot segmentation |
|
||||
| DeepLabV3+ | Semantic | 25ms | Scene parsing |
|
||||
| SegFormer | Semantic | 15ms | Efficient semantic seg |
|
||||
|
||||
### CNN vs Vision Transformer Trade-offs
|
||||
|
||||
| Aspect | CNN (YOLO, R-CNN) | ViT (DETR, DINO) |
|
||||
|--------|-------------------|------------------|
|
||||
| Training data needed | 1K-10K images | 10K-100K+ images |
|
||||
| Training time | Fast | Slow (needs more epochs) |
|
||||
| Inference speed | Faster | Slower |
|
||||
| Small objects | Good with FPN | Needs multi-scale |
|
||||
| Global context | Limited | Excellent |
|
||||
| Positional encoding | Implicit | Explicit |
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
### 1. Computer Vision Architectures
|
||||
|
||||
See `references/computer_vision_architectures.md` for:
|
||||
|
||||
- CNN backbone architectures (ResNet, EfficientNet, ConvNeXt)
|
||||
- Vision Transformer variants (ViT, DeiT, Swin)
|
||||
- Detection heads (anchor-based vs anchor-free)
|
||||
- Feature Pyramid Networks (FPN, BiFPN, PANet)
|
||||
- Neck architectures for multi-scale detection
|
||||
|
||||
### 2. Object Detection Optimization
|
||||
|
||||
See `references/object_detection_optimization.md` for:
|
||||
|
||||
- Non-Maximum Suppression variants (NMS, Soft-NMS, DIoU-NMS)
|
||||
- Anchor optimization and anchor-free alternatives
|
||||
- Loss function design (focal loss, GIoU, CIoU, DIoU)
|
||||
- Training strategies (warmup, cosine annealing, EMA)
|
||||
- Data augmentation for detection (mosaic, mixup, copy-paste)
|
||||
|
||||
### 3. Production Vision Systems
|
||||
|
||||
See `references/production_vision_systems.md` for:
|
||||
|
||||
- ONNX export and optimization
|
||||
- TensorRT deployment pipeline
|
||||
- Batch inference optimization
|
||||
- Edge device deployment (Jetson, Intel NCS)
|
||||
- Model serving with Triton
|
||||
- Video processing pipelines
|
||||
|
||||
## Common Commands
|
||||
|
||||
### Ultralytics YOLO
|
||||
|
||||
```bash
|
||||
# Training
|
||||
yolo detect train data=coco.yaml model=yolov8m.pt epochs=100 imgsz=640
|
||||
|
||||
# Validation
|
||||
yolo detect val model=best.pt data=coco.yaml
|
||||
|
||||
# Inference
|
||||
yolo detect predict model=best.pt source=images/ save=True
|
||||
|
||||
# Export
|
||||
yolo export model=best.pt format=onnx simplify=True dynamic=True
|
||||
```
|
||||
|
||||
### Detectron2
|
||||
|
||||
```bash
|
||||
# Training
|
||||
python train_net.py --config-file configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml \
|
||||
--num-gpus 1 OUTPUT_DIR ./output
|
||||
|
||||
# Evaluation
|
||||
python train_net.py --config-file configs/faster_rcnn.yaml --eval-only \
|
||||
MODEL.WEIGHTS output/model_final.pth
|
||||
|
||||
# Inference
|
||||
python demo.py --config-file configs/faster_rcnn.yaml \
|
||||
--input images/*.jpg --output results/ \
|
||||
--opts MODEL.WEIGHTS output/model_final.pth
|
||||
```
|
||||
|
||||
### MMDetection
|
||||
|
||||
```bash
|
||||
# Training
|
||||
python tools/train.py configs/faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py
|
||||
|
||||
# Testing
|
||||
python tools/test.py configs/faster_rcnn.py checkpoints/latest.pth --eval bbox
|
||||
|
||||
# Inference
|
||||
python demo/image_demo.py demo.jpg configs/faster_rcnn.py checkpoints/latest.pth
|
||||
```
|
||||
|
||||
### Model Optimization
|
||||
|
||||
```bash
|
||||
# ONNX export and simplify
|
||||
python -c "import torch; model = torch.load('model.pt'); torch.onnx.export(model, torch.randn(1,3,640,640), 'model.onnx', opset_version=17)"
|
||||
python -m onnxsim model.onnx model_sim.onnx
|
||||
|
||||
# TensorRT conversion
|
||||
trtexec --onnx=model.onnx --saveEngine=model.engine --fp16 --workspace=4096
|
||||
|
||||
# Benchmark
|
||||
trtexec --loadEngine=model.engine --batch=1 --iterations=1000 --avgRuns=100
|
||||
```
|
||||
|
||||
## Performance Targets
|
||||
|
||||
| Metric | Real-time | High Accuracy | Edge |
|
||||
|--------|-----------|---------------|------|
|
||||
| FPS | >30 | >10 | >15 |
|
||||
| mAP@50 | >0.6 | >0.8 | >0.5 |
|
||||
| Latency P99 | <50ms | <150ms | <100ms |
|
||||
| GPU Memory | <4GB | <8GB | <2GB |
|
||||
| Model Size | <50MB | <200MB | <20MB |
|
||||
|
||||
## Resources
|
||||
|
||||
- **Architecture Guide**: `references/computer_vision_architectures.md`
|
||||
- **Optimization Guide**: `references/object_detection_optimization.md`
|
||||
- **Deployment Guide**: `references/production_vision_systems.md`
|
||||
- **Scripts**: `scripts/` directory for automation tools
|
||||
999
docs/skills/engineering-team/senior-data-engineer.md
Normal file
999
docs/skills/engineering-team/senior-data-engineer.md
Normal file
@@ -0,0 +1,999 @@
|
||||
---
|
||||
title: "Senior Data Engineer"
|
||||
description: "Senior Data Engineer - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior Data Engineer
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-data-engineer` | **Source:** [`engineering-team/senior-data-engineer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-data-engineer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior Data Engineer
|
||||
|
||||
Production-grade data engineering skill for building scalable, reliable data systems.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
1. [Trigger Phrases](#trigger-phrases)
|
||||
2. [Quick Start](#quick-start)
|
||||
3. [Workflows](#workflows)
|
||||
- [Building a Batch ETL Pipeline](#workflow-1-building-a-batch-etl-pipeline)
|
||||
- [Implementing Real-Time Streaming](#workflow-2-implementing-real-time-streaming)
|
||||
- [Data Quality Framework Setup](#workflow-3-data-quality-framework-setup)
|
||||
4. [Architecture Decision Framework](#architecture-decision-framework)
|
||||
5. [Tech Stack](#tech-stack)
|
||||
6. [Reference Documentation](#reference-documentation)
|
||||
7. [Troubleshooting](#troubleshooting)
|
||||
|
||||
---
|
||||
|
||||
## Trigger Phrases
|
||||
|
||||
Activate this skill when you see:
|
||||
|
||||
**Pipeline Design:**
|
||||
- "Design a data pipeline for..."
|
||||
- "Build an ETL/ELT process..."
|
||||
- "How should I ingest data from..."
|
||||
- "Set up data extraction from..."
|
||||
|
||||
**Architecture:**
|
||||
- "Should I use batch or streaming?"
|
||||
- "Lambda vs Kappa architecture"
|
||||
- "How to handle late-arriving data"
|
||||
- "Design a data lakehouse"
|
||||
|
||||
**Data Modeling:**
|
||||
- "Create a dimensional model..."
|
||||
- "Star schema vs snowflake"
|
||||
- "Implement slowly changing dimensions"
|
||||
- "Design a data vault"
|
||||
|
||||
**Data Quality:**
|
||||
- "Add data validation to..."
|
||||
- "Set up data quality checks"
|
||||
- "Monitor data freshness"
|
||||
- "Implement data contracts"
|
||||
|
||||
**Performance:**
|
||||
- "Optimize this Spark job"
|
||||
- "Query is running slow"
|
||||
- "Reduce pipeline execution time"
|
||||
- "Tune Airflow DAG"
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Core Tools
|
||||
|
||||
```bash
|
||||
# Generate pipeline orchestration config
|
||||
python scripts/pipeline_orchestrator.py generate \
|
||||
--type airflow \
|
||||
--source postgres \
|
||||
--destination snowflake \
|
||||
--schedule "0 5 * * *"
|
||||
|
||||
# Validate data quality
|
||||
python scripts/data_quality_validator.py validate \
|
||||
--input data/sales.parquet \
|
||||
--schema schemas/sales.json \
|
||||
--checks freshness,completeness,uniqueness
|
||||
|
||||
# Optimize ETL performance
|
||||
python scripts/etl_performance_optimizer.py analyze \
|
||||
--query queries/daily_aggregation.sql \
|
||||
--engine spark \
|
||||
--recommend
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Workflows
|
||||
|
||||
### Workflow 1: Building a Batch ETL Pipeline
|
||||
|
||||
**Scenario:** Extract data from PostgreSQL, transform with dbt, load to Snowflake.
|
||||
|
||||
#### Step 1: Define Source Schema
|
||||
|
||||
```sql
|
||||
-- Document source tables
|
||||
SELECT
|
||||
table_name,
|
||||
column_name,
|
||||
data_type,
|
||||
is_nullable
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'source_schema'
|
||||
ORDER BY table_name, ordinal_position;
|
||||
```
|
||||
|
||||
#### Step 2: Generate Extraction Config
|
||||
|
||||
```bash
|
||||
python scripts/pipeline_orchestrator.py generate \
|
||||
--type airflow \
|
||||
--source postgres \
|
||||
--tables orders,customers,products \
|
||||
--mode incremental \
|
||||
--watermark updated_at \
|
||||
--output dags/extract_source.py
|
||||
```
|
||||
|
||||
#### Step 3: Create dbt Models
|
||||
|
||||
```sql
|
||||
-- models/staging/stg_orders.sql
|
||||
WITH source AS (
|
||||
SELECT * FROM {{ source('postgres', 'orders') }}
|
||||
),
|
||||
|
||||
renamed AS (
|
||||
SELECT
|
||||
order_id,
|
||||
customer_id,
|
||||
order_date,
|
||||
total_amount,
|
||||
status,
|
||||
_extracted_at
|
||||
FROM source
|
||||
WHERE order_date >= DATEADD(day, -3, CURRENT_DATE)
|
||||
)
|
||||
|
||||
SELECT * FROM renamed
|
||||
```
|
||||
|
||||
```sql
|
||||
-- models/marts/fct_orders.sql
|
||||
{{
|
||||
config(
|
||||
materialized='incremental',
|
||||
unique_key='order_id',
|
||||
cluster_by=['order_date']
|
||||
)
|
||||
}}
|
||||
|
||||
SELECT
|
||||
o.order_id,
|
||||
o.customer_id,
|
||||
c.customer_segment,
|
||||
o.order_date,
|
||||
o.total_amount,
|
||||
o.status
|
||||
FROM {{ ref('stg_orders') }} o
|
||||
LEFT JOIN {{ ref('dim_customers') }} c
|
||||
ON o.customer_id = c.customer_id
|
||||
|
||||
{% if is_incremental() %}
|
||||
WHERE o._extracted_at > (SELECT MAX(_extracted_at) FROM {{ this }})
|
||||
{% endif %}
|
||||
```
|
||||
|
||||
#### Step 4: Configure Data Quality Tests
|
||||
|
||||
```yaml
|
||||
# models/marts/schema.yml
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: fct_orders
|
||||
description: "Order fact table"
|
||||
columns:
|
||||
- name: order_id
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
- name: total_amount
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_utils.accepted_range:
|
||||
min_value: 0
|
||||
max_value: 1000000
|
||||
- name: order_date
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_utils.recency:
|
||||
datepart: day
|
||||
field: order_date
|
||||
interval: 1
|
||||
```
|
||||
|
||||
#### Step 5: Create Airflow DAG
|
||||
|
||||
```python
|
||||
# dags/daily_etl.py
|
||||
from airflow import DAG
|
||||
from airflow.providers.postgres.operators.postgres import PostgresOperator
|
||||
from airflow.operators.bash import BashOperator
|
||||
from airflow.utils.dates import days_ago
|
||||
from datetime import timedelta
|
||||
|
||||
default_args = {
|
||||
'owner': 'data-team',
|
||||
'depends_on_past': False,
|
||||
'email_on_failure': True,
|
||||
'email': ['data-alerts@company.com'],
|
||||
'retries': 2,
|
||||
'retry_delay': timedelta(minutes=5),
|
||||
}
|
||||
|
||||
with DAG(
|
||||
'daily_etl_pipeline',
|
||||
default_args=default_args,
|
||||
description='Daily ETL from PostgreSQL to Snowflake',
|
||||
schedule_interval='0 5 * * *',
|
||||
start_date=days_ago(1),
|
||||
catchup=False,
|
||||
tags=['etl', 'daily'],
|
||||
) as dag:
|
||||
|
||||
extract = BashOperator(
|
||||
task_id='extract_source_data',
|
||||
bash_command='python /opt/airflow/scripts/extract.py --date {{ ds }}',
|
||||
)
|
||||
|
||||
transform = BashOperator(
|
||||
task_id='run_dbt_models',
|
||||
bash_command='cd /opt/airflow/dbt && dbt run --select marts.*',
|
||||
)
|
||||
|
||||
test = BashOperator(
|
||||
task_id='run_dbt_tests',
|
||||
bash_command='cd /opt/airflow/dbt && dbt test --select marts.*',
|
||||
)
|
||||
|
||||
notify = BashOperator(
|
||||
task_id='send_notification',
|
||||
bash_command='python /opt/airflow/scripts/notify.py --status success',
|
||||
trigger_rule='all_success',
|
||||
)
|
||||
|
||||
extract >> transform >> test >> notify
|
||||
```
|
||||
|
||||
#### Step 6: Validate Pipeline
|
||||
|
||||
```bash
|
||||
# Test locally
|
||||
dbt run --select stg_orders fct_orders
|
||||
dbt test --select fct_orders
|
||||
|
||||
# Validate data quality
|
||||
python scripts/data_quality_validator.py validate \
|
||||
--table fct_orders \
|
||||
--checks all \
|
||||
--output reports/quality_report.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Workflow 2: Implementing Real-Time Streaming
|
||||
|
||||
**Scenario:** Stream events from Kafka, process with Flink/Spark Streaming, sink to data lake.
|
||||
|
||||
#### Step 1: Define Event Schema
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "UserEvent",
|
||||
"type": "object",
|
||||
"required": ["event_id", "user_id", "event_type", "timestamp"],
|
||||
"properties": {
|
||||
"event_id": {"type": "string", "format": "uuid"},
|
||||
"user_id": {"type": "string"},
|
||||
"event_type": {"type": "string", "enum": ["page_view", "click", "purchase"]},
|
||||
"timestamp": {"type": "string", "format": "date-time"},
|
||||
"properties": {"type": "object"}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Step 2: Create Kafka Topic
|
||||
|
||||
```bash
|
||||
# Create topic with appropriate partitions
|
||||
kafka-topics.sh --create \
|
||||
--bootstrap-server localhost:9092 \
|
||||
--topic user-events \
|
||||
--partitions 12 \
|
||||
--replication-factor 3 \
|
||||
--config retention.ms=604800000 \
|
||||
--config cleanup.policy=delete
|
||||
|
||||
# Verify topic
|
||||
kafka-topics.sh --describe \
|
||||
--bootstrap-server localhost:9092 \
|
||||
--topic user-events
|
||||
```
|
||||
|
||||
#### Step 3: Implement Spark Streaming Job
|
||||
|
||||
```python
|
||||
# streaming/user_events_processor.py
|
||||
from pyspark.sql import SparkSession
|
||||
from pyspark.sql.functions import (
|
||||
from_json, col, window, count, avg,
|
||||
to_timestamp, current_timestamp
|
||||
)
|
||||
from pyspark.sql.types import (
|
||||
StructType, StructField, StringType,
|
||||
TimestampType, MapType
|
||||
)
|
||||
|
||||
# Initialize Spark
|
||||
spark = SparkSession.builder \
|
||||
.appName("UserEventsProcessor") \
|
||||
.config("spark.sql.streaming.checkpointLocation", "/checkpoints/user-events") \
|
||||
.config("spark.sql.shuffle.partitions", "12") \
|
||||
.getOrCreate()
|
||||
|
||||
# Define schema
|
||||
event_schema = StructType([
|
||||
StructField("event_id", StringType(), False),
|
||||
StructField("user_id", StringType(), False),
|
||||
StructField("event_type", StringType(), False),
|
||||
StructField("timestamp", StringType(), False),
|
||||
StructField("properties", MapType(StringType(), StringType()), True)
|
||||
])
|
||||
|
||||
# Read from Kafka
|
||||
events_df = spark.readStream \
|
||||
.format("kafka") \
|
||||
.option("kafka.bootstrap.servers", "localhost:9092") \
|
||||
.option("subscribe", "user-events") \
|
||||
.option("startingOffsets", "latest") \
|
||||
.option("failOnDataLoss", "false") \
|
||||
.load()
|
||||
|
||||
# Parse JSON
|
||||
parsed_df = events_df \
|
||||
.select(from_json(col("value").cast("string"), event_schema).alias("data")) \
|
||||
.select("data.*") \
|
||||
.withColumn("event_timestamp", to_timestamp(col("timestamp")))
|
||||
|
||||
# Windowed aggregation
|
||||
aggregated_df = parsed_df \
|
||||
.withWatermark("event_timestamp", "10 minutes") \
|
||||
.groupBy(
|
||||
window(col("event_timestamp"), "5 minutes"),
|
||||
col("event_type")
|
||||
) \
|
||||
.agg(
|
||||
count("*").alias("event_count"),
|
||||
approx_count_distinct("user_id").alias("unique_users")
|
||||
)
|
||||
|
||||
# Write to Delta Lake
|
||||
query = aggregated_df.writeStream \
|
||||
.format("delta") \
|
||||
.outputMode("append") \
|
||||
.option("checkpointLocation", "/checkpoints/user-events-aggregated") \
|
||||
.option("path", "/data/lake/user_events_aggregated") \
|
||||
.trigger(processingTime="1 minute") \
|
||||
.start()
|
||||
|
||||
query.awaitTermination()
|
||||
```
|
||||
|
||||
#### Step 4: Handle Late Data and Errors
|
||||
|
||||
```python
|
||||
# Dead letter queue for failed records
|
||||
from pyspark.sql.functions import current_timestamp, lit
|
||||
|
||||
def process_with_error_handling(batch_df, batch_id):
|
||||
try:
|
||||
# Attempt processing
|
||||
valid_df = batch_df.filter(col("event_id").isNotNull())
|
||||
invalid_df = batch_df.filter(col("event_id").isNull())
|
||||
|
||||
# Write valid records
|
||||
valid_df.write \
|
||||
.format("delta") \
|
||||
.mode("append") \
|
||||
.save("/data/lake/user_events")
|
||||
|
||||
# Write invalid to DLQ
|
||||
if invalid_df.count() > 0:
|
||||
invalid_df \
|
||||
.withColumn("error_timestamp", current_timestamp()) \
|
||||
.withColumn("error_reason", lit("missing_event_id")) \
|
||||
.write \
|
||||
.format("delta") \
|
||||
.mode("append") \
|
||||
.save("/data/lake/dlq/user_events")
|
||||
|
||||
except Exception as e:
|
||||
# Log error, alert, continue
|
||||
logger.error(f"Batch {batch_id} failed: {e}")
|
||||
raise
|
||||
|
||||
# Use foreachBatch for custom processing
|
||||
query = parsed_df.writeStream \
|
||||
.foreachBatch(process_with_error_handling) \
|
||||
.option("checkpointLocation", "/checkpoints/user-events") \
|
||||
.start()
|
||||
```
|
||||
|
||||
#### Step 5: Monitor Stream Health
|
||||
|
||||
```python
|
||||
# monitoring/stream_metrics.py
|
||||
from prometheus_client import Gauge, Counter, start_http_server
|
||||
|
||||
# Define metrics
|
||||
RECORDS_PROCESSED = Counter(
|
||||
'stream_records_processed_total',
|
||||
'Total records processed',
|
||||
['stream_name', 'status']
|
||||
)
|
||||
|
||||
PROCESSING_LAG = Gauge(
|
||||
'stream_processing_lag_seconds',
|
||||
'Current processing lag',
|
||||
['stream_name']
|
||||
)
|
||||
|
||||
BATCH_DURATION = Gauge(
|
||||
'stream_batch_duration_seconds',
|
||||
'Last batch processing duration',
|
||||
['stream_name']
|
||||
)
|
||||
|
||||
def emit_metrics(query):
|
||||
"""Emit Prometheus metrics from streaming query."""
|
||||
progress = query.lastProgress
|
||||
if progress:
|
||||
RECORDS_PROCESSED.labels(
|
||||
stream_name='user-events',
|
||||
status='success'
|
||||
).inc(progress['numInputRows'])
|
||||
|
||||
if progress['sources']:
|
||||
# Calculate lag from latest offset
|
||||
for source in progress['sources']:
|
||||
end_offset = source.get('endOffset', {})
|
||||
# Parse Kafka offsets and calculate lag
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Workflow 3: Data Quality Framework Setup
|
||||
|
||||
**Scenario:** Implement comprehensive data quality monitoring with Great Expectations.
|
||||
|
||||
#### Step 1: Initialize Great Expectations
|
||||
|
||||
```bash
|
||||
# Install and initialize
|
||||
pip install great_expectations
|
||||
|
||||
great_expectations init
|
||||
|
||||
# Connect to data source
|
||||
great_expectations datasource new
|
||||
```
|
||||
|
||||
#### Step 2: Create Expectation Suite
|
||||
|
||||
```python
|
||||
# expectations/orders_suite.py
|
||||
import great_expectations as gx
|
||||
|
||||
context = gx.get_context()
|
||||
|
||||
# Create expectation suite
|
||||
suite = context.add_expectation_suite("orders_quality_suite")
|
||||
|
||||
# Add expectations
|
||||
validator = context.get_validator(
|
||||
batch_request={
|
||||
"datasource_name": "warehouse",
|
||||
"data_asset_name": "orders",
|
||||
},
|
||||
expectation_suite_name="orders_quality_suite"
|
||||
)
|
||||
|
||||
# Schema expectations
|
||||
validator.expect_table_columns_to_match_ordered_list(
|
||||
column_list=[
|
||||
"order_id", "customer_id", "order_date",
|
||||
"total_amount", "status", "created_at"
|
||||
]
|
||||
)
|
||||
|
||||
# Completeness expectations
|
||||
validator.expect_column_values_to_not_be_null("order_id")
|
||||
validator.expect_column_values_to_not_be_null("customer_id")
|
||||
validator.expect_column_values_to_not_be_null("order_date")
|
||||
|
||||
# Uniqueness expectations
|
||||
validator.expect_column_values_to_be_unique("order_id")
|
||||
|
||||
# Range expectations
|
||||
validator.expect_column_values_to_be_between(
|
||||
"total_amount",
|
||||
min_value=0,
|
||||
max_value=1000000
|
||||
)
|
||||
|
||||
# Categorical expectations
|
||||
validator.expect_column_values_to_be_in_set(
|
||||
"status",
|
||||
["pending", "confirmed", "shipped", "delivered", "cancelled"]
|
||||
)
|
||||
|
||||
# Freshness expectation
|
||||
validator.expect_column_max_to_be_between(
|
||||
"order_date",
|
||||
min_value={"$PARAMETER": "now - timedelta(days=1)"},
|
||||
max_value={"$PARAMETER": "now"}
|
||||
)
|
||||
|
||||
# Referential integrity
|
||||
validator.expect_column_values_to_be_in_set(
|
||||
"customer_id",
|
||||
value_set={"$PARAMETER": "valid_customer_ids"}
|
||||
)
|
||||
|
||||
validator.save_expectation_suite(discard_failed_expectations=False)
|
||||
```
|
||||
|
||||
#### Step 3: Create Data Quality Checks with dbt
|
||||
|
||||
```yaml
|
||||
# models/marts/schema.yml
|
||||
version: 2
|
||||
|
||||
models:
|
||||
- name: fct_orders
|
||||
description: "Order fact table with data quality checks"
|
||||
|
||||
tests:
|
||||
# Row count check
|
||||
- dbt_utils.equal_rowcount:
|
||||
compare_model: ref('stg_orders')
|
||||
|
||||
# Freshness check
|
||||
- dbt_utils.recency:
|
||||
datepart: hour
|
||||
field: created_at
|
||||
interval: 24
|
||||
|
||||
columns:
|
||||
- name: order_id
|
||||
description: "Unique order identifier"
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('dim_orders')
|
||||
field: order_id
|
||||
|
||||
- name: total_amount
|
||||
tests:
|
||||
- not_null
|
||||
- dbt_utils.accepted_range:
|
||||
min_value: 0
|
||||
max_value: 1000000
|
||||
inclusive: true
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
row_condition: "status != 'cancelled'"
|
||||
|
||||
- name: customer_id
|
||||
tests:
|
||||
- not_null
|
||||
- relationships:
|
||||
to: ref('dim_customers')
|
||||
field: customer_id
|
||||
severity: warn
|
||||
```
|
||||
|
||||
#### Step 4: Implement Data Contracts
|
||||
|
||||
```yaml
|
||||
# contracts/orders_contract.yaml
|
||||
contract:
|
||||
name: orders_data_contract
|
||||
version: "1.0.0"
|
||||
owner: data-team@company.com
|
||||
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
order_id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: "Unique order identifier"
|
||||
customer_id:
|
||||
type: string
|
||||
not_null: true
|
||||
order_date:
|
||||
type: date
|
||||
not_null: true
|
||||
total_amount:
|
||||
type: decimal
|
||||
precision: 10
|
||||
scale: 2
|
||||
minimum: 0
|
||||
status:
|
||||
type: string
|
||||
enum: ["pending", "confirmed", "shipped", "delivered", "cancelled"]
|
||||
|
||||
sla:
|
||||
freshness:
|
||||
max_delay_hours: 1
|
||||
completeness:
|
||||
min_percentage: 99.9
|
||||
accuracy:
|
||||
duplicate_tolerance: 0.01
|
||||
|
||||
consumers:
|
||||
- name: analytics-team
|
||||
usage: "Daily reporting dashboards"
|
||||
- name: ml-team
|
||||
usage: "Churn prediction model"
|
||||
```
|
||||
|
||||
#### Step 5: Set Up Quality Monitoring Dashboard
|
||||
|
||||
```python
|
||||
# monitoring/quality_dashboard.py
|
||||
from datetime import datetime, timedelta
|
||||
import pandas as pd
|
||||
|
||||
def generate_quality_report(connection, table_name: str) -> dict:
|
||||
"""Generate comprehensive data quality report."""
|
||||
|
||||
report = {
|
||||
"table": table_name,
|
||||
"timestamp": datetime.now().isoformat(),
|
||||
"checks": {}
|
||||
}
|
||||
|
||||
# Row count check
|
||||
row_count = connection.execute(
|
||||
f"SELECT COUNT(*) FROM {table_name}"
|
||||
).fetchone()[0]
|
||||
report["checks"]["row_count"] = {
|
||||
"value": row_count,
|
||||
"status": "pass" if row_count > 0 else "fail"
|
||||
}
|
||||
|
||||
# Freshness check
|
||||
max_date = connection.execute(
|
||||
f"SELECT MAX(created_at) FROM {table_name}"
|
||||
).fetchone()[0]
|
||||
hours_old = (datetime.now() - max_date).total_seconds() / 3600
|
||||
report["checks"]["freshness"] = {
|
||||
"max_timestamp": max_date.isoformat(),
|
||||
"hours_old": round(hours_old, 2),
|
||||
"status": "pass" if hours_old < 24 else "fail"
|
||||
}
|
||||
|
||||
# Null rate check
|
||||
null_query = f"""
|
||||
SELECT
|
||||
SUM(CASE WHEN order_id IS NULL THEN 1 ELSE 0 END) as null_order_id,
|
||||
SUM(CASE WHEN customer_id IS NULL THEN 1 ELSE 0 END) as null_customer_id,
|
||||
COUNT(*) as total
|
||||
FROM {table_name}
|
||||
"""
|
||||
null_result = connection.execute(null_query).fetchone()
|
||||
report["checks"]["null_rates"] = {
|
||||
"order_id": null_result[0] / null_result[2] if null_result[2] > 0 else 0,
|
||||
"customer_id": null_result[1] / null_result[2] if null_result[2] > 0 else 0,
|
||||
"status": "pass" if null_result[0] == 0 and null_result[1] == 0 else "fail"
|
||||
}
|
||||
|
||||
# Duplicate check
|
||||
dup_query = f"""
|
||||
SELECT COUNT(*) - COUNT(DISTINCT order_id) as duplicates
|
||||
FROM {table_name}
|
||||
"""
|
||||
duplicates = connection.execute(dup_query).fetchone()[0]
|
||||
report["checks"]["duplicates"] = {
|
||||
"count": duplicates,
|
||||
"status": "pass" if duplicates == 0 else "fail"
|
||||
}
|
||||
|
||||
# Overall status
|
||||
all_passed = all(
|
||||
check["status"] == "pass"
|
||||
for check in report["checks"].values()
|
||||
)
|
||||
report["overall_status"] = "pass" if all_passed else "fail"
|
||||
|
||||
return report
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Architecture Decision Framework
|
||||
|
||||
Use this framework to choose the right approach for your data pipeline.
|
||||
|
||||
### Batch vs Streaming
|
||||
|
||||
| Criteria | Batch | Streaming |
|
||||
|----------|-------|-----------|
|
||||
| **Latency requirement** | Hours to days | Seconds to minutes |
|
||||
| **Data volume** | Large historical datasets | Continuous event streams |
|
||||
| **Processing complexity** | Complex transformations, ML | Simple aggregations, filtering |
|
||||
| **Cost sensitivity** | More cost-effective | Higher infrastructure cost |
|
||||
| **Error handling** | Easier to reprocess | Requires careful design |
|
||||
|
||||
**Decision Tree:**
|
||||
```
|
||||
Is real-time insight required?
|
||||
├── Yes → Use streaming
|
||||
│ └── Is exactly-once semantics needed?
|
||||
│ ├── Yes → Kafka + Flink/Spark Structured Streaming
|
||||
│ └── No → Kafka + consumer groups
|
||||
└── No → Use batch
|
||||
└── Is data volume > 1TB daily?
|
||||
├── Yes → Spark/Databricks
|
||||
└── No → dbt + warehouse compute
|
||||
```
|
||||
|
||||
### Lambda vs Kappa Architecture
|
||||
|
||||
| Aspect | Lambda | Kappa |
|
||||
|--------|--------|-------|
|
||||
| **Complexity** | Two codebases (batch + stream) | Single codebase |
|
||||
| **Maintenance** | Higher (sync batch/stream logic) | Lower |
|
||||
| **Reprocessing** | Native batch layer | Replay from source |
|
||||
| **Use case** | ML training + real-time serving | Pure event-driven |
|
||||
|
||||
**When to choose Lambda:**
|
||||
- Need to train ML models on historical data
|
||||
- Complex batch transformations not feasible in streaming
|
||||
- Existing batch infrastructure
|
||||
|
||||
**When to choose Kappa:**
|
||||
- Event-sourced architecture
|
||||
- All processing can be expressed as stream operations
|
||||
- Starting fresh without legacy systems
|
||||
|
||||
### Data Warehouse vs Data Lakehouse
|
||||
|
||||
| Feature | Warehouse (Snowflake/BigQuery) | Lakehouse (Delta/Iceberg) |
|
||||
|---------|-------------------------------|---------------------------|
|
||||
| **Best for** | BI, SQL analytics | ML, unstructured data |
|
||||
| **Storage cost** | Higher (proprietary format) | Lower (open formats) |
|
||||
| **Flexibility** | Schema-on-write | Schema-on-read |
|
||||
| **Performance** | Excellent for SQL | Good, improving |
|
||||
| **Ecosystem** | Mature BI tools | Growing ML tooling |
|
||||
|
||||
---
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Category | Technologies |
|
||||
|----------|--------------|
|
||||
| **Languages** | Python, SQL, Scala |
|
||||
| **Orchestration** | Airflow, Prefect, Dagster |
|
||||
| **Transformation** | dbt, Spark, Flink |
|
||||
| **Streaming** | Kafka, Kinesis, Pub/Sub |
|
||||
| **Storage** | S3, GCS, Delta Lake, Iceberg |
|
||||
| **Warehouses** | Snowflake, BigQuery, Redshift, Databricks |
|
||||
| **Quality** | Great Expectations, dbt tests, Monte Carlo |
|
||||
| **Monitoring** | Prometheus, Grafana, Datadog |
|
||||
|
||||
---
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
### 1. Data Pipeline Architecture
|
||||
See `references/data_pipeline_architecture.md` for:
|
||||
- Lambda vs Kappa architecture patterns
|
||||
- Batch processing with Spark and Airflow
|
||||
- Stream processing with Kafka and Flink
|
||||
- Exactly-once semantics implementation
|
||||
- Error handling and dead letter queues
|
||||
|
||||
### 2. Data Modeling Patterns
|
||||
See `references/data_modeling_patterns.md` for:
|
||||
- Dimensional modeling (Star/Snowflake)
|
||||
- Slowly Changing Dimensions (SCD Types 1-6)
|
||||
- Data Vault modeling
|
||||
- dbt best practices
|
||||
- Partitioning and clustering
|
||||
|
||||
### 3. DataOps Best Practices
|
||||
See `references/dataops_best_practices.md` for:
|
||||
- Data testing frameworks
|
||||
- Data contracts and schema validation
|
||||
- CI/CD for data pipelines
|
||||
- Observability and lineage
|
||||
- Incident response
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Pipeline Failures
|
||||
|
||||
**Symptom:** Airflow DAG fails with timeout
|
||||
```
|
||||
Task exceeded max execution time
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
1. Check resource allocation
|
||||
2. Profile slow operations
|
||||
3. Add incremental processing
|
||||
```python
|
||||
# Increase timeout
|
||||
default_args = {
|
||||
'execution_timeout': timedelta(hours=2),
|
||||
}
|
||||
|
||||
# Or use incremental loads
|
||||
WHERE updated_at > '{{ prev_ds }}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Symptom:** Spark job OOM
|
||||
```
|
||||
java.lang.OutOfMemoryError: Java heap space
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
1. Increase executor memory
|
||||
2. Reduce partition size
|
||||
3. Use disk spill
|
||||
```python
|
||||
spark.conf.set("spark.executor.memory", "8g")
|
||||
spark.conf.set("spark.sql.shuffle.partitions", "200")
|
||||
spark.conf.set("spark.memory.fraction", "0.8")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Symptom:** Kafka consumer lag increasing
|
||||
```
|
||||
Consumer lag: 1000000 messages
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
1. Increase consumer parallelism
|
||||
2. Optimize processing logic
|
||||
3. Scale consumer group
|
||||
```bash
|
||||
# Add more partitions
|
||||
kafka-topics.sh --alter \
|
||||
--bootstrap-server localhost:9092 \
|
||||
--topic user-events \
|
||||
--partitions 24
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Data Quality Issues
|
||||
|
||||
**Symptom:** Duplicate records appearing
|
||||
```
|
||||
Expected unique, found 150 duplicates
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
1. Add deduplication logic
|
||||
2. Use merge/upsert operations
|
||||
```sql
|
||||
-- dbt incremental with dedup
|
||||
{{
|
||||
config(
|
||||
materialized='incremental',
|
||||
unique_key='order_id'
|
||||
)
|
||||
}}
|
||||
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
*,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY order_id
|
||||
ORDER BY updated_at DESC
|
||||
) as rn
|
||||
FROM {{ source('raw', 'orders') }}
|
||||
) WHERE rn = 1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Symptom:** Stale data in tables
|
||||
```
|
||||
Last update: 3 days ago
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
1. Check upstream pipeline status
|
||||
2. Verify source availability
|
||||
3. Add freshness monitoring
|
||||
```yaml
|
||||
# dbt freshness check
|
||||
sources:
|
||||
- name: raw
|
||||
freshness:
|
||||
warn_after: {count: 12, period: hour}
|
||||
error_after: {count: 24, period: hour}
|
||||
loaded_at_field: _loaded_at
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Symptom:** Schema drift detected
|
||||
```
|
||||
Column 'new_field' not in expected schema
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
1. Update data contract
|
||||
2. Modify transformations
|
||||
3. Communicate with producers
|
||||
```python
|
||||
# Handle schema evolution
|
||||
df = spark.read.format("delta") \
|
||||
.option("mergeSchema", "true") \
|
||||
.load("/data/orders")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Performance Issues
|
||||
|
||||
**Symptom:** Query takes hours
|
||||
```
|
||||
Query runtime: 4 hours (expected: 30 minutes)
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
1. Check query plan
|
||||
2. Add proper partitioning
|
||||
3. Optimize joins
|
||||
```sql
|
||||
-- Before: Full table scan
|
||||
SELECT * FROM orders WHERE order_date = '2024-01-15';
|
||||
|
||||
-- After: Partition pruning
|
||||
-- Table partitioned by order_date
|
||||
SELECT * FROM orders WHERE order_date = '2024-01-15';
|
||||
|
||||
-- Add clustering for frequent filters
|
||||
ALTER TABLE orders CLUSTER BY (customer_id);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Symptom:** dbt model takes too long
|
||||
```
|
||||
Model fct_orders completed in 45 minutes
|
||||
```
|
||||
|
||||
**Solution:**
|
||||
1. Use incremental materialization
|
||||
2. Reduce upstream dependencies
|
||||
3. Pre-aggregate where possible
|
||||
```sql
|
||||
-- Convert to incremental
|
||||
{{
|
||||
config(
|
||||
materialized='incremental',
|
||||
unique_key='order_id',
|
||||
on_schema_change='sync_all_columns'
|
||||
)
|
||||
}}
|
||||
|
||||
SELECT * FROM {{ ref('stg_orders') }}
|
||||
{% if is_incremental() %}
|
||||
WHERE _loaded_at > (SELECT MAX(_loaded_at) FROM {{ this }})
|
||||
{% endif %}
|
||||
```
|
||||
233
docs/skills/engineering-team/senior-data-scientist.md
Normal file
233
docs/skills/engineering-team/senior-data-scientist.md
Normal file
@@ -0,0 +1,233 @@
|
||||
---
|
||||
title: "Senior Data Scientist"
|
||||
description: "Senior Data Scientist - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior Data Scientist
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-data-scientist` | **Source:** [`engineering-team/senior-data-scientist/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-data-scientist/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior Data Scientist
|
||||
|
||||
World-class senior data scientist skill for production-grade AI/ML/Data systems.
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Main Capabilities
|
||||
|
||||
```bash
|
||||
# Core Tool 1
|
||||
python scripts/experiment_designer.py --input data/ --output results/
|
||||
|
||||
# Core Tool 2
|
||||
python scripts/feature_engineering_pipeline.py --target project/ --analyze
|
||||
|
||||
# Core Tool 3
|
||||
python scripts/model_evaluation_suite.py --config config.yaml --deploy
|
||||
```
|
||||
|
||||
## Core Expertise
|
||||
|
||||
This skill covers world-class capabilities in:
|
||||
|
||||
- Advanced production patterns and architectures
|
||||
- Scalable system design and implementation
|
||||
- Performance optimization at scale
|
||||
- MLOps and DataOps best practices
|
||||
- Real-time processing and inference
|
||||
- Distributed computing frameworks
|
||||
- Model deployment and monitoring
|
||||
- Security and compliance
|
||||
- Cost optimization
|
||||
- Team leadership and mentoring
|
||||
|
||||
## Tech Stack
|
||||
|
||||
**Languages:** Python, SQL, R, Scala, Go
|
||||
**ML Frameworks:** PyTorch, TensorFlow, Scikit-learn, XGBoost
|
||||
**Data Tools:** Spark, Airflow, dbt, Kafka, Databricks
|
||||
**LLM Frameworks:** LangChain, LlamaIndex, DSPy
|
||||
**Deployment:** Docker, Kubernetes, AWS/GCP/Azure
|
||||
**Monitoring:** MLflow, Weights & Biases, Prometheus
|
||||
**Databases:** PostgreSQL, BigQuery, Snowflake, Pinecone
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
### 1. Statistical Methods Advanced
|
||||
|
||||
Comprehensive guide available in `references/statistical_methods_advanced.md` covering:
|
||||
|
||||
- Advanced patterns and best practices
|
||||
- Production implementation strategies
|
||||
- Performance optimization techniques
|
||||
- Scalability considerations
|
||||
- Security and compliance
|
||||
- Real-world case studies
|
||||
|
||||
### 2. Experiment Design Frameworks
|
||||
|
||||
Complete workflow documentation in `references/experiment_design_frameworks.md` including:
|
||||
|
||||
- Step-by-step processes
|
||||
- Architecture design patterns
|
||||
- Tool integration guides
|
||||
- Performance tuning strategies
|
||||
- Troubleshooting procedures
|
||||
|
||||
### 3. Feature Engineering Patterns
|
||||
|
||||
Technical reference guide in `references/feature_engineering_patterns.md` with:
|
||||
|
||||
- System design principles
|
||||
- Implementation examples
|
||||
- Configuration best practices
|
||||
- Deployment strategies
|
||||
- Monitoring and observability
|
||||
|
||||
## Production Patterns
|
||||
|
||||
### Pattern 1: Scalable Data Processing
|
||||
|
||||
Enterprise-scale data processing with distributed computing:
|
||||
|
||||
- Horizontal scaling architecture
|
||||
- Fault-tolerant design
|
||||
- Real-time and batch processing
|
||||
- Data quality validation
|
||||
- Performance monitoring
|
||||
|
||||
### Pattern 2: ML Model Deployment
|
||||
|
||||
Production ML system with high availability:
|
||||
|
||||
- Model serving with low latency
|
||||
- A/B testing infrastructure
|
||||
- Feature store integration
|
||||
- Model monitoring and drift detection
|
||||
- Automated retraining pipelines
|
||||
|
||||
### Pattern 3: Real-Time Inference
|
||||
|
||||
High-throughput inference system:
|
||||
|
||||
- Batching and caching strategies
|
||||
- Load balancing
|
||||
- Auto-scaling
|
||||
- Latency optimization
|
||||
- Cost optimization
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Development
|
||||
|
||||
- Test-driven development
|
||||
- Code reviews and pair programming
|
||||
- Documentation as code
|
||||
- Version control everything
|
||||
- Continuous integration
|
||||
|
||||
### Production
|
||||
|
||||
- Monitor everything critical
|
||||
- Automate deployments
|
||||
- Feature flags for releases
|
||||
- Canary deployments
|
||||
- Comprehensive logging
|
||||
|
||||
### Team Leadership
|
||||
|
||||
- Mentor junior engineers
|
||||
- Drive technical decisions
|
||||
- Establish coding standards
|
||||
- Foster learning culture
|
||||
- Cross-functional collaboration
|
||||
|
||||
## Performance Targets
|
||||
|
||||
**Latency:**
|
||||
- P50: < 50ms
|
||||
- P95: < 100ms
|
||||
- P99: < 200ms
|
||||
|
||||
**Throughput:**
|
||||
- Requests/second: > 1000
|
||||
- Concurrent users: > 10,000
|
||||
|
||||
**Availability:**
|
||||
- Uptime: 99.9%
|
||||
- Error rate: < 0.1%
|
||||
|
||||
## Security & Compliance
|
||||
|
||||
- Authentication & authorization
|
||||
- Data encryption (at rest & in transit)
|
||||
- PII handling and anonymization
|
||||
- GDPR/CCPA compliance
|
||||
- Regular security audits
|
||||
- Vulnerability management
|
||||
|
||||
## Common Commands
|
||||
|
||||
```bash
|
||||
# Development
|
||||
python -m pytest tests/ -v --cov
|
||||
python -m black src/
|
||||
python -m pylint src/
|
||||
|
||||
# Training
|
||||
python scripts/train.py --config prod.yaml
|
||||
python scripts/evaluate.py --model best.pth
|
||||
|
||||
# Deployment
|
||||
docker build -t service:v1 .
|
||||
kubectl apply -f k8s/
|
||||
helm upgrade service ./charts/
|
||||
|
||||
# Monitoring
|
||||
kubectl logs -f deployment/service
|
||||
python scripts/health_check.py
|
||||
```
|
||||
|
||||
## Resources
|
||||
|
||||
- Advanced Patterns: `references/statistical_methods_advanced.md`
|
||||
- Implementation Guide: `references/experiment_design_frameworks.md`
|
||||
- Technical Reference: `references/feature_engineering_patterns.md`
|
||||
- Automation Scripts: `scripts/` directory
|
||||
|
||||
## Senior-Level Responsibilities
|
||||
|
||||
As a world-class senior professional:
|
||||
|
||||
1. **Technical Leadership**
|
||||
- Drive architectural decisions
|
||||
- Mentor team members
|
||||
- Establish best practices
|
||||
- Ensure code quality
|
||||
|
||||
2. **Strategic Thinking**
|
||||
- Align with business goals
|
||||
- Evaluate trade-offs
|
||||
- Plan for scale
|
||||
- Manage technical debt
|
||||
|
||||
3. **Collaboration**
|
||||
- Work across teams
|
||||
- Communicate effectively
|
||||
- Build consensus
|
||||
- Share knowledge
|
||||
|
||||
4. **Innovation**
|
||||
- Stay current with research
|
||||
- Experiment with new approaches
|
||||
- Contribute to community
|
||||
- Drive continuous improvement
|
||||
|
||||
5. **Production Excellence**
|
||||
- Ensure high availability
|
||||
- Monitor proactively
|
||||
- Optimize performance
|
||||
- Respond to incidents
|
||||
216
docs/skills/engineering-team/senior-devops.md
Normal file
216
docs/skills/engineering-team/senior-devops.md
Normal file
@@ -0,0 +1,216 @@
|
||||
---
|
||||
title: "Senior Devops"
|
||||
description: "Senior Devops - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior Devops
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-devops` | **Source:** [`engineering-team/senior-devops/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-devops/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior Devops
|
||||
|
||||
Complete toolkit for senior devops with modern tools and best practices.
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Main Capabilities
|
||||
|
||||
This skill provides three core capabilities through automated scripts:
|
||||
|
||||
```bash
|
||||
# Script 1: Pipeline Generator
|
||||
python scripts/pipeline_generator.py [options]
|
||||
|
||||
# Script 2: Terraform Scaffolder
|
||||
python scripts/terraform_scaffolder.py [options]
|
||||
|
||||
# Script 3: Deployment Manager
|
||||
python scripts/deployment_manager.py [options]
|
||||
```
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
### 1. Pipeline Generator
|
||||
|
||||
Automated tool for pipeline generator tasks.
|
||||
|
||||
**Features:**
|
||||
- Automated scaffolding
|
||||
- Best practices built-in
|
||||
- Configurable templates
|
||||
- Quality checks
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
python scripts/pipeline_generator.py <project-path> [options]
|
||||
```
|
||||
|
||||
### 2. Terraform Scaffolder
|
||||
|
||||
Comprehensive analysis and optimization tool.
|
||||
|
||||
**Features:**
|
||||
- Deep analysis
|
||||
- Performance metrics
|
||||
- Recommendations
|
||||
- Automated fixes
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
python scripts/terraform_scaffolder.py <target-path> [--verbose]
|
||||
```
|
||||
|
||||
### 3. Deployment Manager
|
||||
|
||||
Advanced tooling for specialized tasks.
|
||||
|
||||
**Features:**
|
||||
- Expert-level automation
|
||||
- Custom configurations
|
||||
- Integration ready
|
||||
- Production-grade output
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
python scripts/deployment_manager.py [arguments] [options]
|
||||
```
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
### Cicd Pipeline Guide
|
||||
|
||||
Comprehensive guide available in `references/cicd_pipeline_guide.md`:
|
||||
|
||||
- Detailed patterns and practices
|
||||
- Code examples
|
||||
- Best practices
|
||||
- Anti-patterns to avoid
|
||||
- Real-world scenarios
|
||||
|
||||
### Infrastructure As Code
|
||||
|
||||
Complete workflow documentation in `references/infrastructure_as_code.md`:
|
||||
|
||||
- Step-by-step processes
|
||||
- Optimization strategies
|
||||
- Tool integrations
|
||||
- Performance tuning
|
||||
- Troubleshooting guide
|
||||
|
||||
### Deployment Strategies
|
||||
|
||||
Technical reference guide in `references/deployment_strategies.md`:
|
||||
|
||||
- Technology stack details
|
||||
- Configuration examples
|
||||
- Integration patterns
|
||||
- Security considerations
|
||||
- Scalability guidelines
|
||||
|
||||
## Tech Stack
|
||||
|
||||
**Languages:** TypeScript, JavaScript, Python, Go, Swift, Kotlin
|
||||
**Frontend:** React, Next.js, React Native, Flutter
|
||||
**Backend:** Node.js, Express, GraphQL, REST APIs
|
||||
**Database:** PostgreSQL, Prisma, NeonDB, Supabase
|
||||
**DevOps:** Docker, Kubernetes, Terraform, GitHub Actions, CircleCI
|
||||
**Cloud:** AWS, GCP, Azure
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### 1. Setup and Configuration
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
npm install
|
||||
# or
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Configure environment
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
### 2. Run Quality Checks
|
||||
|
||||
```bash
|
||||
# Use the analyzer script
|
||||
python scripts/terraform_scaffolder.py .
|
||||
|
||||
# Review recommendations
|
||||
# Apply fixes
|
||||
```
|
||||
|
||||
### 3. Implement Best Practices
|
||||
|
||||
Follow the patterns and practices documented in:
|
||||
- `references/cicd_pipeline_guide.md`
|
||||
- `references/infrastructure_as_code.md`
|
||||
- `references/deployment_strategies.md`
|
||||
|
||||
## Best Practices Summary
|
||||
|
||||
### Code Quality
|
||||
- Follow established patterns
|
||||
- Write comprehensive tests
|
||||
- Document decisions
|
||||
- Review regularly
|
||||
|
||||
### Performance
|
||||
- Measure before optimizing
|
||||
- Use appropriate caching
|
||||
- Optimize critical paths
|
||||
- Monitor in production
|
||||
|
||||
### Security
|
||||
- Validate all inputs
|
||||
- Use parameterized queries
|
||||
- Implement proper authentication
|
||||
- Keep dependencies updated
|
||||
|
||||
### Maintainability
|
||||
- Write clear code
|
||||
- Use consistent naming
|
||||
- Add helpful comments
|
||||
- Keep it simple
|
||||
|
||||
## Common Commands
|
||||
|
||||
```bash
|
||||
# Development
|
||||
npm run dev
|
||||
npm run build
|
||||
npm run test
|
||||
npm run lint
|
||||
|
||||
# Analysis
|
||||
python scripts/terraform_scaffolder.py .
|
||||
python scripts/deployment_manager.py --analyze
|
||||
|
||||
# Deployment
|
||||
docker build -t app:latest .
|
||||
docker-compose up -d
|
||||
kubectl apply -f k8s/
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
Check the comprehensive troubleshooting section in `references/deployment_strategies.md`.
|
||||
|
||||
### Getting Help
|
||||
|
||||
- Review reference documentation
|
||||
- Check script output messages
|
||||
- Consult tech stack documentation
|
||||
- Review error logs
|
||||
|
||||
## Resources
|
||||
|
||||
- Pattern Reference: `references/cicd_pipeline_guide.md`
|
||||
- Workflow Guide: `references/infrastructure_as_code.md`
|
||||
- Technical Guide: `references/deployment_strategies.md`
|
||||
- Tool Scripts: `scripts/` directory
|
||||
480
docs/skills/engineering-team/senior-frontend.md
Normal file
480
docs/skills/engineering-team/senior-frontend.md
Normal file
@@ -0,0 +1,480 @@
|
||||
---
|
||||
title: "Senior Frontend"
|
||||
description: "Senior Frontend - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior Frontend
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-frontend` | **Source:** [`engineering-team/senior-frontend/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-frontend/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior Frontend
|
||||
|
||||
Frontend development patterns, performance optimization, and automation tools for React/Next.js applications.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Project Scaffolding](#project-scaffolding)
|
||||
- [Component Generation](#component-generation)
|
||||
- [Bundle Analysis](#bundle-analysis)
|
||||
- [React Patterns](#react-patterns)
|
||||
- [Next.js Optimization](#nextjs-optimization)
|
||||
- [Accessibility and Testing](#accessibility-and-testing)
|
||||
|
||||
---
|
||||
|
||||
## Project Scaffolding
|
||||
|
||||
Generate a new Next.js or React project with TypeScript, Tailwind CSS, and best practice configurations.
|
||||
|
||||
### Workflow: Create New Frontend Project
|
||||
|
||||
1. Run the scaffolder with your project name and template:
|
||||
```bash
|
||||
python scripts/frontend_scaffolder.py my-app --template nextjs
|
||||
```
|
||||
|
||||
2. Add optional features (auth, api, forms, testing, storybook):
|
||||
```bash
|
||||
python scripts/frontend_scaffolder.py dashboard --template nextjs --features auth,api
|
||||
```
|
||||
|
||||
3. Navigate to the project and install dependencies:
|
||||
```bash
|
||||
cd my-app && npm install
|
||||
```
|
||||
|
||||
4. Start the development server:
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Scaffolder Options
|
||||
|
||||
| Option | Description |
|
||||
|--------|-------------|
|
||||
| `--template nextjs` | Next.js 14+ with App Router and Server Components |
|
||||
| `--template react` | React + Vite with TypeScript |
|
||||
| `--features auth` | Add NextAuth.js authentication |
|
||||
| `--features api` | Add React Query + API client |
|
||||
| `--features forms` | Add React Hook Form + Zod validation |
|
||||
| `--features testing` | Add Vitest + Testing Library |
|
||||
| `--dry-run` | Preview files without creating them |
|
||||
|
||||
### Generated Structure (Next.js)
|
||||
|
||||
```
|
||||
my-app/
|
||||
├── app/
|
||||
│ ├── layout.tsx # Root layout with fonts
|
||||
│ ├── page.tsx # Home page
|
||||
│ ├── globals.css # Tailwind + CSS variables
|
||||
│ └── api/health/route.ts
|
||||
├── components/
|
||||
│ ├── ui/ # Button, Input, Card
|
||||
│ └── layout/ # Header, Footer, Sidebar
|
||||
├── hooks/ # useDebounce, useLocalStorage
|
||||
├── lib/ # utils (cn), constants
|
||||
├── types/ # TypeScript interfaces
|
||||
├── tailwind.config.ts
|
||||
├── next.config.js
|
||||
└── package.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Component Generation
|
||||
|
||||
Generate React components with TypeScript, tests, and Storybook stories.
|
||||
|
||||
### Workflow: Create a New Component
|
||||
|
||||
1. Generate a client component:
|
||||
```bash
|
||||
python scripts/component_generator.py Button --dir src/components/ui
|
||||
```
|
||||
|
||||
2. Generate a server component:
|
||||
```bash
|
||||
python scripts/component_generator.py ProductCard --type server
|
||||
```
|
||||
|
||||
3. Generate with test and story files:
|
||||
```bash
|
||||
python scripts/component_generator.py UserProfile --with-test --with-story
|
||||
```
|
||||
|
||||
4. Generate a custom hook:
|
||||
```bash
|
||||
python scripts/component_generator.py FormValidation --type hook
|
||||
```
|
||||
|
||||
### Generator Options
|
||||
|
||||
| Option | Description |
|
||||
|--------|-------------|
|
||||
| `--type client` | Client component with 'use client' (default) |
|
||||
| `--type server` | Async server component |
|
||||
| `--type hook` | Custom React hook |
|
||||
| `--with-test` | Include test file |
|
||||
| `--with-story` | Include Storybook story |
|
||||
| `--flat` | Create in output dir without subdirectory |
|
||||
| `--dry-run` | Preview without creating files |
|
||||
|
||||
### Generated Component Example
|
||||
|
||||
```tsx
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface ButtonProps {
|
||||
className?: string;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
export function Button({ className, children }: ButtonProps) {
|
||||
return (
|
||||
<div className={cn('', className)}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Bundle Analysis
|
||||
|
||||
Analyze package.json and project structure for bundle optimization opportunities.
|
||||
|
||||
### Workflow: Optimize Bundle Size
|
||||
|
||||
1. Run the analyzer on your project:
|
||||
```bash
|
||||
python scripts/bundle_analyzer.py /path/to/project
|
||||
```
|
||||
|
||||
2. Review the health score and issues:
|
||||
```
|
||||
Bundle Health Score: 75/100 (C)
|
||||
|
||||
HEAVY DEPENDENCIES:
|
||||
moment (290KB)
|
||||
Alternative: date-fns (12KB) or dayjs (2KB)
|
||||
|
||||
lodash (71KB)
|
||||
Alternative: lodash-es with tree-shaking
|
||||
```
|
||||
|
||||
3. Apply the recommended fixes by replacing heavy dependencies.
|
||||
|
||||
4. Re-run with verbose mode to check import patterns:
|
||||
```bash
|
||||
python scripts/bundle_analyzer.py . --verbose
|
||||
```
|
||||
|
||||
### Bundle Score Interpretation
|
||||
|
||||
| Score | Grade | Action |
|
||||
|-------|-------|--------|
|
||||
| 90-100 | A | Bundle is well-optimized |
|
||||
| 80-89 | B | Minor optimizations available |
|
||||
| 70-79 | C | Replace heavy dependencies |
|
||||
| 60-69 | D | Multiple issues need attention |
|
||||
| 0-59 | F | Critical bundle size problems |
|
||||
|
||||
### Heavy Dependencies Detected
|
||||
|
||||
The analyzer identifies these common heavy packages:
|
||||
|
||||
| Package | Size | Alternative |
|
||||
|---------|------|-------------|
|
||||
| moment | 290KB | date-fns (12KB) or dayjs (2KB) |
|
||||
| lodash | 71KB | lodash-es with tree-shaking |
|
||||
| axios | 14KB | Native fetch or ky (3KB) |
|
||||
| jquery | 87KB | Native DOM APIs |
|
||||
| @mui/material | Large | shadcn/ui or Radix UI |
|
||||
|
||||
---
|
||||
|
||||
## React Patterns
|
||||
|
||||
Reference: `references/react_patterns.md`
|
||||
|
||||
### Compound Components
|
||||
|
||||
Share state between related components:
|
||||
|
||||
```tsx
|
||||
const Tabs = ({ children }) => {
|
||||
const [active, setActive] = useState(0);
|
||||
return (
|
||||
<TabsContext.Provider value={{ active, setActive }}>
|
||||
{children}
|
||||
</TabsContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
Tabs.List = TabList;
|
||||
Tabs.Panel = TabPanel;
|
||||
|
||||
// Usage
|
||||
<Tabs>
|
||||
<Tabs.List>
|
||||
<Tabs.Tab>One</Tabs.Tab>
|
||||
<Tabs.Tab>Two</Tabs.Tab>
|
||||
</Tabs.List>
|
||||
<Tabs.Panel>Content 1</Tabs.Panel>
|
||||
<Tabs.Panel>Content 2</Tabs.Panel>
|
||||
</Tabs>
|
||||
```
|
||||
|
||||
### Custom Hooks
|
||||
|
||||
Extract reusable logic:
|
||||
|
||||
```tsx
|
||||
function useDebounce<T>(value: T, delay = 500): T {
|
||||
const [debouncedValue, setDebouncedValue] = useState(value);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setTimeout(() => setDebouncedValue(value), delay);
|
||||
return () => clearTimeout(timer);
|
||||
}, [value, delay]);
|
||||
|
||||
return debouncedValue;
|
||||
}
|
||||
|
||||
// Usage
|
||||
const debouncedSearch = useDebounce(searchTerm, 300);
|
||||
```
|
||||
|
||||
### Render Props
|
||||
|
||||
Share rendering logic:
|
||||
|
||||
```tsx
|
||||
function DataFetcher({ url, render }) {
|
||||
const [data, setData] = useState(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(url).then(r => r.json()).then(setData).finally(() => setLoading(false));
|
||||
}, [url]);
|
||||
|
||||
return render({ data, loading });
|
||||
}
|
||||
|
||||
// Usage
|
||||
<DataFetcher
|
||||
url="/api/users"
|
||||
render={({ data, loading }) =>
|
||||
loading ? <Spinner /> : <UserList users={data} />
|
||||
}
|
||||
/>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Next.js Optimization
|
||||
|
||||
Reference: `references/nextjs_optimization_guide.md`
|
||||
|
||||
### Server vs Client Components
|
||||
|
||||
Use Server Components by default. Add 'use client' only when you need:
|
||||
- Event handlers (onClick, onChange)
|
||||
- State (useState, useReducer)
|
||||
- Effects (useEffect)
|
||||
- Browser APIs
|
||||
|
||||
```tsx
|
||||
// Server Component (default) - no 'use client'
|
||||
async function ProductPage({ params }) {
|
||||
const product = await getProduct(params.id); // Server-side fetch
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>{product.name}</h1>
|
||||
<AddToCartButton productId={product.id} /> {/* Client component */}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Client Component
|
||||
'use client';
|
||||
function AddToCartButton({ productId }) {
|
||||
const [adding, setAdding] = useState(false);
|
||||
return <button onClick={() => addToCart(productId)}>Add</button>;
|
||||
}
|
||||
```
|
||||
|
||||
### Image Optimization
|
||||
|
||||
```tsx
|
||||
import Image from 'next/image';
|
||||
|
||||
// Above the fold - load immediately
|
||||
<Image
|
||||
src="/hero.jpg"
|
||||
alt="Hero"
|
||||
width={1200}
|
||||
height={600}
|
||||
priority
|
||||
/>
|
||||
|
||||
// Responsive image with fill
|
||||
<div className="relative aspect-video">
|
||||
<Image
|
||||
src="/product.jpg"
|
||||
alt="Product"
|
||||
fill
|
||||
sizes="(max-width: 768px) 100vw, 50vw"
|
||||
className="object-cover"
|
||||
/>
|
||||
</div>
|
||||
```
|
||||
|
||||
### Data Fetching Patterns
|
||||
|
||||
```tsx
|
||||
// Parallel fetching
|
||||
async function Dashboard() {
|
||||
const [user, stats] = await Promise.all([
|
||||
getUser(),
|
||||
getStats()
|
||||
]);
|
||||
return <div>...</div>;
|
||||
}
|
||||
|
||||
// Streaming with Suspense
|
||||
async function ProductPage({ params }) {
|
||||
return (
|
||||
<div>
|
||||
<ProductDetails id={params.id} />
|
||||
<Suspense fallback={<ReviewsSkeleton />}>
|
||||
<Reviews productId={params.id} />
|
||||
</Suspense>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Accessibility and Testing
|
||||
|
||||
Reference: `references/frontend_best_practices.md`
|
||||
|
||||
### Accessibility Checklist
|
||||
|
||||
1. **Semantic HTML**: Use proper elements (`<button>`, `<nav>`, `<main>`)
|
||||
2. **Keyboard Navigation**: All interactive elements focusable
|
||||
3. **ARIA Labels**: Provide labels for icons and complex widgets
|
||||
4. **Color Contrast**: Minimum 4.5:1 for normal text
|
||||
5. **Focus Indicators**: Visible focus states
|
||||
|
||||
```tsx
|
||||
// Accessible button
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Close dialog"
|
||||
onClick={onClose}
|
||||
className="focus-visible:ring-2 focus-visible:ring-blue-500"
|
||||
>
|
||||
<XIcon aria-hidden="true" />
|
||||
</button>
|
||||
|
||||
// Skip link for keyboard users
|
||||
<a href="#main-content" className="sr-only focus:not-sr-only">
|
||||
Skip to main content
|
||||
</a>
|
||||
```
|
||||
|
||||
### Testing Strategy
|
||||
|
||||
```tsx
|
||||
// Component test with React Testing Library
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
test('button triggers action on click', async () => {
|
||||
const onClick = vi.fn();
|
||||
render(<Button onClick={onClick}>Click me</Button>);
|
||||
|
||||
await userEvent.click(screen.getByRole('button'));
|
||||
expect(onClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
// Test accessibility
|
||||
test('dialog is accessible', async () => {
|
||||
render(<Dialog open={true} title="Confirm" />);
|
||||
|
||||
expect(screen.getByRole('dialog')).toBeInTheDocument();
|
||||
expect(screen.getByRole('dialog')).toHaveAttribute('aria-labelledby');
|
||||
});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### Common Next.js Config
|
||||
|
||||
```js
|
||||
// next.config.js
|
||||
const nextConfig = {
|
||||
images: {
|
||||
remotePatterns: [{ hostname: 'cdn.example.com' }],
|
||||
formats: ['image/avif', 'image/webp'],
|
||||
},
|
||||
experimental: {
|
||||
optimizePackageImports: ['lucide-react', '@heroicons/react'],
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### Tailwind CSS Utilities
|
||||
|
||||
```tsx
|
||||
// Conditional classes with cn()
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
<button className={cn(
|
||||
'px-4 py-2 rounded',
|
||||
variant === 'primary' && 'bg-blue-500 text-white',
|
||||
disabled && 'opacity-50 cursor-not-allowed'
|
||||
)} />
|
||||
```
|
||||
|
||||
### TypeScript Patterns
|
||||
|
||||
```tsx
|
||||
// Props with children
|
||||
interface CardProps {
|
||||
className?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
// Generic component
|
||||
interface ListProps<T> {
|
||||
items: T[];
|
||||
renderItem: (item: T) => React.ReactNode;
|
||||
}
|
||||
|
||||
function List<T>({ items, renderItem }: ListProps<T>) {
|
||||
return <ul>{items.map(renderItem)}</ul>;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Resources
|
||||
|
||||
- React Patterns: `references/react_patterns.md`
|
||||
- Next.js Optimization: `references/nextjs_optimization_guide.md`
|
||||
- Best Practices: `references/frontend_best_practices.md`
|
||||
292
docs/skills/engineering-team/senior-fullstack.md
Normal file
292
docs/skills/engineering-team/senior-fullstack.md
Normal file
@@ -0,0 +1,292 @@
|
||||
---
|
||||
title: "Senior Fullstack"
|
||||
description: "Senior Fullstack - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior Fullstack
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-fullstack` | **Source:** [`engineering-team/senior-fullstack/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-fullstack/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior Fullstack
|
||||
|
||||
Fullstack development skill with project scaffolding and code quality analysis tools.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Trigger Phrases](#trigger-phrases)
|
||||
- [Tools](#tools)
|
||||
- [Workflows](#workflows)
|
||||
- [Reference Guides](#reference-guides)
|
||||
|
||||
---
|
||||
|
||||
## Trigger Phrases
|
||||
|
||||
Use this skill when you hear:
|
||||
- "scaffold a new project"
|
||||
- "create a Next.js app"
|
||||
- "set up FastAPI with React"
|
||||
- "analyze code quality"
|
||||
- "check for security issues in codebase"
|
||||
- "what stack should I use"
|
||||
- "set up a fullstack project"
|
||||
- "generate project boilerplate"
|
||||
|
||||
---
|
||||
|
||||
## Tools
|
||||
|
||||
### Project Scaffolder
|
||||
|
||||
Generates fullstack project structures with boilerplate code.
|
||||
|
||||
**Supported Templates:**
|
||||
- `nextjs` - Next.js 14+ with App Router, TypeScript, Tailwind CSS
|
||||
- `fastapi-react` - FastAPI backend + React frontend + PostgreSQL
|
||||
- `mern` - MongoDB, Express, React, Node.js with TypeScript
|
||||
- `django-react` - Django REST Framework + React frontend
|
||||
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
# List available templates
|
||||
python scripts/project_scaffolder.py --list-templates
|
||||
|
||||
# Create Next.js project
|
||||
python scripts/project_scaffolder.py nextjs my-app
|
||||
|
||||
# Create FastAPI + React project
|
||||
python scripts/project_scaffolder.py fastapi-react my-api
|
||||
|
||||
# Create MERN stack project
|
||||
python scripts/project_scaffolder.py mern my-project
|
||||
|
||||
# Create Django + React project
|
||||
python scripts/project_scaffolder.py django-react my-app
|
||||
|
||||
# Specify output directory
|
||||
python scripts/project_scaffolder.py nextjs my-app --output ./projects
|
||||
|
||||
# JSON output
|
||||
python scripts/project_scaffolder.py nextjs my-app --json
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Parameter | Description |
|
||||
|-----------|-------------|
|
||||
| `template` | Template name (nextjs, fastapi-react, mern, django-react) |
|
||||
| `project_name` | Name for the new project directory |
|
||||
| `--output, -o` | Output directory (default: current directory) |
|
||||
| `--list-templates, -l` | List all available templates |
|
||||
| `--json` | Output in JSON format |
|
||||
|
||||
**Output includes:**
|
||||
- Project structure with all necessary files
|
||||
- Package configurations (package.json, requirements.txt)
|
||||
- TypeScript configuration
|
||||
- Docker and docker-compose setup
|
||||
- Environment file templates
|
||||
- Next steps for running the project
|
||||
|
||||
---
|
||||
|
||||
### Code Quality Analyzer
|
||||
|
||||
Analyzes fullstack codebases for quality issues.
|
||||
|
||||
**Analysis Categories:**
|
||||
- Security vulnerabilities (hardcoded secrets, injection risks)
|
||||
- Code complexity metrics (cyclomatic complexity, nesting depth)
|
||||
- Dependency health (outdated packages, known CVEs)
|
||||
- Test coverage estimation
|
||||
- Documentation quality
|
||||
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
# Analyze current directory
|
||||
python scripts/code_quality_analyzer.py .
|
||||
|
||||
# Analyze specific project
|
||||
python scripts/code_quality_analyzer.py /path/to/project
|
||||
|
||||
# Verbose output with detailed findings
|
||||
python scripts/code_quality_analyzer.py . --verbose
|
||||
|
||||
# JSON output
|
||||
python scripts/code_quality_analyzer.py . --json
|
||||
|
||||
# Save report to file
|
||||
python scripts/code_quality_analyzer.py . --output report.json
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Parameter | Description |
|
||||
|-----------|-------------|
|
||||
| `project_path` | Path to project directory (default: current directory) |
|
||||
| `--verbose, -v` | Show detailed findings |
|
||||
| `--json` | Output in JSON format |
|
||||
| `--output, -o` | Write report to file |
|
||||
|
||||
**Output includes:**
|
||||
- Overall score (0-100) with letter grade
|
||||
- Security issues by severity (critical, high, medium, low)
|
||||
- High complexity files
|
||||
- Vulnerable dependencies with CVE references
|
||||
- Test coverage estimate
|
||||
- Documentation completeness
|
||||
- Prioritized recommendations
|
||||
|
||||
**Sample Output:**
|
||||
|
||||
```
|
||||
============================================================
|
||||
CODE QUALITY ANALYSIS REPORT
|
||||
============================================================
|
||||
|
||||
Overall Score: 75/100 (Grade: C)
|
||||
Files Analyzed: 45
|
||||
Total Lines: 12,500
|
||||
|
||||
--- SECURITY ---
|
||||
Critical: 1
|
||||
High: 2
|
||||
Medium: 5
|
||||
|
||||
--- COMPLEXITY ---
|
||||
Average Complexity: 8.5
|
||||
High Complexity Files: 3
|
||||
|
||||
--- RECOMMENDATIONS ---
|
||||
1. [P0] SECURITY
|
||||
Issue: Potential hardcoded secret detected
|
||||
Action: Remove or secure sensitive data at line 42
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Workflows
|
||||
|
||||
### Workflow 1: Start New Project
|
||||
|
||||
1. Choose appropriate stack based on requirements (see Stack Decision Matrix)
|
||||
2. Scaffold project structure
|
||||
3. Verify scaffold: confirm `package.json` (or `requirements.txt`) exists
|
||||
4. Run initial quality check — address any P0 issues before proceeding
|
||||
5. Set up development environment
|
||||
|
||||
```bash
|
||||
# 1. Scaffold project
|
||||
python scripts/project_scaffolder.py nextjs my-saas-app
|
||||
|
||||
# 2. Verify scaffold succeeded
|
||||
ls my-saas-app/package.json
|
||||
|
||||
# 3. Navigate and install
|
||||
cd my-saas-app
|
||||
npm install
|
||||
|
||||
# 4. Configure environment
|
||||
cp .env.example .env.local
|
||||
|
||||
# 5. Run quality check
|
||||
python ../scripts/code_quality_analyzer.py .
|
||||
|
||||
# 6. Start development
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### Workflow 2: Audit Existing Codebase
|
||||
|
||||
1. Run code quality analysis
|
||||
2. Review security findings — fix all P0 (critical) issues immediately
|
||||
3. Re-run analyzer to confirm P0 issues are resolved
|
||||
4. Create tickets for P1/P2 issues
|
||||
|
||||
```bash
|
||||
# 1. Full analysis
|
||||
python scripts/code_quality_analyzer.py /path/to/project --verbose
|
||||
|
||||
# 2. Generate detailed report
|
||||
python scripts/code_quality_analyzer.py /path/to/project --json --output audit.json
|
||||
|
||||
# 3. After fixing P0 issues, re-run to verify
|
||||
python scripts/code_quality_analyzer.py /path/to/project --verbose
|
||||
```
|
||||
|
||||
### Workflow 3: Stack Selection
|
||||
|
||||
Use the tech stack guide to evaluate options:
|
||||
|
||||
1. **SEO Required?** → Next.js with SSR
|
||||
2. **API-heavy backend?** → Separate FastAPI or NestJS
|
||||
3. **Real-time features?** → Add WebSocket layer
|
||||
4. **Team expertise** → Match stack to team skills
|
||||
|
||||
See `references/tech_stack_guide.md` for detailed comparison.
|
||||
|
||||
---
|
||||
|
||||
## Reference Guides
|
||||
|
||||
### Architecture Patterns (`references/architecture_patterns.md`)
|
||||
|
||||
- Frontend component architecture (Atomic Design, Container/Presentational)
|
||||
- Backend patterns (Clean Architecture, Repository Pattern)
|
||||
- API design (REST conventions, GraphQL schema design)
|
||||
- Database patterns (connection pooling, transactions, read replicas)
|
||||
- Caching strategies (cache-aside, HTTP cache headers)
|
||||
- Authentication architecture (JWT + refresh tokens, sessions)
|
||||
|
||||
### Development Workflows (`references/development_workflows.md`)
|
||||
|
||||
- Local development setup (Docker Compose, environment config)
|
||||
- Git workflows (trunk-based, conventional commits)
|
||||
- CI/CD pipelines (GitHub Actions examples)
|
||||
- Testing strategies (unit, integration, E2E)
|
||||
- Code review process (PR templates, checklists)
|
||||
- Deployment strategies (blue-green, canary, feature flags)
|
||||
- Monitoring and observability (logging, metrics, health checks)
|
||||
|
||||
### Tech Stack Guide (`references/tech_stack_guide.md`)
|
||||
|
||||
- Frontend frameworks comparison (Next.js, React+Vite, Vue)
|
||||
- Backend frameworks (Express, Fastify, NestJS, FastAPI, Django)
|
||||
- Database selection (PostgreSQL, MongoDB, Redis)
|
||||
- ORMs (Prisma, Drizzle, SQLAlchemy)
|
||||
- Authentication solutions (Auth.js, Clerk, custom JWT)
|
||||
- Deployment platforms (Vercel, Railway, AWS)
|
||||
- Stack recommendations by use case (MVP, SaaS, Enterprise)
|
||||
|
||||
---
|
||||
|
||||
## Quick Reference
|
||||
|
||||
### Stack Decision Matrix
|
||||
|
||||
| Requirement | Recommendation |
|
||||
|-------------|---------------|
|
||||
| SEO-critical site | Next.js with SSR |
|
||||
| Internal dashboard | React + Vite |
|
||||
| API-first backend | FastAPI or Fastify |
|
||||
| Enterprise scale | NestJS + PostgreSQL |
|
||||
| Rapid prototype | Next.js API routes |
|
||||
| Document-heavy data | MongoDB |
|
||||
| Complex queries | PostgreSQL |
|
||||
|
||||
### Common Issues
|
||||
|
||||
| Issue | Solution |
|
||||
|-------|----------|
|
||||
| N+1 queries | Use DataLoader or eager loading |
|
||||
| Slow builds | Check bundle size, lazy load |
|
||||
| Auth complexity | Use Auth.js or Clerk |
|
||||
| Type errors | Enable strict mode in tsconfig |
|
||||
| CORS issues | Configure middleware properly |
|
||||
300
docs/skills/engineering-team/senior-ml-engineer.md
Normal file
300
docs/skills/engineering-team/senior-ml-engineer.md
Normal file
@@ -0,0 +1,300 @@
|
||||
---
|
||||
title: "Senior ML Engineer"
|
||||
description: "Senior ML Engineer - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior ML Engineer
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-ml-engineer` | **Source:** [`engineering-team/senior-ml-engineer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-ml-engineer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior ML Engineer
|
||||
|
||||
Production ML engineering patterns for model deployment, MLOps infrastructure, and LLM integration.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Model Deployment Workflow](#model-deployment-workflow)
|
||||
- [MLOps Pipeline Setup](#mlops-pipeline-setup)
|
||||
- [LLM Integration Workflow](#llm-integration-workflow)
|
||||
- [RAG System Implementation](#rag-system-implementation)
|
||||
- [Model Monitoring](#model-monitoring)
|
||||
- [Reference Documentation](#reference-documentation)
|
||||
- [Tools](#tools)
|
||||
|
||||
---
|
||||
|
||||
## Model Deployment Workflow
|
||||
|
||||
Deploy a trained model to production with monitoring:
|
||||
|
||||
1. Export model to standardized format (ONNX, TorchScript, SavedModel)
|
||||
2. Package model with dependencies in Docker container
|
||||
3. Deploy to staging environment
|
||||
4. Run integration tests against staging
|
||||
5. Deploy canary (5% traffic) to production
|
||||
6. Monitor latency and error rates for 1 hour
|
||||
7. Promote to full production if metrics pass
|
||||
8. **Validation:** p95 latency < 100ms, error rate < 0.1%
|
||||
|
||||
### Container Template
|
||||
|
||||
```dockerfile
|
||||
FROM python:3.11-slim
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY model/ /app/model/
|
||||
COPY src/ /app/src/
|
||||
|
||||
HEALTHCHECK CMD curl -f http://localhost:8080/health || exit 1
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["uvicorn", "src.server:app", "--host", "0.0.0.0", "--port", "8080"]
|
||||
```
|
||||
|
||||
### Serving Options
|
||||
|
||||
| Option | Latency | Throughput | Use Case |
|
||||
|--------|---------|------------|----------|
|
||||
| FastAPI + Uvicorn | Low | Medium | REST APIs, small models |
|
||||
| Triton Inference Server | Very Low | Very High | GPU inference, batching |
|
||||
| TensorFlow Serving | Low | High | TensorFlow models |
|
||||
| TorchServe | Low | High | PyTorch models |
|
||||
| Ray Serve | Medium | High | Complex pipelines, multi-model |
|
||||
|
||||
---
|
||||
|
||||
## MLOps Pipeline Setup
|
||||
|
||||
Establish automated training and deployment:
|
||||
|
||||
1. Configure feature store (Feast, Tecton) for training data
|
||||
2. Set up experiment tracking (MLflow, Weights & Biases)
|
||||
3. Create training pipeline with hyperparameter logging
|
||||
4. Register model in model registry with version metadata
|
||||
5. Configure staging deployment triggered by registry events
|
||||
6. Set up A/B testing infrastructure for model comparison
|
||||
7. Enable drift monitoring with alerting
|
||||
8. **Validation:** New models automatically evaluated against baseline
|
||||
|
||||
### Feature Store Pattern
|
||||
|
||||
```python
|
||||
from feast import Entity, Feature, FeatureView, FileSource
|
||||
|
||||
user = Entity(name="user_id", value_type=ValueType.INT64)
|
||||
|
||||
user_features = FeatureView(
|
||||
name="user_features",
|
||||
entities=["user_id"],
|
||||
ttl=timedelta(days=1),
|
||||
features=[
|
||||
Feature(name="purchase_count_30d", dtype=ValueType.INT64),
|
||||
Feature(name="avg_order_value", dtype=ValueType.FLOAT),
|
||||
],
|
||||
online=True,
|
||||
source=FileSource(path="data/user_features.parquet"),
|
||||
)
|
||||
```
|
||||
|
||||
### Retraining Triggers
|
||||
|
||||
| Trigger | Detection | Action |
|
||||
|---------|-----------|--------|
|
||||
| Scheduled | Cron (weekly/monthly) | Full retrain |
|
||||
| Performance drop | Accuracy < threshold | Immediate retrain |
|
||||
| Data drift | PSI > 0.2 | Evaluate, then retrain |
|
||||
| New data volume | X new samples | Incremental update |
|
||||
|
||||
---
|
||||
|
||||
## LLM Integration Workflow
|
||||
|
||||
Integrate LLM APIs into production applications:
|
||||
|
||||
1. Create provider abstraction layer for vendor flexibility
|
||||
2. Implement retry logic with exponential backoff
|
||||
3. Configure fallback to secondary provider
|
||||
4. Set up token counting and context truncation
|
||||
5. Add response caching for repeated queries
|
||||
6. Implement cost tracking per request
|
||||
7. Add structured output validation with Pydantic
|
||||
8. **Validation:** Response parses correctly, cost within budget
|
||||
|
||||
### Provider Abstraction
|
||||
|
||||
```python
|
||||
from abc import ABC, abstractmethod
|
||||
from tenacity import retry, stop_after_attempt, wait_exponential
|
||||
|
||||
class LLMProvider(ABC):
|
||||
@abstractmethod
|
||||
def complete(self, prompt: str, **kwargs) -> str:
|
||||
pass
|
||||
|
||||
@retry(stop=stop_after_attempt(3), wait=wait_exponential(min=1, max=10))
|
||||
def call_llm_with_retry(provider: LLMProvider, prompt: str) -> str:
|
||||
return provider.complete(prompt)
|
||||
```
|
||||
|
||||
### Cost Management
|
||||
|
||||
| Provider | Input Cost | Output Cost |
|
||||
|----------|------------|-------------|
|
||||
| GPT-4 | $0.03/1K | $0.06/1K |
|
||||
| GPT-3.5 | $0.0005/1K | $0.0015/1K |
|
||||
| Claude 3 Opus | $0.015/1K | $0.075/1K |
|
||||
| Claude 3 Haiku | $0.00025/1K | $0.00125/1K |
|
||||
|
||||
---
|
||||
|
||||
## RAG System Implementation
|
||||
|
||||
Build retrieval-augmented generation pipeline:
|
||||
|
||||
1. Choose vector database (Pinecone, Qdrant, Weaviate)
|
||||
2. Select embedding model based on quality/cost tradeoff
|
||||
3. Implement document chunking strategy
|
||||
4. Create ingestion pipeline with metadata extraction
|
||||
5. Build retrieval with query embedding
|
||||
6. Add reranking for relevance improvement
|
||||
7. Format context and send to LLM
|
||||
8. **Validation:** Response references retrieved context, no hallucinations
|
||||
|
||||
### Vector Database Selection
|
||||
|
||||
| Database | Hosting | Scale | Latency | Best For |
|
||||
|----------|---------|-------|---------|----------|
|
||||
| Pinecone | Managed | High | Low | Production, managed |
|
||||
| Qdrant | Both | High | Very Low | Performance-critical |
|
||||
| Weaviate | Both | High | Low | Hybrid search |
|
||||
| Chroma | Self-hosted | Medium | Low | Prototyping |
|
||||
| pgvector | Self-hosted | Medium | Medium | Existing Postgres |
|
||||
|
||||
### Chunking Strategies
|
||||
|
||||
| Strategy | Chunk Size | Overlap | Best For |
|
||||
|----------|------------|---------|----------|
|
||||
| Fixed | 500-1000 tokens | 50-100 | General text |
|
||||
| Sentence | 3-5 sentences | 1 sentence | Structured text |
|
||||
| Semantic | Variable | Based on meaning | Research papers |
|
||||
| Recursive | Hierarchical | Parent-child | Long documents |
|
||||
|
||||
---
|
||||
|
||||
## Model Monitoring
|
||||
|
||||
Monitor production models for drift and degradation:
|
||||
|
||||
1. Set up latency tracking (p50, p95, p99)
|
||||
2. Configure error rate alerting
|
||||
3. Implement input data drift detection
|
||||
4. Track prediction distribution shifts
|
||||
5. Log ground truth when available
|
||||
6. Compare model versions with A/B metrics
|
||||
7. Set up automated retraining triggers
|
||||
8. **Validation:** Alerts fire before user-visible degradation
|
||||
|
||||
### Drift Detection
|
||||
|
||||
```python
|
||||
from scipy.stats import ks_2samp
|
||||
|
||||
def detect_drift(reference, current, threshold=0.05):
|
||||
statistic, p_value = ks_2samp(reference, current)
|
||||
return {
|
||||
"drift_detected": p_value < threshold,
|
||||
"ks_statistic": statistic,
|
||||
"p_value": p_value
|
||||
}
|
||||
```
|
||||
|
||||
### Alert Thresholds
|
||||
|
||||
| Metric | Warning | Critical |
|
||||
|--------|---------|----------|
|
||||
| p95 latency | > 100ms | > 200ms |
|
||||
| Error rate | > 0.1% | > 1% |
|
||||
| PSI (drift) | > 0.1 | > 0.2 |
|
||||
| Accuracy drop | > 2% | > 5% |
|
||||
|
||||
---
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
### MLOps Production Patterns
|
||||
|
||||
`references/mlops_production_patterns.md` contains:
|
||||
|
||||
- Model deployment pipeline with Kubernetes manifests
|
||||
- Feature store architecture with Feast examples
|
||||
- Model monitoring with drift detection code
|
||||
- A/B testing infrastructure with traffic splitting
|
||||
- Automated retraining pipeline with MLflow
|
||||
|
||||
### LLM Integration Guide
|
||||
|
||||
`references/llm_integration_guide.md` contains:
|
||||
|
||||
- Provider abstraction layer pattern
|
||||
- Retry and fallback strategies with tenacity
|
||||
- Prompt engineering templates (few-shot, CoT)
|
||||
- Token optimization with tiktoken
|
||||
- Cost calculation and tracking
|
||||
|
||||
### RAG System Architecture
|
||||
|
||||
`references/rag_system_architecture.md` contains:
|
||||
|
||||
- RAG pipeline implementation with code
|
||||
- Vector database comparison and integration
|
||||
- Chunking strategies (fixed, semantic, recursive)
|
||||
- Embedding model selection guide
|
||||
- Hybrid search and reranking patterns
|
||||
|
||||
---
|
||||
|
||||
## Tools
|
||||
|
||||
### Model Deployment Pipeline
|
||||
|
||||
```bash
|
||||
python scripts/model_deployment_pipeline.py --model model.pkl --target staging
|
||||
```
|
||||
|
||||
Generates deployment artifacts: Dockerfile, Kubernetes manifests, health checks.
|
||||
|
||||
### RAG System Builder
|
||||
|
||||
```bash
|
||||
python scripts/rag_system_builder.py --config rag_config.yaml --analyze
|
||||
```
|
||||
|
||||
Scaffolds RAG pipeline with vector store integration and retrieval logic.
|
||||
|
||||
### ML Monitoring Suite
|
||||
|
||||
```bash
|
||||
python scripts/ml_monitoring_suite.py --config monitoring.yaml --deploy
|
||||
```
|
||||
|
||||
Sets up drift detection, alerting, and performance dashboards.
|
||||
|
||||
---
|
||||
|
||||
## Tech Stack
|
||||
|
||||
| Category | Tools |
|
||||
|----------|-------|
|
||||
| ML Frameworks | PyTorch, TensorFlow, Scikit-learn, XGBoost |
|
||||
| LLM Frameworks | LangChain, LlamaIndex, DSPy |
|
||||
| MLOps | MLflow, Weights & Biases, Kubeflow |
|
||||
| Data | Spark, Airflow, dbt, Kafka |
|
||||
| Deployment | Docker, Kubernetes, Triton |
|
||||
| Databases | PostgreSQL, BigQuery, Pinecone, Redis |
|
||||
362
docs/skills/engineering-team/senior-prompt-engineer.md
Normal file
362
docs/skills/engineering-team/senior-prompt-engineer.md
Normal file
@@ -0,0 +1,362 @@
|
||||
---
|
||||
title: "Senior Prompt Engineer"
|
||||
description: "Senior Prompt Engineer - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior Prompt Engineer
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-prompt-engineer` | **Source:** [`engineering-team/senior-prompt-engineer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-prompt-engineer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior Prompt Engineer
|
||||
|
||||
Prompt engineering patterns, LLM evaluation frameworks, and agentic system design.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Quick Start](#quick-start)
|
||||
- [Tools Overview](#tools-overview)
|
||||
- [Prompt Optimizer](#1-prompt-optimizer)
|
||||
- [RAG Evaluator](#2-rag-evaluator)
|
||||
- [Agent Orchestrator](#3-agent-orchestrator)
|
||||
- [Prompt Engineering Workflows](#prompt-engineering-workflows)
|
||||
- [Prompt Optimization Workflow](#prompt-optimization-workflow)
|
||||
- [Few-Shot Example Design](#few-shot-example-design-workflow)
|
||||
- [Structured Output Design](#structured-output-design-workflow)
|
||||
- [Reference Documentation](#reference-documentation)
|
||||
- [Common Patterns Quick Reference](#common-patterns-quick-reference)
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Analyze and optimize a prompt file
|
||||
python scripts/prompt_optimizer.py prompts/my_prompt.txt --analyze
|
||||
|
||||
# Evaluate RAG retrieval quality
|
||||
python scripts/rag_evaluator.py --contexts contexts.json --questions questions.json
|
||||
|
||||
# Visualize agent workflow from definition
|
||||
python scripts/agent_orchestrator.py agent_config.yaml --visualize
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tools Overview
|
||||
|
||||
### 1. Prompt Optimizer
|
||||
|
||||
Analyzes prompts for token efficiency, clarity, and structure. Generates optimized versions.
|
||||
|
||||
**Input:** Prompt text file or string
|
||||
**Output:** Analysis report with optimization suggestions
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Analyze a prompt file
|
||||
python scripts/prompt_optimizer.py prompt.txt --analyze
|
||||
|
||||
# Output:
|
||||
# Token count: 847
|
||||
# Estimated cost: $0.0025 (GPT-4)
|
||||
# Clarity score: 72/100
|
||||
# Issues found:
|
||||
# - Ambiguous instruction at line 3
|
||||
# - Missing output format specification
|
||||
# - Redundant context (lines 12-15 repeat lines 5-8)
|
||||
# Suggestions:
|
||||
# 1. Add explicit output format: "Respond in JSON with keys: ..."
|
||||
# 2. Remove redundant context to save 89 tokens
|
||||
# 3. Clarify "analyze" -> "list the top 3 issues with severity ratings"
|
||||
|
||||
# Generate optimized version
|
||||
python scripts/prompt_optimizer.py prompt.txt --optimize --output optimized.txt
|
||||
|
||||
# Count tokens for cost estimation
|
||||
python scripts/prompt_optimizer.py prompt.txt --tokens --model gpt-4
|
||||
|
||||
# Extract and manage few-shot examples
|
||||
python scripts/prompt_optimizer.py prompt.txt --extract-examples --output examples.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 2. RAG Evaluator
|
||||
|
||||
Evaluates Retrieval-Augmented Generation quality by measuring context relevance and answer faithfulness.
|
||||
|
||||
**Input:** Retrieved contexts (JSON) and questions/answers
|
||||
**Output:** Evaluation metrics and quality report
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Evaluate retrieval quality
|
||||
python scripts/rag_evaluator.py --contexts retrieved.json --questions eval_set.json
|
||||
|
||||
# Output:
|
||||
# === RAG Evaluation Report ===
|
||||
# Questions evaluated: 50
|
||||
#
|
||||
# Retrieval Metrics:
|
||||
# Context Relevance: 0.78 (target: >0.80)
|
||||
# Retrieval Precision@5: 0.72
|
||||
# Coverage: 0.85
|
||||
#
|
||||
# Generation Metrics:
|
||||
# Answer Faithfulness: 0.91
|
||||
# Groundedness: 0.88
|
||||
#
|
||||
# Issues Found:
|
||||
# - 8 questions had no relevant context in top-5
|
||||
# - 3 answers contained information not in context
|
||||
#
|
||||
# Recommendations:
|
||||
# 1. Improve chunking strategy for technical documents
|
||||
# 2. Add metadata filtering for date-sensitive queries
|
||||
|
||||
# Evaluate with custom metrics
|
||||
python scripts/rag_evaluator.py --contexts retrieved.json --questions eval_set.json \
|
||||
--metrics relevance,faithfulness,coverage
|
||||
|
||||
# Export detailed results
|
||||
python scripts/rag_evaluator.py --contexts retrieved.json --questions eval_set.json \
|
||||
--output report.json --verbose
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 3. Agent Orchestrator
|
||||
|
||||
Parses agent definitions and visualizes execution flows. Validates tool configurations.
|
||||
|
||||
**Input:** Agent configuration (YAML/JSON)
|
||||
**Output:** Workflow visualization, validation report
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Validate agent configuration
|
||||
python scripts/agent_orchestrator.py agent.yaml --validate
|
||||
|
||||
# Output:
|
||||
# === Agent Validation Report ===
|
||||
# Agent: research_assistant
|
||||
# Pattern: ReAct
|
||||
#
|
||||
# Tools (4 registered):
|
||||
# [OK] web_search - API key configured
|
||||
# [OK] calculator - No config needed
|
||||
# [WARN] file_reader - Missing allowed_paths
|
||||
# [OK] summarizer - Prompt template valid
|
||||
#
|
||||
# Flow Analysis:
|
||||
# Max depth: 5 iterations
|
||||
# Estimated tokens/run: 2,400-4,800
|
||||
# Potential infinite loop: No
|
||||
#
|
||||
# Recommendations:
|
||||
# 1. Add allowed_paths to file_reader for security
|
||||
# 2. Consider adding early exit condition for simple queries
|
||||
|
||||
# Visualize agent workflow (ASCII)
|
||||
python scripts/agent_orchestrator.py agent.yaml --visualize
|
||||
|
||||
# Output:
|
||||
# ┌─────────────────────────────────────────┐
|
||||
# │ research_assistant │
|
||||
# │ (ReAct Pattern) │
|
||||
# └─────────────────┬───────────────────────┘
|
||||
# │
|
||||
# ┌────────▼────────┐
|
||||
# │ User Query │
|
||||
# └────────┬────────┘
|
||||
# │
|
||||
# ┌────────▼────────┐
|
||||
# │ Think │◄──────┐
|
||||
# └────────┬────────┘ │
|
||||
# │ │
|
||||
# ┌────────▼────────┐ │
|
||||
# │ Select Tool │ │
|
||||
# └────────┬────────┘ │
|
||||
# │ │
|
||||
# ┌─────────────┼─────────────┐ │
|
||||
# ▼ ▼ ▼ │
|
||||
# [web_search] [calculator] [file_reader]
|
||||
# │ │ │ │
|
||||
# └─────────────┼─────────────┘ │
|
||||
# │ │
|
||||
# ┌────────▼────────┐ │
|
||||
# │ Observe │───────┘
|
||||
# └────────┬────────┘
|
||||
# │
|
||||
# ┌────────▼────────┐
|
||||
# │ Final Answer │
|
||||
# └─────────────────┘
|
||||
|
||||
# Export workflow as Mermaid diagram
|
||||
python scripts/agent_orchestrator.py agent.yaml --visualize --format mermaid
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Prompt Engineering Workflows
|
||||
|
||||
### Prompt Optimization Workflow
|
||||
|
||||
Use when improving an existing prompt's performance or reducing token costs.
|
||||
|
||||
**Step 1: Baseline current prompt**
|
||||
```bash
|
||||
python scripts/prompt_optimizer.py current_prompt.txt --analyze --output baseline.json
|
||||
```
|
||||
|
||||
**Step 2: Identify issues**
|
||||
Review the analysis report for:
|
||||
- Token waste (redundant instructions, verbose examples)
|
||||
- Ambiguous instructions (unclear output format, vague verbs)
|
||||
- Missing constraints (no length limits, no format specification)
|
||||
|
||||
**Step 3: Apply optimization patterns**
|
||||
| Issue | Pattern to Apply |
|
||||
|-------|------------------|
|
||||
| Ambiguous output | Add explicit format specification |
|
||||
| Too verbose | Extract to few-shot examples |
|
||||
| Inconsistent results | Add role/persona framing |
|
||||
| Missing edge cases | Add constraint boundaries |
|
||||
|
||||
**Step 4: Generate optimized version**
|
||||
```bash
|
||||
python scripts/prompt_optimizer.py current_prompt.txt --optimize --output optimized.txt
|
||||
```
|
||||
|
||||
**Step 5: Compare results**
|
||||
```bash
|
||||
python scripts/prompt_optimizer.py optimized.txt --analyze --compare baseline.json
|
||||
# Shows: token reduction, clarity improvement, issues resolved
|
||||
```
|
||||
|
||||
**Step 6: Validate with test cases**
|
||||
Run both prompts against your evaluation set and compare outputs.
|
||||
|
||||
---
|
||||
|
||||
### Few-Shot Example Design Workflow
|
||||
|
||||
Use when creating examples for in-context learning.
|
||||
|
||||
**Step 1: Define the task clearly**
|
||||
```
|
||||
Task: Extract product entities from customer reviews
|
||||
Input: Review text
|
||||
Output: JSON with {product_name, sentiment, features_mentioned}
|
||||
```
|
||||
|
||||
**Step 2: Select diverse examples (3-5 recommended)**
|
||||
| Example Type | Purpose |
|
||||
|--------------|---------|
|
||||
| Simple case | Shows basic pattern |
|
||||
| Edge case | Handles ambiguity |
|
||||
| Complex case | Multiple entities |
|
||||
| Negative case | What NOT to extract |
|
||||
|
||||
**Step 3: Format consistently**
|
||||
```
|
||||
Example 1:
|
||||
Input: "Love my new iPhone 15, the camera is amazing!"
|
||||
Output: {"product_name": "iPhone 15", "sentiment": "positive", "features_mentioned": ["camera"]}
|
||||
|
||||
Example 2:
|
||||
Input: "The laptop was okay but battery life is terrible."
|
||||
Output: {"product_name": "laptop", "sentiment": "mixed", "features_mentioned": ["battery life"]}
|
||||
```
|
||||
|
||||
**Step 4: Validate example quality**
|
||||
```bash
|
||||
python scripts/prompt_optimizer.py prompt_with_examples.txt --validate-examples
|
||||
# Checks: consistency, coverage, format alignment
|
||||
```
|
||||
|
||||
**Step 5: Test with held-out cases**
|
||||
Ensure model generalizes beyond your examples.
|
||||
|
||||
---
|
||||
|
||||
### Structured Output Design Workflow
|
||||
|
||||
Use when you need reliable JSON/XML/structured responses.
|
||||
|
||||
**Step 1: Define schema**
|
||||
```json
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"summary": {"type": "string", "maxLength": 200},
|
||||
"sentiment": {"enum": ["positive", "negative", "neutral"]},
|
||||
"confidence": {"type": "number", "minimum": 0, "maximum": 1}
|
||||
},
|
||||
"required": ["summary", "sentiment"]
|
||||
}
|
||||
```
|
||||
|
||||
**Step 2: Include schema in prompt**
|
||||
```
|
||||
Respond with JSON matching this schema:
|
||||
- summary (string, max 200 chars): Brief summary of the content
|
||||
- sentiment (enum): One of "positive", "negative", "neutral"
|
||||
- confidence (number 0-1): Your confidence in the sentiment
|
||||
```
|
||||
|
||||
**Step 3: Add format enforcement**
|
||||
```
|
||||
IMPORTANT: Respond ONLY with valid JSON. No markdown, no explanation.
|
||||
Start your response with { and end with }
|
||||
```
|
||||
|
||||
**Step 4: Validate outputs**
|
||||
```bash
|
||||
python scripts/prompt_optimizer.py structured_prompt.txt --validate-schema schema.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
| File | Contains | Load when user asks about |
|
||||
|------|----------|---------------------------|
|
||||
| `references/prompt_engineering_patterns.md` | 10 prompt patterns with input/output examples | "which pattern?", "few-shot", "chain-of-thought", "role prompting" |
|
||||
| `references/llm_evaluation_frameworks.md` | Evaluation metrics, scoring methods, A/B testing | "how to evaluate?", "measure quality", "compare prompts" |
|
||||
| `references/agentic_system_design.md` | Agent architectures (ReAct, Plan-Execute, Tool Use) | "build agent", "tool calling", "multi-agent" |
|
||||
|
||||
---
|
||||
|
||||
## Common Patterns Quick Reference
|
||||
|
||||
| Pattern | When to Use | Example |
|
||||
|---------|-------------|---------|
|
||||
| **Zero-shot** | Simple, well-defined tasks | "Classify this email as spam or not spam" |
|
||||
| **Few-shot** | Complex tasks, consistent format needed | Provide 3-5 examples before the task |
|
||||
| **Chain-of-Thought** | Reasoning, math, multi-step logic | "Think step by step..." |
|
||||
| **Role Prompting** | Expertise needed, specific perspective | "You are an expert tax accountant..." |
|
||||
| **Structured Output** | Need parseable JSON/XML | Include schema + format enforcement |
|
||||
|
||||
---
|
||||
|
||||
## Common Commands
|
||||
|
||||
```bash
|
||||
# Prompt Analysis
|
||||
python scripts/prompt_optimizer.py prompt.txt --analyze # Full analysis
|
||||
python scripts/prompt_optimizer.py prompt.txt --tokens # Token count only
|
||||
python scripts/prompt_optimizer.py prompt.txt --optimize # Generate optimized version
|
||||
|
||||
# RAG Evaluation
|
||||
python scripts/rag_evaluator.py --contexts ctx.json --questions q.json # Evaluate
|
||||
python scripts/rag_evaluator.py --contexts ctx.json --compare baseline # Compare to baseline
|
||||
|
||||
# Agent Development
|
||||
python scripts/agent_orchestrator.py agent.yaml --validate # Validate config
|
||||
python scripts/agent_orchestrator.py agent.yaml --visualize # Show workflow
|
||||
python scripts/agent_orchestrator.py agent.yaml --estimate-cost # Token estimation
|
||||
```
|
||||
402
docs/skills/engineering-team/senior-qa.md
Normal file
402
docs/skills/engineering-team/senior-qa.md
Normal file
@@ -0,0 +1,402 @@
|
||||
---
|
||||
title: "Senior QA Engineer"
|
||||
description: "Senior QA Engineer - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior QA Engineer
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-qa` | **Source:** [`engineering-team/senior-qa/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-qa/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior QA Engineer
|
||||
|
||||
Test automation, coverage analysis, and quality assurance patterns for React and Next.js applications.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Quick Start](#quick-start)
|
||||
- [Tools Overview](#tools-overview)
|
||||
- [Test Suite Generator](#1-test-suite-generator)
|
||||
- [Coverage Analyzer](#2-coverage-analyzer)
|
||||
- [E2E Test Scaffolder](#3-e2e-test-scaffolder)
|
||||
- [QA Workflows](#qa-workflows)
|
||||
- [Unit Test Generation Workflow](#unit-test-generation-workflow)
|
||||
- [Coverage Analysis Workflow](#coverage-analysis-workflow)
|
||||
- [E2E Test Setup Workflow](#e2e-test-setup-workflow)
|
||||
- [Reference Documentation](#reference-documentation)
|
||||
- [Common Patterns Quick Reference](#common-patterns-quick-reference)
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Generate Jest test stubs for React components
|
||||
python scripts/test_suite_generator.py src/components/ --output __tests__/
|
||||
|
||||
# Analyze test coverage from Jest/Istanbul reports
|
||||
python scripts/coverage_analyzer.py coverage/coverage-final.json --threshold 80
|
||||
|
||||
# Scaffold Playwright E2E tests for Next.js routes
|
||||
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tools Overview
|
||||
|
||||
### 1. Test Suite Generator
|
||||
|
||||
Scans React/TypeScript components and generates Jest + React Testing Library test stubs with proper structure.
|
||||
|
||||
**Input:** Source directory containing React components
|
||||
**Output:** Test files with describe blocks, render tests, interaction tests
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Basic usage - scan components and generate tests
|
||||
python scripts/test_suite_generator.py src/components/ --output __tests__/
|
||||
|
||||
# Output:
|
||||
# Scanning: src/components/
|
||||
# Found 24 React components
|
||||
#
|
||||
# Generated tests:
|
||||
# __tests__/Button.test.tsx (render, click handler, disabled state)
|
||||
# __tests__/Modal.test.tsx (render, open/close, keyboard events)
|
||||
# __tests__/Form.test.tsx (render, validation, submission)
|
||||
# ...
|
||||
#
|
||||
# Summary: 24 test files, 87 test cases
|
||||
|
||||
# Include accessibility tests
|
||||
python scripts/test_suite_generator.py src/ --output __tests__/ --include-a11y
|
||||
|
||||
# Generate with custom template
|
||||
python scripts/test_suite_generator.py src/ --template custom-template.tsx
|
||||
```
|
||||
|
||||
**Supported Patterns:**
|
||||
- Functional components with hooks
|
||||
- Components with Context providers
|
||||
- Components with data fetching
|
||||
- Form components with validation
|
||||
|
||||
---
|
||||
|
||||
### 2. Coverage Analyzer
|
||||
|
||||
Parses Jest/Istanbul coverage reports and identifies gaps, uncovered branches, and provides actionable recommendations.
|
||||
|
||||
**Input:** Coverage report (JSON or LCOV format)
|
||||
**Output:** Coverage analysis with recommendations
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Analyze coverage report
|
||||
python scripts/coverage_analyzer.py coverage/coverage-final.json
|
||||
|
||||
# Output:
|
||||
# === Coverage Analysis Report ===
|
||||
# Overall: 72.4% (target: 80%)
|
||||
#
|
||||
# BY TYPE:
|
||||
# Statements: 74.2%
|
||||
# Branches: 68.1%
|
||||
# Functions: 71.8%
|
||||
# Lines: 73.5%
|
||||
#
|
||||
# CRITICAL GAPS (uncovered business logic):
|
||||
# src/services/payment.ts:45-67 - Payment processing
|
||||
# src/hooks/useAuth.ts:23-41 - Authentication flow
|
||||
#
|
||||
# RECOMMENDATIONS:
|
||||
# 1. Add tests for payment service error handling
|
||||
# 2. Cover authentication edge cases
|
||||
# 3. Test form validation branches
|
||||
#
|
||||
# Files below threshold (80%):
|
||||
# src/components/Checkout.tsx: 45%
|
||||
# src/services/api.ts: 62%
|
||||
|
||||
# Enforce threshold (exit 1 if below)
|
||||
python scripts/coverage_analyzer.py coverage/ --threshold 80 --strict
|
||||
|
||||
# Generate HTML report
|
||||
python scripts/coverage_analyzer.py coverage/ --format html --output report.html
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 3. E2E Test Scaffolder
|
||||
|
||||
Scans Next.js pages/app directory and generates Playwright test files with common interactions.
|
||||
|
||||
**Input:** Next.js pages or app directory
|
||||
**Output:** Playwright test files organized by route
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Scaffold E2E tests for Next.js App Router
|
||||
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/
|
||||
|
||||
# Output:
|
||||
# Scanning: src/app/
|
||||
# Found 12 routes
|
||||
#
|
||||
# Generated E2E tests:
|
||||
# e2e/home.spec.ts (navigation, hero section)
|
||||
# e2e/auth/login.spec.ts (form submission, validation)
|
||||
# e2e/auth/register.spec.ts (registration flow)
|
||||
# e2e/dashboard.spec.ts (authenticated routes)
|
||||
# e2e/products/[id].spec.ts (dynamic routes)
|
||||
# ...
|
||||
#
|
||||
# Generated: playwright.config.ts
|
||||
# Generated: e2e/fixtures/auth.ts
|
||||
|
||||
# Include Page Object Model classes
|
||||
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/ --include-pom
|
||||
|
||||
# Generate for specific routes
|
||||
python scripts/e2e_test_scaffolder.py src/app/ --routes "/login,/dashboard,/checkout"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## QA Workflows
|
||||
|
||||
### Unit Test Generation Workflow
|
||||
|
||||
Use when setting up tests for new or existing React components.
|
||||
|
||||
**Step 1: Scan project for untested components**
|
||||
```bash
|
||||
python scripts/test_suite_generator.py src/components/ --scan-only
|
||||
```
|
||||
|
||||
**Step 2: Generate test stubs**
|
||||
```bash
|
||||
python scripts/test_suite_generator.py src/components/ --output __tests__/
|
||||
```
|
||||
|
||||
**Step 3: Review and customize generated tests**
|
||||
```typescript
|
||||
// __tests__/Button.test.tsx (generated)
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import { Button } from '../src/components/Button';
|
||||
|
||||
describe('Button', () => {
|
||||
it('renders with label', () => {
|
||||
render(<Button>Click me</Button>);
|
||||
expect(screen.getByRole('button', { name: /click me/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('calls onClick when clicked', () => {
|
||||
const handleClick = jest.fn();
|
||||
render(<Button onClick={handleClick}>Click</Button>);
|
||||
fireEvent.click(screen.getByRole('button'));
|
||||
expect(handleClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
// TODO: Add your specific test cases
|
||||
});
|
||||
```
|
||||
|
||||
**Step 4: Run tests and check coverage**
|
||||
```bash
|
||||
npm test -- --coverage
|
||||
python scripts/coverage_analyzer.py coverage/coverage-final.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Coverage Analysis Workflow
|
||||
|
||||
Use when improving test coverage or preparing for release.
|
||||
|
||||
**Step 1: Generate coverage report**
|
||||
```bash
|
||||
npm test -- --coverage --coverageReporters=json
|
||||
```
|
||||
|
||||
**Step 2: Analyze coverage gaps**
|
||||
```bash
|
||||
python scripts/coverage_analyzer.py coverage/coverage-final.json --threshold 80
|
||||
```
|
||||
|
||||
**Step 3: Identify critical paths**
|
||||
```bash
|
||||
python scripts/coverage_analyzer.py coverage/ --critical-paths
|
||||
```
|
||||
|
||||
**Step 4: Generate missing test stubs**
|
||||
```bash
|
||||
python scripts/test_suite_generator.py src/ --uncovered-only --output __tests__/
|
||||
```
|
||||
|
||||
**Step 5: Verify improvement**
|
||||
```bash
|
||||
npm test -- --coverage
|
||||
python scripts/coverage_analyzer.py coverage/ --compare previous-coverage.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### E2E Test Setup Workflow
|
||||
|
||||
Use when setting up Playwright for a Next.js project.
|
||||
|
||||
**Step 1: Initialize Playwright (if not installed)**
|
||||
```bash
|
||||
npm init playwright@latest
|
||||
```
|
||||
|
||||
**Step 2: Scaffold E2E tests from routes**
|
||||
```bash
|
||||
python scripts/e2e_test_scaffolder.py src/app/ --output e2e/
|
||||
```
|
||||
|
||||
**Step 3: Configure authentication fixtures**
|
||||
```typescript
|
||||
// e2e/fixtures/auth.ts (generated)
|
||||
import { test as base } from '@playwright/test';
|
||||
|
||||
export const test = base.extend({
|
||||
authenticatedPage: async ({ page }, use) => {
|
||||
await page.goto('/login');
|
||||
await page.fill('[name="email"]', 'test@example.com');
|
||||
await page.fill('[name="password"]', 'password');
|
||||
await page.click('button[type="submit"]');
|
||||
await page.waitForURL('/dashboard');
|
||||
await use(page);
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
**Step 4: Run E2E tests**
|
||||
```bash
|
||||
npx playwright test
|
||||
npx playwright show-report
|
||||
```
|
||||
|
||||
**Step 5: Add to CI pipeline**
|
||||
```yaml
|
||||
# .github/workflows/e2e.yml
|
||||
- name: Run E2E tests
|
||||
run: npx playwright test
|
||||
- name: Upload report
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: playwright-report
|
||||
path: playwright-report/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
| File | Contains | Use When |
|
||||
|------|----------|----------|
|
||||
| `references/testing_strategies.md` | Test pyramid, testing types, coverage targets, CI/CD integration | Designing test strategy |
|
||||
| `references/test_automation_patterns.md` | Page Object Model, mocking (MSW), fixtures, async patterns | Writing test code |
|
||||
| `references/qa_best_practices.md` | Testable code, flaky tests, debugging, quality metrics | Improving test quality |
|
||||
|
||||
---
|
||||
|
||||
## Common Patterns Quick Reference
|
||||
|
||||
### React Testing Library Queries
|
||||
|
||||
```typescript
|
||||
// Preferred (accessible)
|
||||
screen.getByRole('button', { name: /submit/i })
|
||||
screen.getByLabelText(/email/i)
|
||||
screen.getByPlaceholderText(/search/i)
|
||||
|
||||
// Fallback
|
||||
screen.getByTestId('custom-element')
|
||||
```
|
||||
|
||||
### Async Testing
|
||||
|
||||
```typescript
|
||||
// Wait for element
|
||||
await screen.findByText(/loaded/i);
|
||||
|
||||
// Wait for removal
|
||||
await waitForElementToBeRemoved(() => screen.queryByText(/loading/i));
|
||||
|
||||
// Wait for condition
|
||||
await waitFor(() => {
|
||||
expect(mockFn).toHaveBeenCalled();
|
||||
});
|
||||
```
|
||||
|
||||
### Mocking with MSW
|
||||
|
||||
```typescript
|
||||
import { rest } from 'msw';
|
||||
import { setupServer } from 'msw/node';
|
||||
|
||||
const server = setupServer(
|
||||
rest.get('/api/users', (req, res, ctx) => {
|
||||
return res(ctx.json([{ id: 1, name: 'John' }]));
|
||||
})
|
||||
);
|
||||
|
||||
beforeAll(() => server.listen());
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
```
|
||||
|
||||
### Playwright Locators
|
||||
|
||||
```typescript
|
||||
// Preferred
|
||||
page.getByRole('button', { name: 'Submit' })
|
||||
page.getByLabel('Email')
|
||||
page.getByText('Welcome')
|
||||
|
||||
// Chaining
|
||||
page.getByRole('listitem').filter({ hasText: 'Product' })
|
||||
```
|
||||
|
||||
### Coverage Thresholds (jest.config.js)
|
||||
|
||||
```javascript
|
||||
module.exports = {
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
branches: 80,
|
||||
functions: 80,
|
||||
lines: 80,
|
||||
statements: 80,
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common Commands
|
||||
|
||||
```bash
|
||||
# Jest
|
||||
npm test # Run all tests
|
||||
npm test -- --watch # Watch mode
|
||||
npm test -- --coverage # With coverage
|
||||
npm test -- Button.test.tsx # Single file
|
||||
|
||||
# Playwright
|
||||
npx playwright test # Run all E2E tests
|
||||
npx playwright test --ui # UI mode
|
||||
npx playwright test --debug # Debug mode
|
||||
npx playwright codegen # Generate tests
|
||||
|
||||
# Coverage
|
||||
npm test -- --coverage --coverageReporters=lcov,json
|
||||
python scripts/coverage_analyzer.py coverage/coverage-final.json
|
||||
```
|
||||
512
docs/skills/engineering-team/senior-secops.md
Normal file
512
docs/skills/engineering-team/senior-secops.md
Normal file
@@ -0,0 +1,512 @@
|
||||
---
|
||||
title: "Senior SecOps Engineer"
|
||||
description: "Senior SecOps Engineer - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior SecOps Engineer
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-secops` | **Source:** [`engineering-team/senior-secops/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-secops/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior SecOps Engineer
|
||||
|
||||
Complete toolkit for Security Operations including vulnerability management, compliance verification, secure coding practices, and security automation.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Trigger Terms](#trigger-terms)
|
||||
- [Core Capabilities](#core-capabilities)
|
||||
- [Workflows](#workflows)
|
||||
- [Tool Reference](#tool-reference)
|
||||
- [Security Standards](#security-standards)
|
||||
- [Compliance Frameworks](#compliance-frameworks)
|
||||
- [Best Practices](#best-practices)
|
||||
|
||||
---
|
||||
|
||||
## Trigger Terms
|
||||
|
||||
Use this skill when you encounter:
|
||||
|
||||
| Category | Terms |
|
||||
|----------|-------|
|
||||
| **Vulnerability Management** | CVE, CVSS, vulnerability scan, security patch, dependency audit, npm audit, pip-audit |
|
||||
| **OWASP Top 10** | injection, XSS, CSRF, broken authentication, security misconfiguration, sensitive data exposure |
|
||||
| **Compliance** | SOC 2, PCI-DSS, HIPAA, GDPR, compliance audit, security controls, access control |
|
||||
| **Secure Coding** | input validation, output encoding, parameterized queries, prepared statements, sanitization |
|
||||
| **Secrets Management** | API key, secrets vault, environment variables, HashiCorp Vault, AWS Secrets Manager |
|
||||
| **Authentication** | JWT, OAuth, MFA, 2FA, TOTP, password hashing, bcrypt, argon2, session management |
|
||||
| **Security Testing** | SAST, DAST, penetration test, security scan, Snyk, Semgrep, CodeQL, Trivy |
|
||||
| **Incident Response** | security incident, breach notification, incident response, forensics, containment |
|
||||
| **Network Security** | TLS, HTTPS, HSTS, CSP, CORS, security headers, firewall rules, WAF |
|
||||
| **Infrastructure Security** | container security, Kubernetes security, IAM, least privilege, zero trust |
|
||||
| **Cryptography** | encryption at rest, encryption in transit, AES-256, RSA, key management, KMS |
|
||||
| **Monitoring** | security monitoring, SIEM, audit logging, intrusion detection, anomaly detection |
|
||||
|
||||
---
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
### 1. Security Scanner
|
||||
|
||||
Scan source code for security vulnerabilities including hardcoded secrets, SQL injection, XSS, command injection, and path traversal.
|
||||
|
||||
```bash
|
||||
# Scan project for security issues
|
||||
python scripts/security_scanner.py /path/to/project
|
||||
|
||||
# Filter by severity
|
||||
python scripts/security_scanner.py /path/to/project --severity high
|
||||
|
||||
# JSON output for CI/CD
|
||||
python scripts/security_scanner.py /path/to/project --json --output report.json
|
||||
```
|
||||
|
||||
**Detects:**
|
||||
- Hardcoded secrets (API keys, passwords, AWS credentials, GitHub tokens, private keys)
|
||||
- SQL injection patterns (string concatenation, f-strings, template literals)
|
||||
- XSS vulnerabilities (innerHTML assignment, unsafe DOM manipulation, React unsafe patterns)
|
||||
- Command injection (shell=True, exec, eval with user input)
|
||||
- Path traversal (file operations with user input)
|
||||
|
||||
### 2. Vulnerability Assessor
|
||||
|
||||
Scan dependencies for known CVEs across npm, Python, and Go ecosystems.
|
||||
|
||||
```bash
|
||||
# Assess project dependencies
|
||||
python scripts/vulnerability_assessor.py /path/to/project
|
||||
|
||||
# Critical/high only
|
||||
python scripts/vulnerability_assessor.py /path/to/project --severity high
|
||||
|
||||
# Export vulnerability report
|
||||
python scripts/vulnerability_assessor.py /path/to/project --json --output vulns.json
|
||||
```
|
||||
|
||||
**Scans:**
|
||||
- `package.json` and `package-lock.json` (npm)
|
||||
- `requirements.txt` and `pyproject.toml` (Python)
|
||||
- `go.mod` (Go)
|
||||
|
||||
**Output:**
|
||||
- CVE IDs with CVSS scores
|
||||
- Affected package versions
|
||||
- Fixed versions for remediation
|
||||
- Overall risk score (0-100)
|
||||
|
||||
### 3. Compliance Checker
|
||||
|
||||
Verify security compliance against SOC 2, PCI-DSS, HIPAA, and GDPR frameworks.
|
||||
|
||||
```bash
|
||||
# Check all frameworks
|
||||
python scripts/compliance_checker.py /path/to/project
|
||||
|
||||
# Specific framework
|
||||
python scripts/compliance_checker.py /path/to/project --framework soc2
|
||||
python scripts/compliance_checker.py /path/to/project --framework pci-dss
|
||||
python scripts/compliance_checker.py /path/to/project --framework hipaa
|
||||
python scripts/compliance_checker.py /path/to/project --framework gdpr
|
||||
|
||||
# Export compliance report
|
||||
python scripts/compliance_checker.py /path/to/project --json --output compliance.json
|
||||
```
|
||||
|
||||
**Verifies:**
|
||||
- Access control implementation
|
||||
- Encryption at rest and in transit
|
||||
- Audit logging
|
||||
- Authentication strength (MFA, password hashing)
|
||||
- Security documentation
|
||||
- CI/CD security controls
|
||||
|
||||
---
|
||||
|
||||
## Workflows
|
||||
|
||||
### Workflow 1: Security Audit
|
||||
|
||||
Complete security assessment of a codebase.
|
||||
|
||||
```bash
|
||||
# Step 1: Scan for code vulnerabilities
|
||||
python scripts/security_scanner.py . --severity medium
|
||||
|
||||
# Step 2: Check dependency vulnerabilities
|
||||
python scripts/vulnerability_assessor.py . --severity high
|
||||
|
||||
# Step 3: Verify compliance controls
|
||||
python scripts/compliance_checker.py . --framework all
|
||||
|
||||
# Step 4: Generate combined report
|
||||
python scripts/security_scanner.py . --json --output security.json
|
||||
python scripts/vulnerability_assessor.py . --json --output vulns.json
|
||||
python scripts/compliance_checker.py . --json --output compliance.json
|
||||
```
|
||||
|
||||
### Workflow 2: CI/CD Security Gate
|
||||
|
||||
Integrate security checks into deployment pipeline.
|
||||
|
||||
```yaml
|
||||
# .github/workflows/security.yml
|
||||
name: Security Scan
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main, develop]
|
||||
|
||||
jobs:
|
||||
security-scan:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Security Scanner
|
||||
run: python scripts/security_scanner.py . --severity high
|
||||
|
||||
- name: Vulnerability Assessment
|
||||
run: python scripts/vulnerability_assessor.py . --severity critical
|
||||
|
||||
- name: Compliance Check
|
||||
run: python scripts/compliance_checker.py . --framework soc2
|
||||
```
|
||||
|
||||
### Workflow 3: CVE Triage
|
||||
|
||||
Respond to a new CVE affecting your application.
|
||||
|
||||
```
|
||||
1. ASSESS (0-2 hours)
|
||||
- Identify affected systems using vulnerability_assessor.py
|
||||
- Check if CVE is being actively exploited
|
||||
- Determine CVSS environmental score for your context
|
||||
|
||||
2. PRIORITIZE
|
||||
- Critical (CVSS 9.0+, internet-facing): 24 hours
|
||||
- High (CVSS 7.0-8.9): 7 days
|
||||
- Medium (CVSS 4.0-6.9): 30 days
|
||||
- Low (CVSS < 4.0): 90 days
|
||||
|
||||
3. REMEDIATE
|
||||
- Update affected dependency to fixed version
|
||||
- Run security_scanner.py to verify fix
|
||||
- Test for regressions
|
||||
- Deploy with enhanced monitoring
|
||||
|
||||
4. VERIFY
|
||||
- Re-run vulnerability_assessor.py
|
||||
- Confirm CVE no longer reported
|
||||
- Document remediation actions
|
||||
```
|
||||
|
||||
### Workflow 4: Incident Response
|
||||
|
||||
Security incident handling procedure.
|
||||
|
||||
```
|
||||
PHASE 1: DETECT & IDENTIFY (0-15 min)
|
||||
- Alert received and acknowledged
|
||||
- Initial severity assessment (SEV-1 to SEV-4)
|
||||
- Incident commander assigned
|
||||
- Communication channel established
|
||||
|
||||
PHASE 2: CONTAIN (15-60 min)
|
||||
- Affected systems identified
|
||||
- Network isolation if needed
|
||||
- Credentials rotated if compromised
|
||||
- Preserve evidence (logs, memory dumps)
|
||||
|
||||
PHASE 3: ERADICATE (1-4 hours)
|
||||
- Root cause identified
|
||||
- Malware/backdoors removed
|
||||
- Vulnerabilities patched (run security_scanner.py)
|
||||
- Systems hardened
|
||||
|
||||
PHASE 4: RECOVER (4-24 hours)
|
||||
- Systems restored from clean backup
|
||||
- Services brought back online
|
||||
- Enhanced monitoring enabled
|
||||
- User access restored
|
||||
|
||||
PHASE 5: POST-INCIDENT (24-72 hours)
|
||||
- Incident timeline documented
|
||||
- Root cause analysis complete
|
||||
- Lessons learned documented
|
||||
- Preventive measures implemented
|
||||
- Stakeholder report delivered
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tool Reference
|
||||
|
||||
### security_scanner.py
|
||||
|
||||
| Option | Description |
|
||||
|--------|-------------|
|
||||
| `target` | Directory or file to scan |
|
||||
| `--severity, -s` | Minimum severity: critical, high, medium, low |
|
||||
| `--verbose, -v` | Show files as they're scanned |
|
||||
| `--json` | Output results as JSON |
|
||||
| `--output, -o` | Write results to file |
|
||||
|
||||
**Exit Codes:**
|
||||
- `0`: No critical/high findings
|
||||
- `1`: High severity findings
|
||||
- `2`: Critical severity findings
|
||||
|
||||
### vulnerability_assessor.py
|
||||
|
||||
| Option | Description |
|
||||
|--------|-------------|
|
||||
| `target` | Directory containing dependency files |
|
||||
| `--severity, -s` | Minimum severity: critical, high, medium, low |
|
||||
| `--verbose, -v` | Show files as they're scanned |
|
||||
| `--json` | Output results as JSON |
|
||||
| `--output, -o` | Write results to file |
|
||||
|
||||
**Exit Codes:**
|
||||
- `0`: No critical/high vulnerabilities
|
||||
- `1`: High severity vulnerabilities
|
||||
- `2`: Critical severity vulnerabilities
|
||||
|
||||
### compliance_checker.py
|
||||
|
||||
| Option | Description |
|
||||
|--------|-------------|
|
||||
| `target` | Directory to check |
|
||||
| `--framework, -f` | Framework: soc2, pci-dss, hipaa, gdpr, all |
|
||||
| `--verbose, -v` | Show checks as they run |
|
||||
| `--json` | Output results as JSON |
|
||||
| `--output, -o` | Write results to file |
|
||||
|
||||
**Exit Codes:**
|
||||
- `0`: Compliant (90%+ score)
|
||||
- `1`: Non-compliant (50-69% score)
|
||||
- `2`: Critical gaps (<50% score)
|
||||
|
||||
---
|
||||
|
||||
## Security Standards
|
||||
|
||||
### OWASP Top 10 Prevention
|
||||
|
||||
| Vulnerability | Prevention |
|
||||
|--------------|------------|
|
||||
| **A01: Broken Access Control** | Implement RBAC, deny by default, validate permissions server-side |
|
||||
| **A02: Cryptographic Failures** | Use TLS 1.2+, AES-256 encryption, secure key management |
|
||||
| **A03: Injection** | Parameterized queries, input validation, escape output |
|
||||
| **A04: Insecure Design** | Threat modeling, secure design patterns, defense in depth |
|
||||
| **A05: Security Misconfiguration** | Hardening guides, remove defaults, disable unused features |
|
||||
| **A06: Vulnerable Components** | Dependency scanning, automated updates, SBOM |
|
||||
| **A07: Authentication Failures** | MFA, rate limiting, secure password storage |
|
||||
| **A08: Data Integrity Failures** | Code signing, integrity checks, secure CI/CD |
|
||||
| **A09: Security Logging Failures** | Comprehensive audit logs, SIEM integration, alerting |
|
||||
| **A10: SSRF** | URL validation, allowlist destinations, network segmentation |
|
||||
|
||||
### Secure Coding Checklist
|
||||
|
||||
```markdown
|
||||
## Input Validation
|
||||
- [ ] Validate all input on server side
|
||||
- [ ] Use allowlists over denylists
|
||||
- [ ] Sanitize for specific context (HTML, SQL, shell)
|
||||
|
||||
## Output Encoding
|
||||
- [ ] HTML encode for browser output
|
||||
- [ ] URL encode for URLs
|
||||
- [ ] JavaScript encode for script contexts
|
||||
|
||||
## Authentication
|
||||
- [ ] Use bcrypt/argon2 for passwords
|
||||
- [ ] Implement MFA for sensitive operations
|
||||
- [ ] Enforce strong password policy
|
||||
|
||||
## Session Management
|
||||
- [ ] Generate secure random session IDs
|
||||
- [ ] Set HttpOnly, Secure, SameSite flags
|
||||
- [ ] Implement session timeout (15 min idle)
|
||||
|
||||
## Error Handling
|
||||
- [ ] Log errors with context (no secrets)
|
||||
- [ ] Return generic messages to users
|
||||
- [ ] Never expose stack traces in production
|
||||
|
||||
## Secrets Management
|
||||
- [ ] Use environment variables or secrets manager
|
||||
- [ ] Never commit secrets to version control
|
||||
- [ ] Rotate credentials regularly
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Compliance Frameworks
|
||||
|
||||
### SOC 2 Type II Controls
|
||||
|
||||
| Control | Category | Description |
|
||||
|---------|----------|-------------|
|
||||
| CC1 | Control Environment | Security policies, org structure |
|
||||
| CC2 | Communication | Security awareness, documentation |
|
||||
| CC3 | Risk Assessment | Vulnerability scanning, threat modeling |
|
||||
| CC6 | Logical Access | Authentication, authorization, MFA |
|
||||
| CC7 | System Operations | Monitoring, logging, incident response |
|
||||
| CC8 | Change Management | CI/CD, code review, deployment controls |
|
||||
|
||||
### PCI-DSS v4.0 Requirements
|
||||
|
||||
| Requirement | Description |
|
||||
|-------------|-------------|
|
||||
| Req 3 | Protect stored cardholder data (encryption at rest) |
|
||||
| Req 4 | Encrypt transmission (TLS 1.2+) |
|
||||
| Req 6 | Secure development (input validation, secure coding) |
|
||||
| Req 8 | Strong authentication (MFA, password policy) |
|
||||
| Req 10 | Audit logging (all access to cardholder data) |
|
||||
| Req 11 | Security testing (SAST, DAST, penetration testing) |
|
||||
|
||||
### HIPAA Security Rule
|
||||
|
||||
| Safeguard | Requirement |
|
||||
|-----------|-------------|
|
||||
| 164.312(a)(1) | Unique user identification for PHI access |
|
||||
| 164.312(b) | Audit trails for PHI access |
|
||||
| 164.312(c)(1) | Data integrity controls |
|
||||
| 164.312(d) | Person/entity authentication (MFA) |
|
||||
| 164.312(e)(1) | Transmission encryption (TLS) |
|
||||
|
||||
### GDPR Requirements
|
||||
|
||||
| Article | Requirement |
|
||||
|---------|-------------|
|
||||
| Art 25 | Privacy by design, data minimization |
|
||||
| Art 32 | Security measures, encryption, pseudonymization |
|
||||
| Art 33 | Breach notification (72 hours) |
|
||||
| Art 17 | Right to erasure (data deletion) |
|
||||
| Art 20 | Data portability (export capability) |
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Secrets Management
|
||||
|
||||
```python
|
||||
# BAD: Hardcoded secret
|
||||
API_KEY = "sk-1234567890abcdef"
|
||||
|
||||
# GOOD: Environment variable
|
||||
import os
|
||||
API_KEY = os.environ.get("API_KEY")
|
||||
|
||||
# BETTER: Secrets manager
|
||||
from your_vault_client import get_secret
|
||||
API_KEY = get_secret("api/key")
|
||||
```
|
||||
|
||||
### SQL Injection Prevention
|
||||
|
||||
```python
|
||||
# BAD: String concatenation
|
||||
query = f"SELECT * FROM users WHERE id = {user_id}"
|
||||
|
||||
# GOOD: Parameterized query
|
||||
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
|
||||
```
|
||||
|
||||
### XSS Prevention
|
||||
|
||||
```javascript
|
||||
// BAD: Direct innerHTML assignment is vulnerable
|
||||
// GOOD: Use textContent (auto-escaped)
|
||||
element.textContent = userInput;
|
||||
|
||||
// GOOD: Use sanitization library for HTML
|
||||
import DOMPurify from 'dompurify';
|
||||
const safeHTML = DOMPurify.sanitize(userInput);
|
||||
```
|
||||
|
||||
### Authentication
|
||||
|
||||
```javascript
|
||||
// Password hashing
|
||||
const bcrypt = require('bcrypt');
|
||||
const SALT_ROUNDS = 12;
|
||||
|
||||
// Hash password
|
||||
const hash = await bcrypt.hash(password, SALT_ROUNDS);
|
||||
|
||||
// Verify password
|
||||
const match = await bcrypt.compare(password, hash);
|
||||
```
|
||||
|
||||
### Security Headers
|
||||
|
||||
```javascript
|
||||
// Express.js security headers
|
||||
const helmet = require('helmet');
|
||||
app.use(helmet());
|
||||
|
||||
// Or manually set headers:
|
||||
app.use((req, res, next) => {
|
||||
res.setHeader('X-Content-Type-Options', 'nosniff');
|
||||
res.setHeader('X-Frame-Options', 'DENY');
|
||||
res.setHeader('X-XSS-Protection', '1; mode=block');
|
||||
res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
|
||||
res.setHeader('Content-Security-Policy', "default-src 'self'");
|
||||
next();
|
||||
});
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
| Document | Description |
|
||||
|----------|-------------|
|
||||
| `references/security_standards.md` | OWASP Top 10, secure coding, authentication, API security |
|
||||
| `references/vulnerability_management_guide.md` | CVE triage, CVSS scoring, remediation workflows |
|
||||
| `references/compliance_requirements.md` | SOC 2, PCI-DSS, HIPAA, GDPR requirements |
|
||||
|
||||
---
|
||||
|
||||
## Tech Stack
|
||||
|
||||
**Security Scanning:**
|
||||
- Snyk (dependency scanning)
|
||||
- Semgrep (SAST)
|
||||
- CodeQL (code analysis)
|
||||
- Trivy (container scanning)
|
||||
- OWASP ZAP (DAST)
|
||||
|
||||
**Secrets Management:**
|
||||
- HashiCorp Vault
|
||||
- AWS Secrets Manager
|
||||
- Azure Key Vault
|
||||
- 1Password Secrets Automation
|
||||
|
||||
**Authentication:**
|
||||
- bcrypt, argon2 (password hashing)
|
||||
- jsonwebtoken (JWT)
|
||||
- passport.js (authentication middleware)
|
||||
- speakeasy (TOTP/MFA)
|
||||
|
||||
**Logging & Monitoring:**
|
||||
- Winston, Pino (Node.js logging)
|
||||
- Datadog, Splunk (SIEM)
|
||||
- PagerDuty (alerting)
|
||||
|
||||
**Compliance:**
|
||||
- Vanta (SOC 2 automation)
|
||||
- Drata (compliance management)
|
||||
- AWS Config (configuration compliance)
|
||||
429
docs/skills/engineering-team/senior-security.md
Normal file
429
docs/skills/engineering-team/senior-security.md
Normal file
@@ -0,0 +1,429 @@
|
||||
---
|
||||
title: "Senior Security Engineer"
|
||||
description: "Senior Security Engineer - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Senior Security Engineer
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `senior-security` | **Source:** [`engineering-team/senior-security/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/senior-security/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Senior Security Engineer
|
||||
|
||||
Security engineering tools for threat modeling, vulnerability analysis, secure architecture design, and penetration testing.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Threat Modeling Workflow](#threat-modeling-workflow)
|
||||
- [Security Architecture Workflow](#security-architecture-workflow)
|
||||
- [Vulnerability Assessment Workflow](#vulnerability-assessment-workflow)
|
||||
- [Secure Code Review Workflow](#secure-code-review-workflow)
|
||||
- [Incident Response Workflow](#incident-response-workflow)
|
||||
- [Security Tools Reference](#security-tools-reference)
|
||||
- [Tools and References](#tools-and-references)
|
||||
|
||||
---
|
||||
|
||||
## Threat Modeling Workflow
|
||||
|
||||
Identify and analyze security threats using STRIDE methodology.
|
||||
|
||||
### Workflow: Conduct Threat Model
|
||||
|
||||
1. Define system scope and boundaries:
|
||||
- Identify assets to protect
|
||||
- Map trust boundaries
|
||||
- Document data flows
|
||||
2. Create data flow diagram:
|
||||
- External entities (users, services)
|
||||
- Processes (application components)
|
||||
- Data stores (databases, caches)
|
||||
- Data flows (APIs, network connections)
|
||||
3. Apply STRIDE to each DFD element:
|
||||
- Spoofing: Can identity be faked?
|
||||
- Tampering: Can data be modified?
|
||||
- Repudiation: Can actions be denied?
|
||||
- Information Disclosure: Can data leak?
|
||||
- Denial of Service: Can availability be affected?
|
||||
- Elevation of Privilege: Can access be escalated?
|
||||
4. Score risks using DREAD:
|
||||
- Damage potential (1-10)
|
||||
- Reproducibility (1-10)
|
||||
- Exploitability (1-10)
|
||||
- Affected users (1-10)
|
||||
- Discoverability (1-10)
|
||||
5. Prioritize threats by risk score
|
||||
6. Define mitigations for each threat
|
||||
7. Document in threat model report
|
||||
8. **Validation:** All DFD elements analyzed; STRIDE applied; threats scored; mitigations mapped
|
||||
|
||||
### STRIDE Threat Categories
|
||||
|
||||
| Category | Description | Security Property | Mitigation Focus |
|
||||
|----------|-------------|-------------------|------------------|
|
||||
| Spoofing | Impersonating users or systems | Authentication | MFA, certificates, strong auth |
|
||||
| Tampering | Modifying data or code | Integrity | Signing, checksums, validation |
|
||||
| Repudiation | Denying actions | Non-repudiation | Audit logs, digital signatures |
|
||||
| Information Disclosure | Exposing data | Confidentiality | Encryption, access controls |
|
||||
| Denial of Service | Disrupting availability | Availability | Rate limiting, redundancy |
|
||||
| Elevation of Privilege | Gaining unauthorized access | Authorization | RBAC, least privilege |
|
||||
|
||||
### STRIDE per Element Matrix
|
||||
|
||||
| DFD Element | S | T | R | I | D | E |
|
||||
|-------------|---|---|---|---|---|---|
|
||||
| External Entity | X | | X | | | |
|
||||
| Process | X | X | X | X | X | X |
|
||||
| Data Store | | X | X | X | X | |
|
||||
| Data Flow | | X | | X | X | |
|
||||
|
||||
See: [references/threat-modeling-guide.md](references/threat-modeling-guide.md)
|
||||
|
||||
---
|
||||
|
||||
## Security Architecture Workflow
|
||||
|
||||
Design secure systems using defense-in-depth principles.
|
||||
|
||||
### Workflow: Design Secure Architecture
|
||||
|
||||
1. Define security requirements:
|
||||
- Compliance requirements (GDPR, HIPAA, PCI-DSS)
|
||||
- Data classification (public, internal, confidential, restricted)
|
||||
- Threat model inputs
|
||||
2. Apply defense-in-depth layers:
|
||||
- Perimeter: WAF, DDoS protection, rate limiting
|
||||
- Network: Segmentation, IDS/IPS, mTLS
|
||||
- Host: Patching, EDR, hardening
|
||||
- Application: Input validation, authentication, secure coding
|
||||
- Data: Encryption at rest and in transit
|
||||
3. Implement Zero Trust principles:
|
||||
- Verify explicitly (every request)
|
||||
- Least privilege access (JIT/JEA)
|
||||
- Assume breach (segment, monitor)
|
||||
4. Configure authentication and authorization:
|
||||
- Identity provider selection
|
||||
- MFA requirements
|
||||
- RBAC/ABAC model
|
||||
5. Design encryption strategy:
|
||||
- Key management approach
|
||||
- Algorithm selection
|
||||
- Certificate lifecycle
|
||||
6. Plan security monitoring:
|
||||
- Log aggregation
|
||||
- SIEM integration
|
||||
- Alerting rules
|
||||
7. Document architecture decisions
|
||||
8. **Validation:** Defense-in-depth layers defined; Zero Trust applied; encryption strategy documented; monitoring planned
|
||||
|
||||
### Defense-in-Depth Layers
|
||||
|
||||
```
|
||||
Layer 1: PERIMETER
|
||||
WAF, DDoS mitigation, DNS filtering, rate limiting
|
||||
|
||||
Layer 2: NETWORK
|
||||
Segmentation, IDS/IPS, network monitoring, VPN, mTLS
|
||||
|
||||
Layer 3: HOST
|
||||
Endpoint protection, OS hardening, patching, logging
|
||||
|
||||
Layer 4: APPLICATION
|
||||
Input validation, authentication, secure coding, SAST
|
||||
|
||||
Layer 5: DATA
|
||||
Encryption at rest/transit, access controls, DLP, backup
|
||||
```
|
||||
|
||||
### Authentication Pattern Selection
|
||||
|
||||
| Use Case | Recommended Pattern |
|
||||
|----------|---------------------|
|
||||
| Web application | OAuth 2.0 + PKCE with OIDC |
|
||||
| API authentication | JWT with short expiration + refresh tokens |
|
||||
| Service-to-service | mTLS with certificate rotation |
|
||||
| CLI/Automation | API keys with IP allowlisting |
|
||||
| High security | FIDO2/WebAuthn hardware keys |
|
||||
|
||||
See: [references/security-architecture-patterns.md](references/security-architecture-patterns.md)
|
||||
|
||||
---
|
||||
|
||||
## Vulnerability Assessment Workflow
|
||||
|
||||
Identify and remediate security vulnerabilities in applications.
|
||||
|
||||
### Workflow: Conduct Vulnerability Assessment
|
||||
|
||||
1. Define assessment scope:
|
||||
- In-scope systems and applications
|
||||
- Testing methodology (black box, gray box, white box)
|
||||
- Rules of engagement
|
||||
2. Gather information:
|
||||
- Technology stack inventory
|
||||
- Architecture documentation
|
||||
- Previous vulnerability reports
|
||||
3. Perform automated scanning:
|
||||
- SAST (static analysis)
|
||||
- DAST (dynamic analysis)
|
||||
- Dependency scanning
|
||||
- Secret detection
|
||||
4. Conduct manual testing:
|
||||
- Business logic flaws
|
||||
- Authentication bypass
|
||||
- Authorization issues
|
||||
- Injection vulnerabilities
|
||||
5. Classify findings by severity:
|
||||
- Critical: Immediate exploitation risk
|
||||
- High: Significant impact, easier to exploit
|
||||
- Medium: Moderate impact or difficulty
|
||||
- Low: Minor impact
|
||||
6. Develop remediation plan:
|
||||
- Prioritize by risk
|
||||
- Assign owners
|
||||
- Set deadlines
|
||||
7. Verify fixes and document
|
||||
8. **Validation:** Scope defined; automated and manual testing complete; findings classified; remediation tracked
|
||||
|
||||
### OWASP Top 10 Mapping
|
||||
|
||||
| Rank | Vulnerability | Testing Approach |
|
||||
|------|---------------|------------------|
|
||||
| A01 | Broken Access Control | Manual IDOR testing, authorization checks |
|
||||
| A02 | Cryptographic Failures | Algorithm review, key management audit |
|
||||
| A03 | Injection | SAST + manual payload testing |
|
||||
| A04 | Insecure Design | Threat modeling, architecture review |
|
||||
| A05 | Security Misconfiguration | Configuration audit, CIS benchmarks |
|
||||
| A06 | Vulnerable Components | Dependency scanning, CVE monitoring |
|
||||
| A07 | Authentication Failures | Password policy, session management review |
|
||||
| A08 | Software/Data Integrity | CI/CD security, code signing verification |
|
||||
| A09 | Logging Failures | Log review, SIEM configuration check |
|
||||
| A10 | SSRF | Manual URL manipulation testing |
|
||||
|
||||
### Vulnerability Severity Matrix
|
||||
|
||||
| Impact / Exploitability | Easy | Moderate | Difficult |
|
||||
|-------------------------|------|----------|-----------|
|
||||
| Critical | Critical | Critical | High |
|
||||
| High | Critical | High | Medium |
|
||||
| Medium | High | Medium | Low |
|
||||
| Low | Medium | Low | Low |
|
||||
|
||||
---
|
||||
|
||||
## Secure Code Review Workflow
|
||||
|
||||
Review code for security vulnerabilities before deployment.
|
||||
|
||||
### Workflow: Conduct Security Code Review
|
||||
|
||||
1. Establish review scope:
|
||||
- Changed files and functions
|
||||
- Security-sensitive areas (auth, crypto, input handling)
|
||||
- Third-party integrations
|
||||
2. Run automated analysis:
|
||||
- SAST tools (Semgrep, CodeQL, Bandit)
|
||||
- Secret scanning
|
||||
- Dependency vulnerability check
|
||||
3. Review authentication code:
|
||||
- Password handling (hashing, storage)
|
||||
- Session management
|
||||
- Token validation
|
||||
4. Review authorization code:
|
||||
- Access control checks
|
||||
- RBAC implementation
|
||||
- Privilege boundaries
|
||||
5. Review data handling:
|
||||
- Input validation
|
||||
- Output encoding
|
||||
- SQL query construction
|
||||
- File path handling
|
||||
6. Review cryptographic code:
|
||||
- Algorithm selection
|
||||
- Key management
|
||||
- Random number generation
|
||||
7. Document findings with severity
|
||||
8. **Validation:** Automated scans passed; auth/authz reviewed; data handling checked; crypto verified; findings documented
|
||||
|
||||
### Security Code Review Checklist
|
||||
|
||||
| Category | Check | Risk |
|
||||
|----------|-------|------|
|
||||
| Input Validation | All user input validated and sanitized | Injection |
|
||||
| Output Encoding | Context-appropriate encoding applied | XSS |
|
||||
| Authentication | Passwords hashed with Argon2/bcrypt | Credential theft |
|
||||
| Session | Secure cookie flags set (HttpOnly, Secure, SameSite) | Session hijacking |
|
||||
| Authorization | Server-side permission checks on all endpoints | Privilege escalation |
|
||||
| SQL | Parameterized queries used exclusively | SQL injection |
|
||||
| File Access | Path traversal sequences rejected | Path traversal |
|
||||
| Secrets | No hardcoded credentials or keys | Information disclosure |
|
||||
| Dependencies | Known vulnerable packages updated | Supply chain |
|
||||
| Logging | Sensitive data not logged | Information disclosure |
|
||||
|
||||
### Secure vs Insecure Patterns
|
||||
|
||||
| Pattern | Issue | Secure Alternative |
|
||||
|---------|-------|-------------------|
|
||||
| SQL string formatting | SQL injection | Use parameterized queries with placeholders |
|
||||
| Shell command building | Command injection | Use subprocess with argument lists, no shell |
|
||||
| Path concatenation | Path traversal | Validate and canonicalize paths |
|
||||
| MD5/SHA1 for passwords | Weak hashing | Use Argon2id or bcrypt |
|
||||
| Math.random for tokens | Predictable values | Use crypto.getRandomValues |
|
||||
|
||||
---
|
||||
|
||||
## Incident Response Workflow
|
||||
|
||||
Respond to and contain security incidents.
|
||||
|
||||
### Workflow: Handle Security Incident
|
||||
|
||||
1. Identify and triage:
|
||||
- Validate incident is genuine
|
||||
- Assess initial scope and severity
|
||||
- Activate incident response team
|
||||
2. Contain the threat:
|
||||
- Isolate affected systems
|
||||
- Block malicious IPs/accounts
|
||||
- Disable compromised credentials
|
||||
3. Eradicate root cause:
|
||||
- Remove malware/backdoors
|
||||
- Patch vulnerabilities
|
||||
- Update configurations
|
||||
4. Recover operations:
|
||||
- Restore from clean backups
|
||||
- Verify system integrity
|
||||
- Monitor for recurrence
|
||||
5. Conduct post-mortem:
|
||||
- Timeline reconstruction
|
||||
- Root cause analysis
|
||||
- Lessons learned
|
||||
6. Implement improvements:
|
||||
- Update detection rules
|
||||
- Enhance controls
|
||||
- Update runbooks
|
||||
7. Document and report
|
||||
8. **Validation:** Threat contained; root cause eliminated; systems recovered; post-mortem complete; improvements implemented
|
||||
|
||||
### Incident Severity Levels
|
||||
|
||||
| Level | Description | Response Time | Escalation |
|
||||
|-------|-------------|---------------|------------|
|
||||
| P1 - Critical | Active breach, data exfiltration | Immediate | CISO, Legal, Executive |
|
||||
| P2 - High | Confirmed compromise, contained | 1 hour | Security Lead, IT Director |
|
||||
| P3 - Medium | Potential compromise, under investigation | 4 hours | Security Team |
|
||||
| P4 - Low | Suspicious activity, low impact | 24 hours | On-call engineer |
|
||||
|
||||
### Incident Response Checklist
|
||||
|
||||
| Phase | Actions |
|
||||
|-------|---------|
|
||||
| Identification | Validate alert, assess scope, determine severity |
|
||||
| Containment | Isolate systems, preserve evidence, block access |
|
||||
| Eradication | Remove threat, patch vulnerabilities, reset credentials |
|
||||
| Recovery | Restore services, verify integrity, increase monitoring |
|
||||
| Lessons Learned | Document timeline, identify gaps, update procedures |
|
||||
|
||||
---
|
||||
|
||||
## Security Tools Reference
|
||||
|
||||
### Recommended Security Tools
|
||||
|
||||
| Category | Tools |
|
||||
|----------|-------|
|
||||
| SAST | Semgrep, CodeQL, Bandit (Python), ESLint security plugins |
|
||||
| DAST | OWASP ZAP, Burp Suite, Nikto |
|
||||
| Dependency Scanning | Snyk, Dependabot, npm audit, pip-audit |
|
||||
| Secret Detection | GitLeaks, TruffleHog, detect-secrets |
|
||||
| Container Security | Trivy, Clair, Anchore |
|
||||
| Infrastructure | Checkov, tfsec, ScoutSuite |
|
||||
| Network | Wireshark, Nmap, Masscan |
|
||||
| Penetration | Metasploit, sqlmap, Burp Suite Pro |
|
||||
|
||||
### Cryptographic Algorithm Selection
|
||||
|
||||
| Use Case | Algorithm | Key Size |
|
||||
|----------|-----------|----------|
|
||||
| Symmetric encryption | AES-256-GCM | 256 bits |
|
||||
| Password hashing | Argon2id | N/A (use defaults) |
|
||||
| Message authentication | HMAC-SHA256 | 256 bits |
|
||||
| Digital signatures | Ed25519 | 256 bits |
|
||||
| Key exchange | X25519 | 256 bits |
|
||||
| TLS | TLS 1.3 | N/A |
|
||||
|
||||
See: [references/cryptography-implementation.md](references/cryptography-implementation.md)
|
||||
|
||||
---
|
||||
|
||||
## Tools and References
|
||||
|
||||
### Scripts
|
||||
|
||||
| Script | Purpose | Usage |
|
||||
|--------|---------|-------|
|
||||
| [threat_modeler.py](scripts/threat_modeler.py) | STRIDE threat analysis with risk scoring | `python threat_modeler.py --component "Authentication"` |
|
||||
| [secret_scanner.py](scripts/secret_scanner.py) | Detect hardcoded secrets and credentials | `python secret_scanner.py /path/to/project` |
|
||||
|
||||
**Threat Modeler Features:**
|
||||
- STRIDE analysis for any system component
|
||||
- DREAD risk scoring
|
||||
- Mitigation recommendations
|
||||
- JSON and text output formats
|
||||
- Interactive mode for guided analysis
|
||||
|
||||
**Secret Scanner Features:**
|
||||
- Detects AWS, GCP, Azure credentials
|
||||
- Finds API keys and tokens (GitHub, Slack, Stripe)
|
||||
- Identifies private keys and passwords
|
||||
- Supports 20+ secret patterns
|
||||
- CI/CD integration ready
|
||||
|
||||
### References
|
||||
|
||||
| Document | Content |
|
||||
|----------|---------|
|
||||
| [security-architecture-patterns.md](references/security-architecture-patterns.md) | Zero Trust, defense-in-depth, authentication patterns, API security |
|
||||
| [threat-modeling-guide.md](references/threat-modeling-guide.md) | STRIDE methodology, attack trees, DREAD scoring, DFD creation |
|
||||
| [cryptography-implementation.md](references/cryptography-implementation.md) | AES-GCM, RSA, Ed25519, password hashing, key management |
|
||||
|
||||
---
|
||||
|
||||
## Security Standards Reference
|
||||
|
||||
### Compliance Frameworks
|
||||
|
||||
| Framework | Focus | Applicable To |
|
||||
|-----------|-------|---------------|
|
||||
| OWASP ASVS | Application security | Web applications |
|
||||
| CIS Benchmarks | System hardening | Servers, containers, cloud |
|
||||
| NIST CSF | Risk management | Enterprise security programs |
|
||||
| PCI-DSS | Payment card data | Payment processing |
|
||||
| HIPAA | Healthcare data | Healthcare applications |
|
||||
| SOC 2 | Service organization controls | SaaS providers |
|
||||
|
||||
### Security Headers Checklist
|
||||
|
||||
| Header | Recommended Value |
|
||||
|--------|-------------------|
|
||||
| Content-Security-Policy | default-src self; script-src self |
|
||||
| X-Frame-Options | DENY |
|
||||
| X-Content-Type-Options | nosniff |
|
||||
| Strict-Transport-Security | max-age=31536000; includeSubDomains |
|
||||
| Referrer-Policy | strict-origin-when-cross-origin |
|
||||
| Permissions-Policy | geolocation=(), microphone=(), camera=() |
|
||||
|
||||
---
|
||||
|
||||
## Related Skills
|
||||
|
||||
| Skill | Integration Point |
|
||||
|-------|-------------------|
|
||||
| [senior-devops](../senior-devops/) | CI/CD security, infrastructure hardening |
|
||||
| [senior-secops](../senior-secops/) | Security monitoring, incident response |
|
||||
| [senior-backend](../senior-backend/) | Secure API development |
|
||||
| [senior-architect](../senior-architect/) | Security architecture decisions |
|
||||
481
docs/skills/engineering-team/stripe-integration-expert.md
Normal file
481
docs/skills/engineering-team/stripe-integration-expert.md
Normal file
@@ -0,0 +1,481 @@
|
||||
---
|
||||
title: "Stripe Integration Expert"
|
||||
description: "Stripe Integration Expert - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Stripe Integration Expert
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `stripe-integration-expert` | **Source:** [`engineering-team/stripe-integration-expert/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/stripe-integration-expert/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering Team
|
||||
**Domain:** Payments / Billing Infrastructure
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Implement production-grade Stripe integrations: subscriptions with trials and proration, one-time payments, usage-based billing, checkout sessions, idempotent webhook handlers, customer portal, and invoicing. Covers Next.js, Express, and Django patterns.
|
||||
|
||||
---
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- Subscription lifecycle management (create, upgrade, downgrade, cancel, pause)
|
||||
- Trial handling and conversion tracking
|
||||
- Proration calculation and credit application
|
||||
- Usage-based billing with metered pricing
|
||||
- Idempotent webhook handlers with signature verification
|
||||
- Customer portal integration
|
||||
- Invoice generation and PDF access
|
||||
- Full Stripe CLI local testing setup
|
||||
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
- Adding subscription billing to any web app
|
||||
- Implementing plan upgrades/downgrades with proration
|
||||
- Building usage-based or seat-based billing
|
||||
- Debugging webhook delivery failures
|
||||
- Migrating from one billing model to another
|
||||
|
||||
---
|
||||
|
||||
## Subscription Lifecycle State Machine
|
||||
|
||||
```
|
||||
FREE_TRIAL ──paid──► ACTIVE ──cancel──► CANCEL_PENDING ──period_end──► CANCELED
|
||||
│ │ │
|
||||
│ downgrade reactivate
|
||||
│ ▼ │
|
||||
│ DOWNGRADING ──period_end──► ACTIVE (lower plan) │
|
||||
│ │
|
||||
└──trial_end without payment──► PAST_DUE ──payment_failed 3x──► CANCELED
|
||||
│
|
||||
payment_success
|
||||
│
|
||||
▼
|
||||
ACTIVE
|
||||
```
|
||||
|
||||
### DB subscription status values:
|
||||
`trialing | active | past_due | canceled | cancel_pending | paused | unpaid`
|
||||
|
||||
---
|
||||
|
||||
## Stripe Client Setup
|
||||
|
||||
```typescript
|
||||
// lib/stripe.ts
|
||||
import Stripe from "stripe"
|
||||
|
||||
export const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
|
||||
apiVersion: "2024-04-10",
|
||||
typescript: true,
|
||||
appInfo: {
|
||||
name: "MyApp",
|
||||
version: "1.0.0",
|
||||
},
|
||||
})
|
||||
|
||||
// Price IDs by plan (set in env)
|
||||
export const PLANS = {
|
||||
starter: {
|
||||
monthly: process.env.STRIPE_STARTER_MONTHLY_PRICE_ID!,
|
||||
yearly: process.env.STRIPE_STARTER_YEARLY_PRICE_ID!,
|
||||
features: ["5 projects", "10k events"],
|
||||
},
|
||||
pro: {
|
||||
monthly: process.env.STRIPE_PRO_MONTHLY_PRICE_ID!,
|
||||
yearly: process.env.STRIPE_PRO_YEARLY_PRICE_ID!,
|
||||
features: ["Unlimited projects", "1M events"],
|
||||
},
|
||||
} as const
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Checkout Session (Next.js App Router)
|
||||
|
||||
```typescript
|
||||
// app/api/billing/checkout/route.ts
|
||||
import { NextResponse } from "next/server"
|
||||
import { stripe } from "@/lib/stripe"
|
||||
import { getAuthUser } from "@/lib/auth"
|
||||
import { db } from "@/lib/db"
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const user = await getAuthUser()
|
||||
if (!user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
|
||||
|
||||
const { priceId, interval = "monthly" } = await req.json()
|
||||
|
||||
// Get or create Stripe customer
|
||||
let stripeCustomerId = user.stripeCustomerId
|
||||
if (!stripeCustomerId) {
|
||||
const customer = await stripe.customers.create({
|
||||
email: user.email,
|
||||
name: user.name ?? undefined,
|
||||
metadata: { userId: user.id },
|
||||
})
|
||||
stripeCustomerId = customer.id
|
||||
await db.user.update({ where: { id: user.id }, data: { stripeCustomerId } })
|
||||
}
|
||||
|
||||
const session = await stripe.checkout.sessions.create({
|
||||
customer: stripeCustomerId,
|
||||
mode: "subscription",
|
||||
payment_method_types: ["card"],
|
||||
line_items: [{ price: priceId, quantity: 1 }],
|
||||
allow_promotion_codes: true,
|
||||
subscription_data: {
|
||||
trial_period_days: user.hasHadTrial ? undefined : 14,
|
||||
metadata: { userId: user.id },
|
||||
},
|
||||
success_url: `${process.env.NEXT_PUBLIC_APP_URL}/dashboard?session_id={CHECKOUT_SESSION_ID}`,
|
||||
cancel_url: `${process.env.NEXT_PUBLIC_APP_URL}/pricing`,
|
||||
metadata: { userId: user.id },
|
||||
})
|
||||
|
||||
return NextResponse.json({ url: session.url })
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Subscription Upgrade/Downgrade
|
||||
|
||||
```typescript
|
||||
// lib/billing.ts
|
||||
export async function changeSubscriptionPlan(
|
||||
subscriptionId: string,
|
||||
newPriceId: string,
|
||||
immediate = false
|
||||
) {
|
||||
const subscription = await stripe.subscriptions.retrieve(subscriptionId)
|
||||
const currentItem = subscription.items.data[0]
|
||||
|
||||
if (immediate) {
|
||||
// Upgrade: apply immediately with proration
|
||||
return stripe.subscriptions.update(subscriptionId, {
|
||||
items: [{ id: currentItem.id, price: newPriceId }],
|
||||
proration_behavior: "always_invoice",
|
||||
billing_cycle_anchor: "unchanged",
|
||||
})
|
||||
} else {
|
||||
// Downgrade: apply at period end, no proration
|
||||
return stripe.subscriptions.update(subscriptionId, {
|
||||
items: [{ id: currentItem.id, price: newPriceId }],
|
||||
proration_behavior: "none",
|
||||
billing_cycle_anchor: "unchanged",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Preview proration before confirming upgrade
|
||||
export async function previewProration(subscriptionId: string, newPriceId: string) {
|
||||
const subscription = await stripe.subscriptions.retrieve(subscriptionId)
|
||||
const prorationDate = Math.floor(Date.now() / 1000)
|
||||
|
||||
const invoice = await stripe.invoices.retrieveUpcoming({
|
||||
customer: subscription.customer as string,
|
||||
subscription: subscriptionId,
|
||||
subscription_items: [{ id: subscription.items.data[0].id, price: newPriceId }],
|
||||
subscription_proration_date: prorationDate,
|
||||
})
|
||||
|
||||
return {
|
||||
amountDue: invoice.amount_due,
|
||||
prorationDate,
|
||||
lineItems: invoice.lines.data,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Complete Webhook Handler (Idempotent)
|
||||
|
||||
```typescript
|
||||
// app/api/webhooks/stripe/route.ts
|
||||
import { NextResponse } from "next/server"
|
||||
import { headers } from "next/headers"
|
||||
import { stripe } from "@/lib/stripe"
|
||||
import { db } from "@/lib/db"
|
||||
import Stripe from "stripe"
|
||||
|
||||
// Processed events table to ensure idempotency
|
||||
async function hasProcessedEvent(eventId: string): Promise<boolean> {
|
||||
const existing = await db.stripeEvent.findUnique({ where: { id: eventId } })
|
||||
return !!existing
|
||||
}
|
||||
|
||||
async function markEventProcessed(eventId: string, type: string) {
|
||||
await db.stripeEvent.create({ data: { id: eventId, type, processedAt: new Date() } })
|
||||
}
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const body = await req.text()
|
||||
const signature = headers().get("stripe-signature")!
|
||||
|
||||
let event: Stripe.Event
|
||||
try {
|
||||
event = stripe.webhooks.constructEvent(body, signature, process.env.STRIPE_WEBHOOK_SECRET!)
|
||||
} catch (err) {
|
||||
console.error("Webhook signature verification failed:", err)
|
||||
return NextResponse.json({ error: "Invalid signature" }, { status: 400 })
|
||||
}
|
||||
|
||||
// Idempotency check
|
||||
if (await hasProcessedEvent(event.id)) {
|
||||
return NextResponse.json({ received: true, skipped: true })
|
||||
}
|
||||
|
||||
try {
|
||||
switch (event.type) {
|
||||
case "checkout.session.completed":
|
||||
await handleCheckoutCompleted(event.data.object as Stripe.Checkout.Session)
|
||||
break
|
||||
|
||||
case "customer.subscription.created":
|
||||
case "customer.subscription.updated":
|
||||
await handleSubscriptionUpdated(event.data.object as Stripe.Subscription)
|
||||
break
|
||||
|
||||
case "customer.subscription.deleted":
|
||||
await handleSubscriptionDeleted(event.data.object as Stripe.Subscription)
|
||||
break
|
||||
|
||||
case "invoice.payment_succeeded":
|
||||
await handleInvoicePaymentSucceeded(event.data.object as Stripe.Invoice)
|
||||
break
|
||||
|
||||
case "invoice.payment_failed":
|
||||
await handleInvoicePaymentFailed(event.data.object as Stripe.Invoice)
|
||||
break
|
||||
|
||||
default:
|
||||
console.log(`Unhandled event type: ${event.type}`)
|
||||
}
|
||||
|
||||
await markEventProcessed(event.id, event.type)
|
||||
return NextResponse.json({ received: true })
|
||||
} catch (err) {
|
||||
console.error(`Error processing webhook ${event.type}:`, err)
|
||||
// Return 500 so Stripe retries — don't mark as processed
|
||||
return NextResponse.json({ error: "Processing failed" }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCheckoutCompleted(session: Stripe.Checkout.Session) {
|
||||
if (session.mode !== "subscription") return
|
||||
|
||||
const userId = session.metadata?.userId
|
||||
if (!userId) throw new Error("No userId in checkout session metadata")
|
||||
|
||||
const subscription = await stripe.subscriptions.retrieve(session.subscription as string)
|
||||
|
||||
await db.user.update({
|
||||
where: { id: userId },
|
||||
data: {
|
||||
stripeCustomerId: session.customer as string,
|
||||
stripeSubscriptionId: subscription.id,
|
||||
stripePriceId: subscription.items.data[0].price.id,
|
||||
stripeCurrentPeriodEnd: new Date(subscription.current_period_end * 1000),
|
||||
subscriptionStatus: subscription.status,
|
||||
hasHadTrial: true,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function handleSubscriptionUpdated(subscription: Stripe.Subscription) {
|
||||
const user = await db.user.findUnique({
|
||||
where: { stripeSubscriptionId: subscription.id },
|
||||
})
|
||||
if (!user) {
|
||||
// Look up by customer ID as fallback
|
||||
const customer = await db.user.findUnique({
|
||||
where: { stripeCustomerId: subscription.customer as string },
|
||||
})
|
||||
if (!customer) throw new Error(`No user found for subscription ${subscription.id}`)
|
||||
}
|
||||
|
||||
await db.user.update({
|
||||
where: { stripeSubscriptionId: subscription.id },
|
||||
data: {
|
||||
stripePriceId: subscription.items.data[0].price.id,
|
||||
stripeCurrentPeriodEnd: new Date(subscription.current_period_end * 1000),
|
||||
subscriptionStatus: subscription.status,
|
||||
cancelAtPeriodEnd: subscription.cancel_at_period_end,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function handleSubscriptionDeleted(subscription: Stripe.Subscription) {
|
||||
await db.user.update({
|
||||
where: { stripeSubscriptionId: subscription.id },
|
||||
data: {
|
||||
stripeSubscriptionId: null,
|
||||
stripePriceId: null,
|
||||
stripeCurrentPeriodEnd: null,
|
||||
subscriptionStatus: "canceled",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function handleInvoicePaymentFailed(invoice: Stripe.Invoice) {
|
||||
if (!invoice.subscription) return
|
||||
const attemptCount = invoice.attempt_count
|
||||
|
||||
await db.user.update({
|
||||
where: { stripeSubscriptionId: invoice.subscription as string },
|
||||
data: { subscriptionStatus: "past_due" },
|
||||
})
|
||||
|
||||
if (attemptCount >= 3) {
|
||||
// Send final dunning email
|
||||
await sendDunningEmail(invoice.customer_email!, "final")
|
||||
} else {
|
||||
await sendDunningEmail(invoice.customer_email!, "retry")
|
||||
}
|
||||
}
|
||||
|
||||
async function handleInvoicePaymentSucceeded(invoice: Stripe.Invoice) {
|
||||
if (!invoice.subscription) return
|
||||
|
||||
await db.user.update({
|
||||
where: { stripeSubscriptionId: invoice.subscription as string },
|
||||
data: {
|
||||
subscriptionStatus: "active",
|
||||
stripeCurrentPeriodEnd: new Date(invoice.period_end * 1000),
|
||||
},
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage-Based Billing
|
||||
|
||||
```typescript
|
||||
// Report usage for metered subscriptions
|
||||
export async function reportUsage(subscriptionItemId: string, quantity: number) {
|
||||
await stripe.subscriptionItems.createUsageRecord(subscriptionItemId, {
|
||||
quantity,
|
||||
timestamp: Math.floor(Date.now() / 1000),
|
||||
action: "increment",
|
||||
})
|
||||
}
|
||||
|
||||
// Example: report API calls in middleware
|
||||
export async function trackApiCall(userId: string) {
|
||||
const user = await db.user.findUnique({ where: { id: userId } })
|
||||
if (user?.stripeSubscriptionId) {
|
||||
const subscription = await stripe.subscriptions.retrieve(user.stripeSubscriptionId)
|
||||
const meteredItem = subscription.items.data.find(
|
||||
(item) => item.price.recurring?.usage_type === "metered"
|
||||
)
|
||||
if (meteredItem) {
|
||||
await reportUsage(meteredItem.id, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Customer Portal
|
||||
|
||||
```typescript
|
||||
// app/api/billing/portal/route.ts
|
||||
import { NextResponse } from "next/server"
|
||||
import { stripe } from "@/lib/stripe"
|
||||
import { getAuthUser } from "@/lib/auth"
|
||||
|
||||
export async function POST() {
|
||||
const user = await getAuthUser()
|
||||
if (!user?.stripeCustomerId) {
|
||||
return NextResponse.json({ error: "No billing account" }, { status: 400 })
|
||||
}
|
||||
|
||||
const portalSession = await stripe.billingPortal.sessions.create({
|
||||
customer: user.stripeCustomerId,
|
||||
return_url: `${process.env.NEXT_PUBLIC_APP_URL}/settings/billing`,
|
||||
})
|
||||
|
||||
return NextResponse.json({ url: portalSession.url })
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Testing with Stripe CLI
|
||||
|
||||
```bash
|
||||
# Install Stripe CLI
|
||||
brew install stripe/stripe-cli/stripe
|
||||
|
||||
# Login
|
||||
stripe login
|
||||
|
||||
# Forward webhooks to local dev
|
||||
stripe listen --forward-to localhost:3000/api/webhooks/stripe
|
||||
|
||||
# Trigger specific events for testing
|
||||
stripe trigger checkout.session.completed
|
||||
stripe trigger customer.subscription.updated
|
||||
stripe trigger invoice.payment_failed
|
||||
|
||||
# Test with specific customer
|
||||
stripe trigger customer.subscription.updated \
|
||||
--override subscription:customer=cus_xxx
|
||||
|
||||
# View recent events
|
||||
stripe events list --limit 10
|
||||
|
||||
# Test cards
|
||||
# Success: 4242 4242 4242 4242
|
||||
# Requires auth: 4000 0025 0000 3155
|
||||
# Decline: 4000 0000 0000 9995
|
||||
# Insufficient funds: 4000 0000 0000 9995
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Feature Gating Helper
|
||||
|
||||
```typescript
|
||||
// lib/subscription.ts
|
||||
export function isSubscriptionActive(user: { subscriptionStatus: string | null, stripeCurrentPeriodEnd: Date | null }) {
|
||||
if (!user.subscriptionStatus) return false
|
||||
if (user.subscriptionStatus === "active" || user.subscriptionStatus === "trialing") return true
|
||||
// Grace period: past_due but not yet expired
|
||||
if (user.subscriptionStatus === "past_due" && user.stripeCurrentPeriodEnd) {
|
||||
return user.stripeCurrentPeriodEnd > new Date()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Middleware usage
|
||||
export async function requireActiveSubscription() {
|
||||
const user = await getAuthUser()
|
||||
if (!isSubscriptionActive(user)) {
|
||||
redirect("/billing?reason=subscription_required")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
- **Webhook delivery order not guaranteed** — always re-fetch from Stripe API, never trust event data alone for DB updates
|
||||
- **Double-processing webhooks** — Stripe retries on 500; always use idempotency table
|
||||
- **Trial conversion tracking** — store `hasHadTrial: true` in DB to prevent trial abuse
|
||||
- **Proration surprises** — always preview proration before upgrade; show user the amount before confirming
|
||||
- **Customer portal not configured** — must enable features in Stripe dashboard under Billing → Customer portal settings
|
||||
- **Missing metadata on checkout** — always pass `userId` in metadata; can't link subscription to user without it
|
||||
116
docs/skills/engineering-team/tdd-guide.md
Normal file
116
docs/skills/engineering-team/tdd-guide.md
Normal file
@@ -0,0 +1,116 @@
|
||||
---
|
||||
title: "TDD Guide"
|
||||
description: "TDD Guide - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# TDD Guide
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `tdd-guide` | **Source:** [`engineering-team/tdd-guide/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/tdd-guide/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# TDD Guide
|
||||
|
||||
Test-driven development skill for generating tests, analyzing coverage, and guiding red-green-refactor workflows across Jest, Pytest, JUnit, and Vitest.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Capabilities](#capabilities)
|
||||
- [Workflows](#workflows)
|
||||
- [Tools](#tools)
|
||||
- [Input Requirements](#input-requirements)
|
||||
- [Limitations](#limitations)
|
||||
|
||||
---
|
||||
|
||||
## Capabilities
|
||||
|
||||
| Capability | Description |
|
||||
|------------|-------------|
|
||||
| Test Generation | Convert requirements or code into test cases with proper structure |
|
||||
| Coverage Analysis | Parse LCOV/JSON/XML reports, identify gaps, prioritize fixes |
|
||||
| TDD Workflow | Guide red-green-refactor cycles with validation |
|
||||
| Framework Adapters | Generate tests for Jest, Pytest, JUnit, Vitest, Mocha |
|
||||
| Quality Scoring | Assess test isolation, assertions, naming, detect test smells |
|
||||
| Fixture Generation | Create realistic test data, mocks, and factories |
|
||||
|
||||
---
|
||||
|
||||
## Workflows
|
||||
|
||||
### Generate Tests from Code
|
||||
|
||||
1. Provide source code (TypeScript, JavaScript, Python, Java)
|
||||
2. Specify target framework (Jest, Pytest, JUnit, Vitest)
|
||||
3. Run `test_generator.py` with requirements
|
||||
4. Review generated test stubs
|
||||
5. **Validation:** Tests compile and cover happy path, error cases, edge cases
|
||||
|
||||
### Analyze Coverage Gaps
|
||||
|
||||
1. Generate coverage report from test runner (`npm test -- --coverage`)
|
||||
2. Run `coverage_analyzer.py` on LCOV/JSON/XML report
|
||||
3. Review prioritized gaps (P0/P1/P2)
|
||||
4. Generate missing tests for uncovered paths
|
||||
5. **Validation:** Coverage meets target threshold (typically 80%+)
|
||||
|
||||
### TDD New Feature
|
||||
|
||||
1. Write failing test first (RED)
|
||||
2. Run `tdd_workflow.py --phase red` to validate
|
||||
3. Implement minimal code to pass (GREEN)
|
||||
4. Run `tdd_workflow.py --phase green` to validate
|
||||
5. Refactor while keeping tests green (REFACTOR)
|
||||
6. **Validation:** All tests pass after each cycle
|
||||
|
||||
---
|
||||
|
||||
## Tools
|
||||
|
||||
| Tool | Purpose | Usage |
|
||||
|------|---------|-------|
|
||||
| `test_generator.py` | Generate test cases from code/requirements | `python scripts/test_generator.py --input source.py --framework pytest` |
|
||||
| `coverage_analyzer.py` | Parse and analyze coverage reports | `python scripts/coverage_analyzer.py --report lcov.info --threshold 80` |
|
||||
| `tdd_workflow.py` | Guide red-green-refactor cycles | `python scripts/tdd_workflow.py --phase red --test test_auth.py` |
|
||||
| `framework_adapter.py` | Convert tests between frameworks | `python scripts/framework_adapter.py --from jest --to pytest` |
|
||||
| `fixture_generator.py` | Generate test data and mocks | `python scripts/fixture_generator.py --entity User --count 5` |
|
||||
| `metrics_calculator.py` | Calculate test quality metrics | `python scripts/metrics_calculator.py --tests tests/` |
|
||||
| `format_detector.py` | Detect language and framework | `python scripts/format_detector.py --file source.ts` |
|
||||
| `output_formatter.py` | Format output for CLI/desktop/CI | `python scripts/output_formatter.py --format markdown` |
|
||||
|
||||
---
|
||||
|
||||
## Input Requirements
|
||||
|
||||
**For Test Generation:**
|
||||
- Source code (file path or pasted content)
|
||||
- Target framework (Jest, Pytest, JUnit, Vitest)
|
||||
- Coverage scope (unit, integration, edge cases)
|
||||
|
||||
**For Coverage Analysis:**
|
||||
- Coverage report file (LCOV, JSON, or XML format)
|
||||
- Optional: Source code for context
|
||||
- Optional: Target threshold percentage
|
||||
|
||||
**For TDD Workflow:**
|
||||
- Feature requirements or user story
|
||||
- Current phase (RED, GREEN, REFACTOR)
|
||||
- Test code and implementation status
|
||||
|
||||
---
|
||||
|
||||
## Limitations
|
||||
|
||||
| Scope | Details |
|
||||
|-------|---------|
|
||||
| Unit test focus | Integration and E2E tests require different patterns |
|
||||
| Static analysis | Cannot execute tests or measure runtime behavior |
|
||||
| Language support | Best for TypeScript, JavaScript, Python, Java |
|
||||
| Report formats | LCOV, JSON, XML only; other formats need conversion |
|
||||
| Generated tests | Provide scaffolding; require human review for complex logic |
|
||||
|
||||
**When to use other tools:**
|
||||
- E2E testing: Playwright, Cypress, Selenium
|
||||
- Performance testing: k6, JMeter, Locust
|
||||
- Security testing: OWASP ZAP, Burp Suite
|
||||
191
docs/skills/engineering-team/tech-stack-evaluator.md
Normal file
191
docs/skills/engineering-team/tech-stack-evaluator.md
Normal file
@@ -0,0 +1,191 @@
|
||||
---
|
||||
title: "Technology Stack Evaluator"
|
||||
description: "Technology Stack Evaluator - Claude Code skill from the Engineering - Core domain."
|
||||
---
|
||||
|
||||
# Technology Stack Evaluator
|
||||
|
||||
**Domain:** Engineering - Core | **Skill:** `tech-stack-evaluator` | **Source:** [`engineering-team/tech-stack-evaluator/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering-team/tech-stack-evaluator/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Technology Stack Evaluator
|
||||
|
||||
Evaluate and compare technologies, frameworks, and cloud providers with data-driven analysis and actionable recommendations.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Capabilities](#capabilities)
|
||||
- [Quick Start](#quick-start)
|
||||
- [Input Formats](#input-formats)
|
||||
- [Analysis Types](#analysis-types)
|
||||
- [Scripts](#scripts)
|
||||
- [References](#references)
|
||||
|
||||
---
|
||||
|
||||
## Capabilities
|
||||
|
||||
| Capability | Description |
|
||||
|------------|-------------|
|
||||
| Technology Comparison | Compare frameworks and libraries with weighted scoring |
|
||||
| TCO Analysis | Calculate 5-year total cost including hidden costs |
|
||||
| Ecosystem Health | Assess GitHub metrics, npm adoption, community strength |
|
||||
| Security Assessment | Evaluate vulnerabilities and compliance readiness |
|
||||
| Migration Analysis | Estimate effort, risks, and timeline for migrations |
|
||||
| Cloud Comparison | Compare AWS, Azure, GCP for specific workloads |
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Compare Two Technologies
|
||||
|
||||
```
|
||||
Compare React vs Vue for a SaaS dashboard.
|
||||
Priorities: developer productivity (40%), ecosystem (30%), performance (30%).
|
||||
```
|
||||
|
||||
### Calculate TCO
|
||||
|
||||
```
|
||||
Calculate 5-year TCO for Next.js on Vercel.
|
||||
Team: 8 developers. Hosting: $2500/month. Growth: 40%/year.
|
||||
```
|
||||
|
||||
### Assess Migration
|
||||
|
||||
```
|
||||
Evaluate migrating from Angular.js to React.
|
||||
Codebase: 50,000 lines, 200 components. Team: 6 developers.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Input Formats
|
||||
|
||||
The evaluator accepts three input formats:
|
||||
|
||||
**Text** - Natural language queries
|
||||
```
|
||||
Compare PostgreSQL vs MongoDB for our e-commerce platform.
|
||||
```
|
||||
|
||||
**YAML** - Structured input for automation
|
||||
```yaml
|
||||
comparison:
|
||||
technologies: ["React", "Vue"]
|
||||
use_case: "SaaS dashboard"
|
||||
weights:
|
||||
ecosystem: 30
|
||||
performance: 25
|
||||
developer_experience: 45
|
||||
```
|
||||
|
||||
**JSON** - Programmatic integration
|
||||
```json
|
||||
{
|
||||
"technologies": ["React", "Vue"],
|
||||
"use_case": "SaaS dashboard"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Analysis Types
|
||||
|
||||
### Quick Comparison (200-300 tokens)
|
||||
- Weighted scores and recommendation
|
||||
- Top 3 decision factors
|
||||
- Confidence level
|
||||
|
||||
### Standard Analysis (500-800 tokens)
|
||||
- Comparison matrix
|
||||
- TCO overview
|
||||
- Security summary
|
||||
|
||||
### Full Report (1200-1500 tokens)
|
||||
- All metrics and calculations
|
||||
- Migration analysis
|
||||
- Detailed recommendations
|
||||
|
||||
---
|
||||
|
||||
## Scripts
|
||||
|
||||
### stack_comparator.py
|
||||
|
||||
Compare technologies with customizable weighted criteria.
|
||||
|
||||
```bash
|
||||
python scripts/stack_comparator.py --help
|
||||
```
|
||||
|
||||
### tco_calculator.py
|
||||
|
||||
Calculate total cost of ownership over multi-year projections.
|
||||
|
||||
```bash
|
||||
python scripts/tco_calculator.py --input assets/sample_input_tco.json
|
||||
```
|
||||
|
||||
### ecosystem_analyzer.py
|
||||
|
||||
Analyze ecosystem health from GitHub, npm, and community metrics.
|
||||
|
||||
```bash
|
||||
python scripts/ecosystem_analyzer.py --technology react
|
||||
```
|
||||
|
||||
### security_assessor.py
|
||||
|
||||
Evaluate security posture and compliance readiness.
|
||||
|
||||
```bash
|
||||
python scripts/security_assessor.py --technology express --compliance soc2,gdpr
|
||||
```
|
||||
|
||||
### migration_analyzer.py
|
||||
|
||||
Estimate migration complexity, effort, and risks.
|
||||
|
||||
```bash
|
||||
python scripts/migration_analyzer.py --from angular-1.x --to react
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## References
|
||||
|
||||
| Document | Content |
|
||||
|----------|---------|
|
||||
| `references/metrics.md` | Detailed scoring algorithms and calculation formulas |
|
||||
| `references/examples.md` | Input/output examples for all analysis types |
|
||||
| `references/workflows.md` | Step-by-step evaluation workflows |
|
||||
|
||||
---
|
||||
|
||||
## Confidence Levels
|
||||
|
||||
| Level | Score | Interpretation |
|
||||
|-------|-------|----------------|
|
||||
| High | 80-100% | Clear winner, strong data |
|
||||
| Medium | 50-79% | Trade-offs present, moderate uncertainty |
|
||||
| Low | < 50% | Close call, limited data |
|
||||
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
- Comparing frontend/backend frameworks for new projects
|
||||
- Evaluating cloud providers for specific workloads
|
||||
- Planning technology migrations with risk assessment
|
||||
- Calculating build vs. buy decisions with TCO
|
||||
- Assessing open-source library viability
|
||||
|
||||
## When NOT to Use
|
||||
|
||||
- Trivial decisions between similar tools (use team preference)
|
||||
- Mandated technology choices (decision already made)
|
||||
- Emergency production issues (use monitoring tools)
|
||||
284
docs/skills/engineering/agent-designer.md
Normal file
284
docs/skills/engineering/agent-designer.md
Normal file
@@ -0,0 +1,284 @@
|
||||
---
|
||||
title: "Agent Designer - Multi-Agent System Architecture"
|
||||
description: "Agent Designer - Multi-Agent System Architecture - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Agent Designer - Multi-Agent System Architecture
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `agent-designer` | **Source:** [`engineering/agent-designer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/agent-designer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering
|
||||
**Tags:** AI agents, architecture, system design, orchestration, multi-agent systems
|
||||
|
||||
## Overview
|
||||
|
||||
Agent Designer is a comprehensive toolkit for designing, architecting, and evaluating multi-agent systems. It provides structured approaches to agent architecture patterns, tool design principles, communication strategies, and performance evaluation frameworks for building robust, scalable AI agent systems.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
### 1. Agent Architecture Patterns
|
||||
|
||||
#### Single Agent Pattern
|
||||
- **Use Case:** Simple, focused tasks with clear boundaries
|
||||
- **Pros:** Minimal complexity, easy debugging, predictable behavior
|
||||
- **Cons:** Limited scalability, single point of failure
|
||||
- **Implementation:** Direct user-agent interaction with comprehensive tool access
|
||||
|
||||
#### Supervisor Pattern
|
||||
- **Use Case:** Hierarchical task decomposition with centralized control
|
||||
- **Architecture:** One supervisor agent coordinating multiple specialist agents
|
||||
- **Pros:** Clear command structure, centralized decision making
|
||||
- **Cons:** Supervisor bottleneck, complex coordination logic
|
||||
- **Implementation:** Supervisor receives tasks, delegates to specialists, aggregates results
|
||||
|
||||
#### Swarm Pattern
|
||||
- **Use Case:** Distributed problem solving with peer-to-peer collaboration
|
||||
- **Architecture:** Multiple autonomous agents with shared objectives
|
||||
- **Pros:** High parallelism, fault tolerance, emergent intelligence
|
||||
- **Cons:** Complex coordination, potential conflicts, harder to predict
|
||||
- **Implementation:** Agent discovery, consensus mechanisms, distributed task allocation
|
||||
|
||||
#### Hierarchical Pattern
|
||||
- **Use Case:** Complex systems with multiple organizational layers
|
||||
- **Architecture:** Tree structure with managers and workers at different levels
|
||||
- **Pros:** Natural organizational mapping, clear responsibilities
|
||||
- **Cons:** Communication overhead, potential bottlenecks at each level
|
||||
- **Implementation:** Multi-level delegation with feedback loops
|
||||
|
||||
#### Pipeline Pattern
|
||||
- **Use Case:** Sequential processing with specialized stages
|
||||
- **Architecture:** Agents arranged in processing pipeline
|
||||
- **Pros:** Clear data flow, specialized optimization per stage
|
||||
- **Cons:** Sequential bottlenecks, rigid processing order
|
||||
- **Implementation:** Message queues between stages, state handoffs
|
||||
|
||||
### 2. Agent Role Definition
|
||||
|
||||
#### Role Specification Framework
|
||||
- **Identity:** Name, purpose statement, core competencies
|
||||
- **Responsibilities:** Primary tasks, decision boundaries, success criteria
|
||||
- **Capabilities:** Required tools, knowledge domains, processing limits
|
||||
- **Interfaces:** Input/output formats, communication protocols
|
||||
- **Constraints:** Security boundaries, resource limits, operational guidelines
|
||||
|
||||
#### Common Agent Archetypes
|
||||
|
||||
**Coordinator Agent**
|
||||
- Orchestrates multi-agent workflows
|
||||
- Makes high-level decisions and resource allocation
|
||||
- Monitors system health and performance
|
||||
- Handles escalations and conflict resolution
|
||||
|
||||
**Specialist Agent**
|
||||
- Deep expertise in specific domain (code, data, research)
|
||||
- Optimized tools and knowledge for specialized tasks
|
||||
- High-quality output within narrow scope
|
||||
- Clear handoff protocols for out-of-scope requests
|
||||
|
||||
**Interface Agent**
|
||||
- Handles external interactions (users, APIs, systems)
|
||||
- Protocol translation and format conversion
|
||||
- Authentication and authorization management
|
||||
- User experience optimization
|
||||
|
||||
**Monitor Agent**
|
||||
- System health monitoring and alerting
|
||||
- Performance metrics collection and analysis
|
||||
- Anomaly detection and reporting
|
||||
- Compliance and audit trail maintenance
|
||||
|
||||
### 3. Tool Design Principles
|
||||
|
||||
#### Schema Design
|
||||
- **Input Validation:** Strong typing, required vs optional parameters
|
||||
- **Output Consistency:** Standardized response formats, error handling
|
||||
- **Documentation:** Clear descriptions, usage examples, edge cases
|
||||
- **Versioning:** Backward compatibility, migration paths
|
||||
|
||||
#### Error Handling Patterns
|
||||
- **Graceful Degradation:** Partial functionality when dependencies fail
|
||||
- **Retry Logic:** Exponential backoff, circuit breakers, max attempts
|
||||
- **Error Propagation:** Structured error responses, error classification
|
||||
- **Recovery Strategies:** Fallback methods, alternative approaches
|
||||
|
||||
#### Idempotency Requirements
|
||||
- **Safe Operations:** Read operations with no side effects
|
||||
- **Idempotent Writes:** Same operation can be safely repeated
|
||||
- **State Management:** Version tracking, conflict resolution
|
||||
- **Atomicity:** All-or-nothing operation completion
|
||||
|
||||
### 4. Communication Patterns
|
||||
|
||||
#### Message Passing
|
||||
- **Asynchronous Messaging:** Decoupled agents, message queues
|
||||
- **Message Format:** Structured payloads with metadata
|
||||
- **Delivery Guarantees:** At-least-once, exactly-once semantics
|
||||
- **Routing:** Direct messaging, publish-subscribe, broadcast
|
||||
|
||||
#### Shared State
|
||||
- **State Stores:** Centralized data repositories
|
||||
- **Consistency Models:** Strong, eventual, weak consistency
|
||||
- **Access Patterns:** Read-heavy, write-heavy, mixed workloads
|
||||
- **Conflict Resolution:** Last-writer-wins, merge strategies
|
||||
|
||||
#### Event-Driven Architecture
|
||||
- **Event Sourcing:** Immutable event logs, state reconstruction
|
||||
- **Event Types:** Domain events, system events, integration events
|
||||
- **Event Processing:** Real-time, batch, stream processing
|
||||
- **Event Schema:** Versioned event formats, backward compatibility
|
||||
|
||||
### 5. Guardrails and Safety
|
||||
|
||||
#### Input Validation
|
||||
- **Schema Enforcement:** Required fields, type checking, format validation
|
||||
- **Content Filtering:** Harmful content detection, PII scrubbing
|
||||
- **Rate Limiting:** Request throttling, resource quotas
|
||||
- **Authentication:** Identity verification, authorization checks
|
||||
|
||||
#### Output Filtering
|
||||
- **Content Moderation:** Harmful content removal, quality checks
|
||||
- **Consistency Validation:** Logic checks, constraint verification
|
||||
- **Formatting:** Standardized output formats, clean presentation
|
||||
- **Audit Logging:** Decision trails, compliance records
|
||||
|
||||
#### Human-in-the-Loop
|
||||
- **Approval Workflows:** Critical decision checkpoints
|
||||
- **Escalation Triggers:** Confidence thresholds, risk assessment
|
||||
- **Override Mechanisms:** Human judgment precedence
|
||||
- **Feedback Loops:** Human corrections improve system behavior
|
||||
|
||||
### 6. Evaluation Frameworks
|
||||
|
||||
#### Task Completion Metrics
|
||||
- **Success Rate:** Percentage of tasks completed successfully
|
||||
- **Partial Completion:** Progress measurement for complex tasks
|
||||
- **Task Classification:** Success criteria by task type
|
||||
- **Failure Analysis:** Root cause identification and categorization
|
||||
|
||||
#### Quality Assessment
|
||||
- **Output Quality:** Accuracy, relevance, completeness measures
|
||||
- **Consistency:** Response variability across similar inputs
|
||||
- **Coherence:** Logical flow and internal consistency
|
||||
- **User Satisfaction:** Feedback scores, usage patterns
|
||||
|
||||
#### Cost Analysis
|
||||
- **Token Usage:** Input/output token consumption per task
|
||||
- **API Costs:** External service usage and charges
|
||||
- **Compute Resources:** CPU, memory, storage utilization
|
||||
- **Time-to-Value:** Cost per successful task completion
|
||||
|
||||
#### Latency Distribution
|
||||
- **Response Time:** End-to-end task completion time
|
||||
- **Processing Stages:** Bottleneck identification per stage
|
||||
- **Queue Times:** Wait times in processing pipelines
|
||||
- **Resource Contention:** Impact of concurrent operations
|
||||
|
||||
### 7. Orchestration Strategies
|
||||
|
||||
#### Centralized Orchestration
|
||||
- **Workflow Engine:** Central coordinator manages all agents
|
||||
- **State Management:** Centralized workflow state tracking
|
||||
- **Decision Logic:** Complex routing and branching rules
|
||||
- **Monitoring:** Comprehensive visibility into all operations
|
||||
|
||||
#### Decentralized Orchestration
|
||||
- **Peer-to-Peer:** Agents coordinate directly with each other
|
||||
- **Service Discovery:** Dynamic agent registration and lookup
|
||||
- **Consensus Protocols:** Distributed decision making
|
||||
- **Fault Tolerance:** No single point of failure
|
||||
|
||||
#### Hybrid Approaches
|
||||
- **Domain Boundaries:** Centralized within domains, federated across
|
||||
- **Hierarchical Coordination:** Multiple orchestration levels
|
||||
- **Context-Dependent:** Strategy selection based on task type
|
||||
- **Load Balancing:** Distribute coordination responsibility
|
||||
|
||||
### 8. Memory Patterns
|
||||
|
||||
#### Short-Term Memory
|
||||
- **Context Windows:** Working memory for current tasks
|
||||
- **Session State:** Temporary data for ongoing interactions
|
||||
- **Cache Management:** Performance optimization strategies
|
||||
- **Memory Pressure:** Handling capacity constraints
|
||||
|
||||
#### Long-Term Memory
|
||||
- **Persistent Storage:** Durable data across sessions
|
||||
- **Knowledge Base:** Accumulated domain knowledge
|
||||
- **Experience Replay:** Learning from past interactions
|
||||
- **Memory Consolidation:** Transferring from short to long-term
|
||||
|
||||
#### Shared Memory
|
||||
- **Collaborative Knowledge:** Shared learning across agents
|
||||
- **Synchronization:** Consistency maintenance strategies
|
||||
- **Access Control:** Permission-based memory access
|
||||
- **Memory Partitioning:** Isolation between agent groups
|
||||
|
||||
### 9. Scaling Considerations
|
||||
|
||||
#### Horizontal Scaling
|
||||
- **Agent Replication:** Multiple instances of same agent type
|
||||
- **Load Distribution:** Request routing across agent instances
|
||||
- **Resource Pooling:** Shared compute and storage resources
|
||||
- **Geographic Distribution:** Multi-region deployments
|
||||
|
||||
#### Vertical Scaling
|
||||
- **Capability Enhancement:** More powerful individual agents
|
||||
- **Tool Expansion:** Broader tool access per agent
|
||||
- **Context Expansion:** Larger working memory capacity
|
||||
- **Processing Power:** Higher throughput per agent
|
||||
|
||||
#### Performance Optimization
|
||||
- **Caching Strategies:** Response caching, tool result caching
|
||||
- **Parallel Processing:** Concurrent task execution
|
||||
- **Resource Optimization:** Efficient resource utilization
|
||||
- **Bottleneck Elimination:** Systematic performance tuning
|
||||
|
||||
### 10. Failure Handling
|
||||
|
||||
#### Retry Mechanisms
|
||||
- **Exponential Backoff:** Increasing delays between retries
|
||||
- **Jitter:** Random delay variation to prevent thundering herd
|
||||
- **Maximum Attempts:** Bounded retry behavior
|
||||
- **Retry Conditions:** Transient vs permanent failure classification
|
||||
|
||||
#### Fallback Strategies
|
||||
- **Graceful Degradation:** Reduced functionality when systems fail
|
||||
- **Alternative Approaches:** Different methods for same goals
|
||||
- **Default Responses:** Safe fallback behaviors
|
||||
- **User Communication:** Clear failure messaging
|
||||
|
||||
#### Circuit Breakers
|
||||
- **Failure Detection:** Monitoring failure rates and response times
|
||||
- **State Management:** Open, closed, half-open circuit states
|
||||
- **Recovery Testing:** Gradual return to normal operation
|
||||
- **Cascading Failure Prevention:** Protecting upstream systems
|
||||
|
||||
## Implementation Guidelines
|
||||
|
||||
### Architecture Decision Process
|
||||
1. **Requirements Analysis:** Understand system goals, constraints, scale
|
||||
2. **Pattern Selection:** Choose appropriate architecture pattern
|
||||
3. **Agent Design:** Define roles, responsibilities, interfaces
|
||||
4. **Tool Architecture:** Design tool schemas and error handling
|
||||
5. **Communication Design:** Select message patterns and protocols
|
||||
6. **Safety Implementation:** Build guardrails and validation
|
||||
7. **Evaluation Planning:** Define success metrics and monitoring
|
||||
8. **Deployment Strategy:** Plan scaling and failure handling
|
||||
|
||||
### Quality Assurance
|
||||
- **Testing Strategy:** Unit, integration, and system testing approaches
|
||||
- **Monitoring:** Real-time system health and performance tracking
|
||||
- **Documentation:** Architecture documentation and runbooks
|
||||
- **Security Review:** Threat modeling and security assessments
|
||||
|
||||
### Continuous Improvement
|
||||
- **Performance Monitoring:** Ongoing system performance analysis
|
||||
- **User Feedback:** Incorporating user experience improvements
|
||||
- **A/B Testing:** Controlled experiments for system improvements
|
||||
- **Knowledge Base Updates:** Continuous learning and adaptation
|
||||
|
||||
This skill provides the foundation for designing robust, scalable multi-agent systems that can handle complex tasks while maintaining safety, reliability, and performance at scale.
|
||||
448
docs/skills/engineering/agent-workflow-designer.md
Normal file
448
docs/skills/engineering/agent-workflow-designer.md
Normal file
@@ -0,0 +1,448 @@
|
||||
---
|
||||
title: "Agent Workflow Designer"
|
||||
description: "Agent Workflow Designer - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Agent Workflow Designer
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `agent-workflow-designer` | **Source:** [`engineering/agent-workflow-designer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/agent-workflow-designer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering
|
||||
**Domain:** Multi-Agent Systems / AI Orchestration
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Design production-grade multi-agent orchestration systems. Covers five core patterns (sequential pipeline, parallel fan-out/fan-in, hierarchical delegation, event-driven, consensus), platform-specific implementations, handoff protocols, state management, error recovery, context window budgeting, and cost optimization.
|
||||
|
||||
---
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- Pattern selection guide for any orchestration requirement
|
||||
- Handoff protocol templates (structured context passing)
|
||||
- State management patterns for multi-agent workflows
|
||||
- Error recovery and retry strategies
|
||||
- Context window budget management
|
||||
- Cost optimization strategies per platform
|
||||
- Platform-specific configs: Claude Code Agent Teams, OpenClaw, CrewAI, AutoGen
|
||||
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
- Building a multi-step AI pipeline that exceeds one agent's context capacity
|
||||
- Parallelizing research, generation, or analysis tasks for speed
|
||||
- Creating specialist agents with defined roles and handoff contracts
|
||||
- Designing fault-tolerant AI workflows for production
|
||||
|
||||
---
|
||||
|
||||
## Pattern Selection Guide
|
||||
|
||||
```
|
||||
Is the task sequential (each step needs previous output)?
|
||||
YES → Sequential Pipeline
|
||||
NO → Can tasks run in parallel?
|
||||
YES → Parallel Fan-out/Fan-in
|
||||
NO → Is there a hierarchy of decisions?
|
||||
YES → Hierarchical Delegation
|
||||
NO → Is it event-triggered?
|
||||
YES → Event-Driven
|
||||
NO → Need consensus/validation?
|
||||
YES → Consensus Pattern
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pattern 1: Sequential Pipeline
|
||||
|
||||
**Use when:** Each step depends on the previous output. Research → Draft → Review → Polish.
|
||||
|
||||
```python
|
||||
# sequential_pipeline.py
|
||||
from dataclasses import dataclass
|
||||
from typing import Callable, Any
|
||||
import anthropic
|
||||
|
||||
@dataclass
|
||||
class PipelineStage:
|
||||
name: str
|
||||
system_prompt: str
|
||||
input_key: str # what to take from state
|
||||
output_key: str # what to write to state
|
||||
model: str = "claude-3-5-sonnet-20241022"
|
||||
max_tokens: int = 2048
|
||||
|
||||
class SequentialPipeline:
|
||||
def __init__(self, stages: list[PipelineStage]):
|
||||
self.stages = stages
|
||||
self.client = anthropic.Anthropic()
|
||||
|
||||
def run(self, initial_input: str) -> dict:
|
||||
state = {"input": initial_input}
|
||||
|
||||
for stage in self.stages:
|
||||
print(f"[{stage.name}] Processing...")
|
||||
|
||||
stage_input = state.get(stage.input_key, "")
|
||||
|
||||
response = self.client.messages.create(
|
||||
model=stage.model,
|
||||
max_tokens=stage.max_tokens,
|
||||
system=stage.system_prompt,
|
||||
messages=[{"role": "user", "content": stage_input}],
|
||||
)
|
||||
|
||||
state[stage.output_key] = response.content[0].text
|
||||
state[f"{stage.name}_tokens"] = response.usage.input_tokens + response.usage.output_tokens
|
||||
|
||||
print(f"[{stage.name}] Done. Tokens: {state[f'{stage.name}_tokens']}")
|
||||
|
||||
return state
|
||||
|
||||
# Example: Blog post pipeline
|
||||
pipeline = SequentialPipeline([
|
||||
PipelineStage(
|
||||
name="researcher",
|
||||
system_prompt="You are a research specialist. Given a topic, produce a structured research brief with: key facts, statistics, expert perspectives, and controversy points.",
|
||||
input_key="input",
|
||||
output_key="research",
|
||||
),
|
||||
PipelineStage(
|
||||
name="writer",
|
||||
system_prompt="You are a senior content writer. Using the research provided, write a compelling 800-word blog post with a clear hook, 3 main sections, and a strong CTA.",
|
||||
input_key="research",
|
||||
output_key="draft",
|
||||
),
|
||||
PipelineStage(
|
||||
name="editor",
|
||||
system_prompt="You are a copy editor. Review the draft for: clarity, flow, grammar, and SEO. Return the improved version only, no commentary.",
|
||||
input_key="draft",
|
||||
output_key="final",
|
||||
),
|
||||
])
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pattern 2: Parallel Fan-out / Fan-in
|
||||
|
||||
**Use when:** Independent tasks that can run concurrently. Research 5 competitors simultaneously.
|
||||
|
||||
```python
|
||||
# parallel_fanout.py
|
||||
import asyncio
|
||||
import anthropic
|
||||
from typing import Any
|
||||
|
||||
async def run_agent(client, task_name: str, system: str, user: str, model: str = "claude-3-5-sonnet-20241022") -> dict:
|
||||
"""Single async agent call"""
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
def _call():
|
||||
return client.messages.create(
|
||||
model=model,
|
||||
max_tokens=2048,
|
||||
system=system,
|
||||
messages=[{"role": "user", "content": user}],
|
||||
)
|
||||
|
||||
response = await loop.run_in_executor(None, _call)
|
||||
return {
|
||||
"task": task_name,
|
||||
"output": response.content[0].text,
|
||||
"tokens": response.usage.input_tokens + response.usage.output_tokens,
|
||||
}
|
||||
|
||||
async def parallel_research(competitors: list[str], research_type: str) -> dict:
|
||||
"""Fan-out: research all competitors in parallel. Fan-in: synthesize results."""
|
||||
client = anthropic.Anthropic()
|
||||
|
||||
# FAN-OUT: spawn parallel agent calls
|
||||
tasks = [
|
||||
run_agent(
|
||||
client,
|
||||
task_name=competitor,
|
||||
system=f"You are a competitive intelligence analyst. Research {competitor} and provide: pricing, key features, target market, and known weaknesses.",
|
||||
user=f"Analyze {competitor} for comparison with our product in the {research_type} market.",
|
||||
)
|
||||
for competitor in competitors
|
||||
]
|
||||
|
||||
results = await asyncio.gather(*tasks, return_exceptions=True)
|
||||
|
||||
# Handle failures gracefully
|
||||
successful = [r for r in results if not isinstance(r, Exception)]
|
||||
failed = [r for r in results if isinstance(r, Exception)]
|
||||
|
||||
if failed:
|
||||
print(f"Warning: {len(failed)} research tasks failed: {failed}")
|
||||
|
||||
# FAN-IN: synthesize
|
||||
combined_research = "\n\n".join([
|
||||
f"## {r['task']}\n{r['output']}" for r in successful
|
||||
])
|
||||
|
||||
synthesis = await run_agent(
|
||||
client,
|
||||
task_name="synthesizer",
|
||||
system="You are a strategic analyst. Synthesize competitor research into a concise comparison matrix and strategic recommendations.",
|
||||
user=f"Synthesize these competitor analyses:\n\n{combined_research}",
|
||||
model="claude-3-5-sonnet-20241022",
|
||||
)
|
||||
|
||||
return {
|
||||
"individual_analyses": successful,
|
||||
"synthesis": synthesis["output"],
|
||||
"total_tokens": sum(r["tokens"] for r in successful) + synthesis["tokens"],
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pattern 3: Hierarchical Delegation
|
||||
|
||||
**Use when:** Complex tasks with subtask discovery. Orchestrator breaks down work, delegates to specialists.
|
||||
|
||||
```python
|
||||
# hierarchical_delegation.py
|
||||
import json
|
||||
import anthropic
|
||||
|
||||
ORCHESTRATOR_SYSTEM = """You are an orchestration agent. Your job is to:
|
||||
1. Analyze the user's request
|
||||
2. Break it into subtasks
|
||||
3. Assign each to the appropriate specialist agent
|
||||
4. Collect results and synthesize
|
||||
|
||||
Available specialists:
|
||||
- researcher: finds facts, data, and information
|
||||
- writer: creates content and documents
|
||||
- coder: writes and reviews code
|
||||
- analyst: analyzes data and produces insights
|
||||
|
||||
Respond with a JSON plan:
|
||||
{
|
||||
"subtasks": [
|
||||
{"id": "1", "agent": "researcher", "task": "...", "depends_on": []},
|
||||
{"id": "2", "agent": "writer", "task": "...", "depends_on": ["1"]}
|
||||
]
|
||||
}"""
|
||||
|
||||
SPECIALIST_SYSTEMS = {
|
||||
"researcher": "You are a research specialist. Find accurate, relevant information and cite sources when possible.",
|
||||
"writer": "You are a professional writer. Create clear, engaging content in the requested format.",
|
||||
"coder": "You are a senior software engineer. Write clean, well-commented code with error handling.",
|
||||
"analyst": "You are a data analyst. Provide structured analysis with evidence-backed conclusions.",
|
||||
}
|
||||
|
||||
class HierarchicalOrchestrator:
|
||||
def __init__(self):
|
||||
self.client = anthropic.Anthropic()
|
||||
|
||||
def run(self, user_request: str) -> str:
|
||||
# 1. Orchestrator creates plan
|
||||
plan_response = self.client.messages.create(
|
||||
model="claude-3-5-sonnet-20241022",
|
||||
max_tokens=1024,
|
||||
system=ORCHESTRATOR_SYSTEM,
|
||||
messages=[{"role": "user", "content": user_request}],
|
||||
)
|
||||
|
||||
plan = json.loads(plan_response.content[0].text)
|
||||
results = {}
|
||||
|
||||
# 2. Execute subtasks respecting dependencies
|
||||
for subtask in self._topological_sort(plan["subtasks"]):
|
||||
context = self._build_context(subtask, results)
|
||||
specialist = SPECIALIST_SYSTEMS[subtask["agent"]]
|
||||
|
||||
result = self.client.messages.create(
|
||||
model="claude-3-5-sonnet-20241022",
|
||||
max_tokens=2048,
|
||||
system=specialist,
|
||||
messages=[{"role": "user", "content": f"{context}\n\nTask: {subtask['task']}"}],
|
||||
)
|
||||
results[subtask["id"]] = result.content[0].text
|
||||
|
||||
# 3. Final synthesis
|
||||
all_results = "\n\n".join([f"### {k}\n{v}" for k, v in results.items()])
|
||||
synthesis = self.client.messages.create(
|
||||
model="claude-3-5-sonnet-20241022",
|
||||
max_tokens=2048,
|
||||
system="Synthesize the specialist outputs into a coherent final response.",
|
||||
messages=[{"role": "user", "content": f"Original request: {user_request}\n\nSpecialist outputs:\n{all_results}"}],
|
||||
)
|
||||
return synthesis.content[0].text
|
||||
|
||||
def _build_context(self, subtask: dict, results: dict) -> str:
|
||||
if not subtask.get("depends_on"):
|
||||
return ""
|
||||
deps = [f"Output from task {dep}:\n{results[dep]}" for dep in subtask["depends_on"] if dep in results]
|
||||
return "Previous results:\n" + "\n\n".join(deps) if deps else ""
|
||||
|
||||
def _topological_sort(self, subtasks: list) -> list:
|
||||
# Simple ordered execution respecting depends_on
|
||||
ordered, remaining = [], list(subtasks)
|
||||
completed = set()
|
||||
while remaining:
|
||||
for task in remaining:
|
||||
if all(dep in completed for dep in task.get("depends_on", [])):
|
||||
ordered.append(task)
|
||||
completed.add(task["id"])
|
||||
remaining.remove(task)
|
||||
break
|
||||
return ordered
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Handoff Protocol Template
|
||||
|
||||
```python
|
||||
# Standard handoff context format — use between all agents
|
||||
@dataclass
|
||||
class AgentHandoff:
|
||||
"""Structured context passed between agents in a workflow."""
|
||||
task_id: str
|
||||
workflow_id: str
|
||||
step_number: int
|
||||
total_steps: int
|
||||
|
||||
# What was done
|
||||
previous_agent: str
|
||||
previous_output: str
|
||||
artifacts: dict # {"filename": "content"} for any files produced
|
||||
|
||||
# What to do next
|
||||
current_agent: str
|
||||
current_task: str
|
||||
constraints: list[str] # hard rules for this step
|
||||
|
||||
# Metadata
|
||||
context_budget_remaining: int # tokens left for this agent
|
||||
cost_so_far_usd: float
|
||||
|
||||
def to_prompt(self) -> str:
|
||||
return f"""
|
||||
# Agent Handoff — Step {self.step_number}/{self.total_steps}
|
||||
|
||||
## Your Task
|
||||
{self.current_task}
|
||||
|
||||
## Constraints
|
||||
{chr(10).join(f'- {c}' for c in self.constraints)}
|
||||
|
||||
## Context from Previous Step ({self.previous_agent})
|
||||
{self.previous_output[:2000]}{"... [truncated]" if len(self.previous_output) > 2000 else ""}
|
||||
|
||||
## Context Budget
|
||||
You have approximately {self.context_budget_remaining} tokens remaining. Be concise.
|
||||
"""
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Error Recovery Patterns
|
||||
|
||||
```python
|
||||
import time
|
||||
from functools import wraps
|
||||
|
||||
def with_retry(max_attempts=3, backoff_seconds=2, fallback_model=None):
|
||||
"""Decorator for agent calls with exponential backoff and model fallback."""
|
||||
def decorator(fn):
|
||||
@wraps(fn)
|
||||
def wrapper(*args, **kwargs):
|
||||
last_error = None
|
||||
for attempt in range(max_attempts):
|
||||
try:
|
||||
return fn(*args, **kwargs)
|
||||
except Exception as e:
|
||||
last_error = e
|
||||
if attempt < max_attempts - 1:
|
||||
wait = backoff_seconds * (2 ** attempt)
|
||||
print(f"Attempt {attempt+1} failed: {e}. Retrying in {wait}s...")
|
||||
time.sleep(wait)
|
||||
|
||||
# Fall back to cheaper/faster model on rate limit
|
||||
if fallback_model and "rate_limit" in str(e).lower():
|
||||
kwargs["model"] = fallback_model
|
||||
raise last_error
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
@with_retry(max_attempts=3, fallback_model="claude-3-haiku-20240307")
|
||||
def call_agent(model, system, user):
|
||||
...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Context Window Budgeting
|
||||
|
||||
```python
|
||||
# Budget context across a multi-step pipeline
|
||||
# Rule: never let any step consume more than 60% of remaining budget
|
||||
|
||||
CONTEXT_LIMITS = {
|
||||
"claude-3-5-sonnet-20241022": 200_000,
|
||||
"gpt-4o": 128_000,
|
||||
}
|
||||
|
||||
class ContextBudget:
|
||||
def __init__(self, model: str, reserve_pct: float = 0.2):
|
||||
total = CONTEXT_LIMITS.get(model, 128_000)
|
||||
self.total = total
|
||||
self.reserve = int(total * reserve_pct) # keep 20% as buffer
|
||||
self.used = 0
|
||||
|
||||
@property
|
||||
def remaining(self):
|
||||
return self.total - self.reserve - self.used
|
||||
|
||||
def allocate(self, step_name: str, requested: int) -> int:
|
||||
allocated = min(requested, int(self.remaining * 0.6)) # max 60% of remaining
|
||||
print(f"[Budget] {step_name}: allocated {allocated:,} tokens (remaining: {self.remaining:,})")
|
||||
return allocated
|
||||
|
||||
def consume(self, tokens_used: int):
|
||||
self.used += tokens_used
|
||||
|
||||
def truncate_to_budget(text: str, token_budget: int, chars_per_token: float = 4.0) -> str:
|
||||
"""Rough truncation — use tiktoken for precision."""
|
||||
char_budget = int(token_budget * chars_per_token)
|
||||
if len(text) <= char_budget:
|
||||
return text
|
||||
return text[:char_budget] + "\n\n[... truncated to fit context budget ...]"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cost Optimization Strategies
|
||||
|
||||
| Strategy | Savings | Tradeoff |
|
||||
|---|---|---|
|
||||
| Use Haiku for routing/classification | 85-90% | Slightly less nuanced judgment |
|
||||
| Cache repeated system prompts | 50-90% | Requires prompt caching setup |
|
||||
| Truncate intermediate outputs | 20-40% | May lose detail in handoffs |
|
||||
| Batch similar tasks | 50% | Latency increases |
|
||||
| Use Sonnet for most, Opus for final step only | 60-70% | Final quality may improve |
|
||||
| Short-circuit on confidence threshold | 30-50% | Need confidence scoring |
|
||||
|
||||
---
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
- **Circular dependencies** — agents calling each other in loops; enforce DAG structure at design time
|
||||
- **Context bleed** — passing entire previous output to every step; summarize or extract only what's needed
|
||||
- **No timeout** — a stuck agent blocks the whole pipeline; always set max_tokens and wall-clock timeouts
|
||||
- **Silent failures** — agent returns plausible but wrong output; add validation steps for critical paths
|
||||
- **Ignoring cost** — 10 parallel Opus calls is $0.50 per workflow; model selection is a cost decision
|
||||
- **Over-orchestration** — if a single prompt can do it, it should; only add agents when genuinely needed
|
||||
426
docs/skills/engineering/api-design-reviewer.md
Normal file
426
docs/skills/engineering/api-design-reviewer.md
Normal file
@@ -0,0 +1,426 @@
|
||||
---
|
||||
title: "API Design Reviewer"
|
||||
description: "API Design Reviewer - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# API Design Reviewer
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `api-design-reviewer` | **Source:** [`engineering/api-design-reviewer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/api-design-reviewer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering / Architecture
|
||||
**Maintainer:** Claude Skills Team
|
||||
|
||||
## Overview
|
||||
|
||||
The API Design Reviewer skill provides comprehensive analysis and review of API designs, focusing on REST conventions, best practices, and industry standards. This skill helps engineering teams build consistent, maintainable, and well-designed APIs through automated linting, breaking change detection, and design scorecards.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
### 1. API Linting and Convention Analysis
|
||||
- **Resource Naming Conventions**: Enforces kebab-case for resources, camelCase for fields
|
||||
- **HTTP Method Usage**: Validates proper use of GET, POST, PUT, PATCH, DELETE
|
||||
- **URL Structure**: Analyzes endpoint patterns for consistency and RESTful design
|
||||
- **Status Code Compliance**: Ensures appropriate HTTP status codes are used
|
||||
- **Error Response Formats**: Validates consistent error response structures
|
||||
- **Documentation Coverage**: Checks for missing descriptions and documentation gaps
|
||||
|
||||
### 2. Breaking Change Detection
|
||||
- **Endpoint Removal**: Detects removed or deprecated endpoints
|
||||
- **Response Shape Changes**: Identifies modifications to response structures
|
||||
- **Field Removal**: Tracks removed or renamed fields in API responses
|
||||
- **Type Changes**: Catches field type modifications that could break clients
|
||||
- **Required Field Additions**: Flags new required fields that could break existing integrations
|
||||
- **Status Code Changes**: Detects changes to expected status codes
|
||||
|
||||
### 3. API Design Scoring and Assessment
|
||||
- **Consistency Analysis** (30%): Evaluates naming conventions, response patterns, and structural consistency
|
||||
- **Documentation Quality** (20%): Assesses completeness and clarity of API documentation
|
||||
- **Security Implementation** (20%): Reviews authentication, authorization, and security headers
|
||||
- **Usability Design** (15%): Analyzes ease of use, discoverability, and developer experience
|
||||
- **Performance Patterns** (15%): Evaluates caching, pagination, and efficiency patterns
|
||||
|
||||
## REST Design Principles
|
||||
|
||||
### Resource Naming Conventions
|
||||
```
|
||||
✅ Good Examples:
|
||||
- /api/v1/users
|
||||
- /api/v1/user-profiles
|
||||
- /api/v1/orders/123/line-items
|
||||
|
||||
❌ Bad Examples:
|
||||
- /api/v1/getUsers
|
||||
- /api/v1/user_profiles
|
||||
- /api/v1/orders/123/lineItems
|
||||
```
|
||||
|
||||
### HTTP Method Usage
|
||||
- **GET**: Retrieve resources (safe, idempotent)
|
||||
- **POST**: Create new resources (not idempotent)
|
||||
- **PUT**: Replace entire resources (idempotent)
|
||||
- **PATCH**: Partial resource updates (not necessarily idempotent)
|
||||
- **DELETE**: Remove resources (idempotent)
|
||||
|
||||
### URL Structure Best Practices
|
||||
```
|
||||
Collection Resources: /api/v1/users
|
||||
Individual Resources: /api/v1/users/123
|
||||
Nested Resources: /api/v1/users/123/orders
|
||||
Actions: /api/v1/users/123/activate (POST)
|
||||
Filtering: /api/v1/users?status=active&role=admin
|
||||
```
|
||||
|
||||
## Versioning Strategies
|
||||
|
||||
### 1. URL Versioning (Recommended)
|
||||
```
|
||||
/api/v1/users
|
||||
/api/v2/users
|
||||
```
|
||||
**Pros**: Clear, explicit, easy to route
|
||||
**Cons**: URL proliferation, caching complexity
|
||||
|
||||
### 2. Header Versioning
|
||||
```
|
||||
GET /api/users
|
||||
Accept: application/vnd.api+json;version=1
|
||||
```
|
||||
**Pros**: Clean URLs, content negotiation
|
||||
**Cons**: Less visible, harder to test manually
|
||||
|
||||
### 3. Media Type Versioning
|
||||
```
|
||||
GET /api/users
|
||||
Accept: application/vnd.myapi.v1+json
|
||||
```
|
||||
**Pros**: RESTful, supports multiple representations
|
||||
**Cons**: Complex, harder to implement
|
||||
|
||||
### 4. Query Parameter Versioning
|
||||
```
|
||||
/api/users?version=1
|
||||
```
|
||||
**Pros**: Simple to implement
|
||||
**Cons**: Not RESTful, can be ignored
|
||||
|
||||
## Pagination Patterns
|
||||
|
||||
### Offset-Based Pagination
|
||||
```json
|
||||
{
|
||||
"data": [...],
|
||||
"pagination": {
|
||||
"offset": 20,
|
||||
"limit": 10,
|
||||
"total": 150,
|
||||
"hasMore": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Cursor-Based Pagination
|
||||
```json
|
||||
{
|
||||
"data": [...],
|
||||
"pagination": {
|
||||
"nextCursor": "eyJpZCI6MTIzfQ==",
|
||||
"hasMore": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Page-Based Pagination
|
||||
```json
|
||||
{
|
||||
"data": [...],
|
||||
"pagination": {
|
||||
"page": 3,
|
||||
"pageSize": 10,
|
||||
"totalPages": 15,
|
||||
"totalItems": 150
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Error Response Formats
|
||||
|
||||
### Standard Error Structure
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "VALIDATION_ERROR",
|
||||
"message": "The request contains invalid parameters",
|
||||
"details": [
|
||||
{
|
||||
"field": "email",
|
||||
"code": "INVALID_FORMAT",
|
||||
"message": "Email address is not valid"
|
||||
}
|
||||
],
|
||||
"requestId": "req-123456",
|
||||
"timestamp": "2024-02-16T13:00:00Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### HTTP Status Code Usage
|
||||
- **400 Bad Request**: Invalid request syntax or parameters
|
||||
- **401 Unauthorized**: Authentication required
|
||||
- **403 Forbidden**: Access denied (authenticated but not authorized)
|
||||
- **404 Not Found**: Resource not found
|
||||
- **409 Conflict**: Resource conflict (duplicate, version mismatch)
|
||||
- **422 Unprocessable Entity**: Valid syntax but semantic errors
|
||||
- **429 Too Many Requests**: Rate limit exceeded
|
||||
- **500 Internal Server Error**: Unexpected server error
|
||||
|
||||
## Authentication and Authorization Patterns
|
||||
|
||||
### Bearer Token Authentication
|
||||
```
|
||||
Authorization: Bearer <token>
|
||||
```
|
||||
|
||||
### API Key Authentication
|
||||
```
|
||||
X-API-Key: <api-key>
|
||||
Authorization: Api-Key <api-key>
|
||||
```
|
||||
|
||||
### OAuth 2.0 Flow
|
||||
```
|
||||
Authorization: Bearer <oauth-access-token>
|
||||
```
|
||||
|
||||
### Role-Based Access Control (RBAC)
|
||||
```json
|
||||
{
|
||||
"user": {
|
||||
"id": "123",
|
||||
"roles": ["admin", "editor"],
|
||||
"permissions": ["read:users", "write:orders"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Rate Limiting Implementation
|
||||
|
||||
### Headers
|
||||
```
|
||||
X-RateLimit-Limit: 1000
|
||||
X-RateLimit-Remaining: 999
|
||||
X-RateLimit-Reset: 1640995200
|
||||
```
|
||||
|
||||
### Response on Limit Exceeded
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "RATE_LIMIT_EXCEEDED",
|
||||
"message": "Too many requests",
|
||||
"retryAfter": 3600
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## HATEOAS (Hypermedia as the Engine of Application State)
|
||||
|
||||
### Example Implementation
|
||||
```json
|
||||
{
|
||||
"id": "123",
|
||||
"name": "John Doe",
|
||||
"email": "john@example.com",
|
||||
"_links": {
|
||||
"self": { "href": "/api/v1/users/123" },
|
||||
"orders": { "href": "/api/v1/users/123/orders" },
|
||||
"profile": { "href": "/api/v1/users/123/profile" },
|
||||
"deactivate": {
|
||||
"href": "/api/v1/users/123/deactivate",
|
||||
"method": "POST"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Idempotency
|
||||
|
||||
### Idempotent Methods
|
||||
- **GET**: Always safe and idempotent
|
||||
- **PUT**: Should be idempotent (replace entire resource)
|
||||
- **DELETE**: Should be idempotent (same result)
|
||||
- **PATCH**: May or may not be idempotent
|
||||
|
||||
### Idempotency Keys
|
||||
```
|
||||
POST /api/v1/payments
|
||||
Idempotency-Key: 123e4567-e89b-12d3-a456-426614174000
|
||||
```
|
||||
|
||||
## Backward Compatibility Guidelines
|
||||
|
||||
### Safe Changes (Non-Breaking)
|
||||
- Adding optional fields to requests
|
||||
- Adding fields to responses
|
||||
- Adding new endpoints
|
||||
- Making required fields optional
|
||||
- Adding new enum values (with graceful handling)
|
||||
|
||||
### Breaking Changes (Require Version Bump)
|
||||
- Removing fields from responses
|
||||
- Making optional fields required
|
||||
- Changing field types
|
||||
- Removing endpoints
|
||||
- Changing URL structures
|
||||
- Modifying error response formats
|
||||
|
||||
## OpenAPI/Swagger Validation
|
||||
|
||||
### Required Components
|
||||
- **API Information**: Title, description, version
|
||||
- **Server Information**: Base URLs and descriptions
|
||||
- **Path Definitions**: All endpoints with methods
|
||||
- **Parameter Definitions**: Query, path, header parameters
|
||||
- **Request/Response Schemas**: Complete data models
|
||||
- **Security Definitions**: Authentication schemes
|
||||
- **Error Responses**: Standard error formats
|
||||
|
||||
### Best Practices
|
||||
- Use consistent naming conventions
|
||||
- Provide detailed descriptions for all components
|
||||
- Include examples for complex objects
|
||||
- Define reusable components and schemas
|
||||
- Validate against OpenAPI specification
|
||||
|
||||
## Performance Considerations
|
||||
|
||||
### Caching Strategies
|
||||
```
|
||||
Cache-Control: public, max-age=3600
|
||||
ETag: "123456789"
|
||||
Last-Modified: Wed, 21 Oct 2015 07:28:00 GMT
|
||||
```
|
||||
|
||||
### Efficient Data Transfer
|
||||
- Use appropriate HTTP methods
|
||||
- Implement field selection (`?fields=id,name,email`)
|
||||
- Support compression (gzip)
|
||||
- Implement efficient pagination
|
||||
- Use ETags for conditional requests
|
||||
|
||||
### Resource Optimization
|
||||
- Avoid N+1 queries
|
||||
- Implement batch operations
|
||||
- Use async processing for heavy operations
|
||||
- Support partial updates (PATCH)
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
### Input Validation
|
||||
- Validate all input parameters
|
||||
- Sanitize user data
|
||||
- Use parameterized queries
|
||||
- Implement request size limits
|
||||
|
||||
### Authentication Security
|
||||
- Use HTTPS everywhere
|
||||
- Implement secure token storage
|
||||
- Support token expiration and refresh
|
||||
- Use strong authentication mechanisms
|
||||
|
||||
### Authorization Controls
|
||||
- Implement principle of least privilege
|
||||
- Use resource-based permissions
|
||||
- Support fine-grained access control
|
||||
- Audit access patterns
|
||||
|
||||
## Tools and Scripts
|
||||
|
||||
### api_linter.py
|
||||
Analyzes API specifications for compliance with REST conventions and best practices.
|
||||
|
||||
**Features:**
|
||||
- OpenAPI/Swagger spec validation
|
||||
- Naming convention checks
|
||||
- HTTP method usage validation
|
||||
- Error format consistency
|
||||
- Documentation completeness analysis
|
||||
|
||||
### breaking_change_detector.py
|
||||
Compares API specification versions to identify breaking changes.
|
||||
|
||||
**Features:**
|
||||
- Endpoint comparison
|
||||
- Schema change detection
|
||||
- Field removal/modification tracking
|
||||
- Migration guide generation
|
||||
- Impact severity assessment
|
||||
|
||||
### api_scorecard.py
|
||||
Provides comprehensive scoring of API design quality.
|
||||
|
||||
**Features:**
|
||||
- Multi-dimensional scoring
|
||||
- Detailed improvement recommendations
|
||||
- Letter grade assessment (A-F)
|
||||
- Benchmark comparisons
|
||||
- Progress tracking
|
||||
|
||||
## Integration Examples
|
||||
|
||||
### CI/CD Integration
|
||||
```yaml
|
||||
- name: API Linting
|
||||
run: python scripts/api_linter.py openapi.json
|
||||
|
||||
- name: Breaking Change Detection
|
||||
run: python scripts/breaking_change_detector.py openapi-v1.json openapi-v2.json
|
||||
|
||||
- name: API Scorecard
|
||||
run: python scripts/api_scorecard.py openapi.json
|
||||
```
|
||||
|
||||
### Pre-commit Hooks
|
||||
```bash
|
||||
#!/bin/bash
|
||||
python engineering/api-design-reviewer/scripts/api_linter.py api/openapi.json
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "API linting failed. Please fix the issues before committing."
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
## Best Practices Summary
|
||||
|
||||
1. **Consistency First**: Maintain consistent naming, response formats, and patterns
|
||||
2. **Documentation**: Provide comprehensive, up-to-date API documentation
|
||||
3. **Versioning**: Plan for evolution with clear versioning strategies
|
||||
4. **Error Handling**: Implement consistent, informative error responses
|
||||
5. **Security**: Build security into every layer of the API
|
||||
6. **Performance**: Design for scale and efficiency from the start
|
||||
7. **Backward Compatibility**: Minimize breaking changes and provide migration paths
|
||||
8. **Testing**: Implement comprehensive testing including contract testing
|
||||
9. **Monitoring**: Add observability for API usage and performance
|
||||
10. **Developer Experience**: Prioritize ease of use and clear documentation
|
||||
|
||||
## Common Anti-Patterns to Avoid
|
||||
|
||||
1. **Verb-based URLs**: Use nouns for resources, not actions
|
||||
2. **Inconsistent Response Formats**: Maintain standard response structures
|
||||
3. **Over-nesting**: Avoid deeply nested resource hierarchies
|
||||
4. **Ignoring HTTP Status Codes**: Use appropriate status codes for different scenarios
|
||||
5. **Poor Error Messages**: Provide actionable, specific error information
|
||||
6. **Missing Pagination**: Always paginate list endpoints
|
||||
7. **No Versioning Strategy**: Plan for API evolution from day one
|
||||
8. **Exposing Internal Structure**: Design APIs for external consumption, not internal convenience
|
||||
9. **Missing Rate Limiting**: Protect your API from abuse and overload
|
||||
10. **Inadequate Testing**: Test all aspects including error cases and edge conditions
|
||||
|
||||
## Conclusion
|
||||
|
||||
The API Design Reviewer skill provides a comprehensive framework for building, reviewing, and maintaining high-quality REST APIs. By following these guidelines and using the provided tools, development teams can create APIs that are consistent, well-documented, secure, and maintainable.
|
||||
|
||||
Regular use of the linting, breaking change detection, and scoring tools ensures continuous improvement and helps maintain API quality throughout the development lifecycle.
|
||||
686
docs/skills/engineering/api-test-suite-builder.md
Normal file
686
docs/skills/engineering/api-test-suite-builder.md
Normal file
@@ -0,0 +1,686 @@
|
||||
---
|
||||
title: "API Test Suite Builder"
|
||||
description: "API Test Suite Builder - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# API Test Suite Builder
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `api-test-suite-builder` | **Source:** [`engineering/api-test-suite-builder/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/api-test-suite-builder/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering
|
||||
**Domain:** Testing / API Quality
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Scans API route definitions across frameworks (Next.js App Router, Express, FastAPI, Django REST) and
|
||||
auto-generates comprehensive test suites covering auth, input validation, error codes, pagination, file
|
||||
uploads, and rate limiting. Outputs ready-to-run test files for Vitest+Supertest (Node) or Pytest+httpx
|
||||
(Python).
|
||||
|
||||
---
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- **Route detection** — scan source files to extract all API endpoints
|
||||
- **Auth coverage** — valid/invalid/expired tokens, missing auth header
|
||||
- **Input validation** — missing fields, wrong types, boundary values, injection attempts
|
||||
- **Error code matrix** — 400/401/403/404/422/500 for each route
|
||||
- **Pagination** — first/last/empty/oversized pages
|
||||
- **File uploads** — valid, oversized, wrong MIME type, empty
|
||||
- **Rate limiting** — burst detection, per-user vs global limits
|
||||
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
- New API added — generate test scaffold before writing implementation (TDD)
|
||||
- Legacy API with no tests — scan and generate baseline coverage
|
||||
- API contract review — verify existing tests match current route definitions
|
||||
- Pre-release regression check — ensure all routes have at least smoke tests
|
||||
- Security audit prep — generate adversarial input tests
|
||||
|
||||
---
|
||||
|
||||
## Route Detection
|
||||
|
||||
### Next.js App Router
|
||||
```bash
|
||||
# Find all route handlers
|
||||
find ./app/api -name "route.ts" -o -name "route.js" | sort
|
||||
|
||||
# Extract HTTP methods from each route file
|
||||
grep -rn "export async function\|export function" app/api/**/route.ts | \
|
||||
grep -oE "(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)" | sort -u
|
||||
|
||||
# Full route map
|
||||
find ./app/api -name "route.ts" | while read f; do
|
||||
route=$(echo $f | sed 's|./app||' | sed 's|/route.ts||')
|
||||
methods=$(grep -oE "export (async )?function (GET|POST|PUT|PATCH|DELETE)" "$f" | \
|
||||
grep -oE "(GET|POST|PUT|PATCH|DELETE)")
|
||||
echo "$methods $route"
|
||||
done
|
||||
```
|
||||
|
||||
### Express
|
||||
```bash
|
||||
# Find all router files
|
||||
find ./src -name "*.ts" -o -name "*.js" | xargs grep -l "router\.\(get\|post\|put\|delete\|patch\)" 2>/dev/null
|
||||
|
||||
# Extract routes with line numbers
|
||||
grep -rn "router\.\(get\|post\|put\|delete\|patch\)\|app\.\(get\|post\|put\|delete\|patch\)" \
|
||||
src/ --include="*.ts" | grep -oE "(get|post|put|delete|patch)\(['\"][^'\"]*['\"]"
|
||||
|
||||
# Generate route map
|
||||
grep -rn "router\.\|app\." src/ --include="*.ts" | \
|
||||
grep -oE "\.(get|post|put|delete|patch)\(['\"][^'\"]+['\"]" | \
|
||||
sed "s/\.\(.*\)('\(.*\)'/\U\1 \2/"
|
||||
```
|
||||
|
||||
### FastAPI
|
||||
```bash
|
||||
# Find all route decorators
|
||||
grep -rn "@app\.\|@router\." . --include="*.py" | \
|
||||
grep -E "@(app|router)\.(get|post|put|delete|patch)"
|
||||
|
||||
# Extract with path and function name
|
||||
grep -rn "@\(app\|router\)\.\(get\|post\|put\|delete\|patch\)" . --include="*.py" | \
|
||||
grep -oE "@(app|router)\.(get|post|put|delete|patch)\(['\"][^'\"]*['\"]"
|
||||
```
|
||||
|
||||
### Django REST Framework
|
||||
```bash
|
||||
# urlpatterns extraction
|
||||
grep -rn "path\|re_path\|url(" . --include="*.py" | grep "urlpatterns" -A 50 | \
|
||||
grep -E "path\(['\"]" | grep -oE "['\"][^'\"]+['\"]" | head -40
|
||||
|
||||
# ViewSet router registration
|
||||
grep -rn "router\.register\|DefaultRouter\|SimpleRouter" . --include="*.py"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Test Generation Patterns
|
||||
|
||||
### Auth Test Matrix
|
||||
|
||||
For every authenticated endpoint, generate:
|
||||
|
||||
| Test Case | Expected Status |
|
||||
|-----------|----------------|
|
||||
| No Authorization header | 401 |
|
||||
| Invalid token format | 401 |
|
||||
| Valid token, wrong user role | 403 |
|
||||
| Expired JWT token | 401 |
|
||||
| Valid token, correct role | 2xx |
|
||||
| Token from deleted user | 401 |
|
||||
|
||||
### Input Validation Matrix
|
||||
|
||||
For every POST/PUT/PATCH endpoint with a request body:
|
||||
|
||||
| Test Case | Expected Status |
|
||||
|-----------|----------------|
|
||||
| Empty body `{}` | 400 or 422 |
|
||||
| Missing required fields (one at a time) | 400 or 422 |
|
||||
| Wrong type (string where int expected) | 400 or 422 |
|
||||
| Boundary: value at min-1 | 400 or 422 |
|
||||
| Boundary: value at min | 2xx |
|
||||
| Boundary: value at max | 2xx |
|
||||
| Boundary: value at max+1 | 400 or 422 |
|
||||
| SQL injection in string field | 400 or 200 (sanitized) |
|
||||
| XSS payload in string field | 400 or 200 (sanitized) |
|
||||
| Null values for required fields | 400 or 422 |
|
||||
|
||||
---
|
||||
|
||||
## Example Test Files
|
||||
|
||||
### Example 1 — Node.js: Vitest + Supertest (Next.js API Route)
|
||||
|
||||
```typescript
|
||||
// tests/api/users.test.ts
|
||||
import { describe, it, expect, beforeAll, afterAll } from 'vitest'
|
||||
import request from 'supertest'
|
||||
import { createServer } from '@/test/helpers/server'
|
||||
import { generateJWT, generateExpiredJWT } from '@/test/helpers/auth'
|
||||
import { createTestUser, cleanupTestUsers } from '@/test/helpers/db'
|
||||
|
||||
const app = createServer()
|
||||
|
||||
describe('GET /api/users/:id', () => {
|
||||
let validToken: string
|
||||
let adminToken: string
|
||||
let testUserId: string
|
||||
|
||||
beforeAll(async () => {
|
||||
const user = await createTestUser({ role: 'user' })
|
||||
const admin = await createTestUser({ role: 'admin' })
|
||||
testUserId = user.id
|
||||
validToken = generateJWT(user)
|
||||
adminToken = generateJWT(admin)
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
await cleanupTestUsers()
|
||||
})
|
||||
|
||||
// --- Auth tests ---
|
||||
it('returns 401 with no auth header', async () => {
|
||||
const res = await request(app).get(`/api/users/${testUserId}`)
|
||||
expect(res.status).toBe(401)
|
||||
expect(res.body).toHaveProperty('error')
|
||||
})
|
||||
|
||||
it('returns 401 with malformed token', async () => {
|
||||
const res = await request(app)
|
||||
.get(`/api/users/${testUserId}`)
|
||||
.set('Authorization', 'Bearer not-a-real-jwt')
|
||||
expect(res.status).toBe(401)
|
||||
})
|
||||
|
||||
it('returns 401 with expired token', async () => {
|
||||
const expiredToken = generateExpiredJWT({ id: testUserId })
|
||||
const res = await request(app)
|
||||
.get(`/api/users/${testUserId}`)
|
||||
.set('Authorization', `Bearer ${expiredToken}`)
|
||||
expect(res.status).toBe(401)
|
||||
expect(res.body.error).toMatch(/expired/i)
|
||||
})
|
||||
|
||||
it('returns 403 when accessing another user\'s profile without admin', async () => {
|
||||
const otherUser = await createTestUser({ role: 'user' })
|
||||
const otherToken = generateJWT(otherUser)
|
||||
const res = await request(app)
|
||||
.get(`/api/users/${testUserId}`)
|
||||
.set('Authorization', `Bearer ${otherToken}`)
|
||||
expect(res.status).toBe(403)
|
||||
await cleanupTestUsers([otherUser.id])
|
||||
})
|
||||
|
||||
it('returns 200 with valid token for own profile', async () => {
|
||||
const res = await request(app)
|
||||
.get(`/api/users/${testUserId}`)
|
||||
.set('Authorization', `Bearer ${validToken}`)
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.body).toMatchObject({ id: testUserId })
|
||||
expect(res.body).not.toHaveProperty('password')
|
||||
expect(res.body).not.toHaveProperty('hashedPassword')
|
||||
})
|
||||
|
||||
it('returns 404 for non-existent user', async () => {
|
||||
const res = await request(app)
|
||||
.get('/api/users/00000000-0000-0000-0000-000000000000')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
expect(res.status).toBe(404)
|
||||
})
|
||||
|
||||
// --- Input validation ---
|
||||
it('returns 400 for invalid UUID format', async () => {
|
||||
const res = await request(app)
|
||||
.get('/api/users/not-a-uuid')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
expect(res.status).toBe(400)
|
||||
})
|
||||
})
|
||||
|
||||
describe('POST /api/users', () => {
|
||||
let adminToken: string
|
||||
|
||||
beforeAll(async () => {
|
||||
const admin = await createTestUser({ role: 'admin' })
|
||||
adminToken = generateJWT(admin)
|
||||
})
|
||||
|
||||
afterAll(cleanupTestUsers)
|
||||
|
||||
// --- Input validation ---
|
||||
it('returns 422 when body is empty', async () => {
|
||||
const res = await request(app)
|
||||
.post('/api/users')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({})
|
||||
expect(res.status).toBe(422)
|
||||
expect(res.body.errors).toBeDefined()
|
||||
})
|
||||
|
||||
it('returns 422 when email is missing', async () => {
|
||||
const res = await request(app)
|
||||
.post('/api/users')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({ name: 'Test User', role: 'user' })
|
||||
expect(res.status).toBe(422)
|
||||
expect(res.body.errors).toContainEqual(
|
||||
expect.objectContaining({ field: 'email' })
|
||||
)
|
||||
})
|
||||
|
||||
it('returns 422 for invalid email format', async () => {
|
||||
const res = await request(app)
|
||||
.post('/api/users')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({ email: 'not-an-email', name: 'Test', role: 'user' })
|
||||
expect(res.status).toBe(422)
|
||||
})
|
||||
|
||||
it('returns 422 for SQL injection attempt in email field', async () => {
|
||||
const res = await request(app)
|
||||
.post('/api/users')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({ email: "' OR '1'='1", name: 'Hacker', role: 'user' })
|
||||
expect(res.status).toBe(422)
|
||||
})
|
||||
|
||||
it('returns 409 when email already exists', async () => {
|
||||
const existing = await createTestUser({ role: 'user' })
|
||||
const res = await request(app)
|
||||
.post('/api/users')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({ email: existing.email, name: 'Duplicate', role: 'user' })
|
||||
expect(res.status).toBe(409)
|
||||
})
|
||||
|
||||
it('creates user successfully with valid data', async () => {
|
||||
const res = await request(app)
|
||||
.post('/api/users')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
.send({ email: 'newuser@example.com', name: 'New User', role: 'user' })
|
||||
expect(res.status).toBe(201)
|
||||
expect(res.body).toHaveProperty('id')
|
||||
expect(res.body.email).toBe('newuser@example.com')
|
||||
expect(res.body).not.toHaveProperty('password')
|
||||
})
|
||||
})
|
||||
|
||||
describe('GET /api/users (pagination)', () => {
|
||||
let adminToken: string
|
||||
|
||||
beforeAll(async () => {
|
||||
const admin = await createTestUser({ role: 'admin' })
|
||||
adminToken = generateJWT(admin)
|
||||
// Create 15 test users for pagination
|
||||
await Promise.all(Array.from({ length: 15 }, (_, i) =>
|
||||
createTestUser({ email: `pagtest${i}@example.com` })
|
||||
))
|
||||
})
|
||||
|
||||
afterAll(cleanupTestUsers)
|
||||
|
||||
it('returns first page with default limit', async () => {
|
||||
const res = await request(app)
|
||||
.get('/api/users')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.body.data).toBeInstanceOf(Array)
|
||||
expect(res.body).toHaveProperty('total')
|
||||
expect(res.body).toHaveProperty('page')
|
||||
expect(res.body).toHaveProperty('pageSize')
|
||||
})
|
||||
|
||||
it('returns empty array for page beyond total', async () => {
|
||||
const res = await request(app)
|
||||
.get('/api/users?page=9999')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.body.data).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('returns 400 for negative page number', async () => {
|
||||
const res = await request(app)
|
||||
.get('/api/users?page=-1')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
expect(res.status).toBe(400)
|
||||
})
|
||||
|
||||
it('caps pageSize at maximum allowed value', async () => {
|
||||
const res = await request(app)
|
||||
.get('/api/users?pageSize=9999')
|
||||
.set('Authorization', `Bearer ${adminToken}`)
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.body.data.length).toBeLessThanOrEqual(100)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Example 2 — Node.js: File Upload Tests
|
||||
|
||||
```typescript
|
||||
// tests/api/uploads.test.ts
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import request from 'supertest'
|
||||
import path from 'path'
|
||||
import fs from 'fs'
|
||||
import { createServer } from '@/test/helpers/server'
|
||||
import { generateJWT } from '@/test/helpers/auth'
|
||||
import { createTestUser } from '@/test/helpers/db'
|
||||
|
||||
const app = createServer()
|
||||
|
||||
describe('POST /api/upload', () => {
|
||||
let validToken: string
|
||||
|
||||
beforeAll(async () => {
|
||||
const user = await createTestUser({ role: 'user' })
|
||||
validToken = generateJWT(user)
|
||||
})
|
||||
|
||||
it('returns 401 without authentication', async () => {
|
||||
const res = await request(app)
|
||||
.post('/api/upload')
|
||||
.attach('file', Buffer.from('test'), 'test.pdf')
|
||||
expect(res.status).toBe(401)
|
||||
})
|
||||
|
||||
it('returns 400 when no file attached', async () => {
|
||||
const res = await request(app)
|
||||
.post('/api/upload')
|
||||
.set('Authorization', `Bearer ${validToken}`)
|
||||
expect(res.status).toBe(400)
|
||||
expect(res.body.error).toMatch(/file/i)
|
||||
})
|
||||
|
||||
it('returns 400 for unsupported file type (exe)', async () => {
|
||||
const res = await request(app)
|
||||
.post('/api/upload')
|
||||
.set('Authorization', `Bearer ${validToken}`)
|
||||
.attach('file', Buffer.from('MZ fake exe'), { filename: 'virus.exe', contentType: 'application/octet-stream' })
|
||||
expect(res.status).toBe(400)
|
||||
expect(res.body.error).toMatch(/type|format|allowed/i)
|
||||
})
|
||||
|
||||
it('returns 413 for oversized file (>10MB)', async () => {
|
||||
const largeBuf = Buffer.alloc(11 * 1024 * 1024) // 11MB
|
||||
const res = await request(app)
|
||||
.post('/api/upload')
|
||||
.set('Authorization', `Bearer ${validToken}`)
|
||||
.attach('file', largeBuf, { filename: 'large.pdf', contentType: 'application/pdf' })
|
||||
expect(res.status).toBe(413)
|
||||
})
|
||||
|
||||
it('returns 400 for empty file (0 bytes)', async () => {
|
||||
const res = await request(app)
|
||||
.post('/api/upload')
|
||||
.set('Authorization', `Bearer ${validToken}`)
|
||||
.attach('file', Buffer.alloc(0), { filename: 'empty.pdf', contentType: 'application/pdf' })
|
||||
expect(res.status).toBe(400)
|
||||
})
|
||||
|
||||
it('rejects MIME type spoofing (pdf extension but exe content)', async () => {
|
||||
// Real malicious file: exe magic bytes but pdf extension
|
||||
const fakeExe = Buffer.from('4D5A9000', 'hex') // MZ header
|
||||
const res = await request(app)
|
||||
.post('/api/upload')
|
||||
.set('Authorization', `Bearer ${validToken}`)
|
||||
.attach('file', fakeExe, { filename: 'document.pdf', contentType: 'application/pdf' })
|
||||
// Should detect magic bytes mismatch
|
||||
expect([400, 415]).toContain(res.status)
|
||||
})
|
||||
|
||||
it('accepts valid PDF file', async () => {
|
||||
const pdfHeader = Buffer.from('%PDF-1.4 test content')
|
||||
const res = await request(app)
|
||||
.post('/api/upload')
|
||||
.set('Authorization', `Bearer ${validToken}`)
|
||||
.attach('file', pdfHeader, { filename: 'valid.pdf', contentType: 'application/pdf' })
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.body).toHaveProperty('url')
|
||||
expect(res.body).toHaveProperty('id')
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Example 3 — Python: Pytest + httpx (FastAPI)
|
||||
|
||||
```python
|
||||
# tests/api/test_items.py
|
||||
import pytest
|
||||
import httpx
|
||||
from datetime import datetime, timedelta
|
||||
import jwt
|
||||
|
||||
BASE_URL = "http://localhost:8000"
|
||||
JWT_SECRET = "test-secret" # use test config, never production secret
|
||||
|
||||
|
||||
def make_token(user_id: str, role: str = "user", expired: bool = False) -> str:
|
||||
exp = datetime.utcnow() + (timedelta(hours=-1) if expired else timedelta(hours=1))
|
||||
return jwt.encode(
|
||||
{"sub": user_id, "role": role, "exp": exp},
|
||||
JWT_SECRET,
|
||||
algorithm="HS256",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
with httpx.Client(base_url=BASE_URL) as c:
|
||||
yield c
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def valid_token():
|
||||
return make_token("user-123", role="user")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def admin_token():
|
||||
return make_token("admin-456", role="admin")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def expired_token():
|
||||
return make_token("user-123", expired=True)
|
||||
|
||||
|
||||
class TestGetItem:
|
||||
def test_returns_401_without_auth(self, client):
|
||||
res = client.get("/api/items/1")
|
||||
assert res.status_code == 401
|
||||
|
||||
def test_returns_401_with_invalid_token(self, client):
|
||||
res = client.get("/api/items/1", headers={"Authorization": "Bearer garbage"})
|
||||
assert res.status_code == 401
|
||||
|
||||
def test_returns_401_with_expired_token(self, client, expired_token):
|
||||
res = client.get("/api/items/1", headers={"Authorization": f"Bearer {expired_token}"})
|
||||
assert res.status_code == 401
|
||||
assert "expired" in res.json().get("detail", "").lower()
|
||||
|
||||
def test_returns_404_for_nonexistent_item(self, client, valid_token):
|
||||
res = client.get(
|
||||
"/api/items/99999999",
|
||||
headers={"Authorization": f"Bearer {valid_token}"},
|
||||
)
|
||||
assert res.status_code == 404
|
||||
|
||||
def test_returns_400_for_invalid_id_format(self, client, valid_token):
|
||||
res = client.get(
|
||||
"/api/items/not-a-number",
|
||||
headers={"Authorization": f"Bearer {valid_token}"},
|
||||
)
|
||||
assert res.status_code in (400, 422)
|
||||
|
||||
def test_returns_200_with_valid_auth(self, client, valid_token, test_item):
|
||||
res = client.get(
|
||||
f"/api/items/{test_item['id']}",
|
||||
headers={"Authorization": f"Bearer {valid_token}"},
|
||||
)
|
||||
assert res.status_code == 200
|
||||
data = res.json()
|
||||
assert data["id"] == test_item["id"]
|
||||
assert "password" not in data
|
||||
|
||||
|
||||
class TestCreateItem:
|
||||
def test_returns_422_with_empty_body(self, client, admin_token):
|
||||
res = client.post(
|
||||
"/api/items",
|
||||
json={},
|
||||
headers={"Authorization": f"Bearer {admin_token}"},
|
||||
)
|
||||
assert res.status_code == 422
|
||||
errors = res.json()["detail"]
|
||||
assert len(errors) > 0
|
||||
|
||||
def test_returns_422_with_missing_required_field(self, client, admin_token):
|
||||
res = client.post(
|
||||
"/api/items",
|
||||
json={"description": "no name field"},
|
||||
headers={"Authorization": f"Bearer {admin_token}"},
|
||||
)
|
||||
assert res.status_code == 422
|
||||
fields = [e["loc"][-1] for e in res.json()["detail"]]
|
||||
assert "name" in fields
|
||||
|
||||
def test_returns_422_with_wrong_type(self, client, admin_token):
|
||||
res = client.post(
|
||||
"/api/items",
|
||||
json={"name": "test", "price": "not-a-number"},
|
||||
headers={"Authorization": f"Bearer {admin_token}"},
|
||||
)
|
||||
assert res.status_code == 422
|
||||
|
||||
@pytest.mark.parametrize("price", [-1, -0.01])
|
||||
def test_returns_422_for_negative_price(self, client, admin_token, price):
|
||||
res = client.post(
|
||||
"/api/items",
|
||||
json={"name": "test", "price": price},
|
||||
headers={"Authorization": f"Bearer {admin_token}"},
|
||||
)
|
||||
assert res.status_code == 422
|
||||
|
||||
def test_returns_422_for_price_exceeding_max(self, client, admin_token):
|
||||
res = client.post(
|
||||
"/api/items",
|
||||
json={"name": "test", "price": 1_000_001},
|
||||
headers={"Authorization": f"Bearer {admin_token}"},
|
||||
)
|
||||
assert res.status_code == 422
|
||||
|
||||
def test_creates_item_successfully(self, client, admin_token):
|
||||
res = client.post(
|
||||
"/api/items",
|
||||
json={"name": "New Widget", "price": 9.99, "category": "tools"},
|
||||
headers={"Authorization": f"Bearer {admin_token}"},
|
||||
)
|
||||
assert res.status_code == 201
|
||||
data = res.json()
|
||||
assert "id" in data
|
||||
assert data["name"] == "New Widget"
|
||||
|
||||
def test_returns_403_for_non_admin(self, client, valid_token):
|
||||
res = client.post(
|
||||
"/api/items",
|
||||
json={"name": "test", "price": 1.0},
|
||||
headers={"Authorization": f"Bearer {valid_token}"},
|
||||
)
|
||||
assert res.status_code == 403
|
||||
|
||||
|
||||
class TestPagination:
|
||||
def test_returns_paginated_response(self, client, valid_token):
|
||||
res = client.get(
|
||||
"/api/items?page=1&size=10",
|
||||
headers={"Authorization": f"Bearer {valid_token}"},
|
||||
)
|
||||
assert res.status_code == 200
|
||||
data = res.json()
|
||||
assert "items" in data
|
||||
assert "total" in data
|
||||
assert "page" in data
|
||||
assert len(data["items"]) <= 10
|
||||
|
||||
def test_empty_result_for_out_of_range_page(self, client, valid_token):
|
||||
res = client.get(
|
||||
"/api/items?page=99999",
|
||||
headers={"Authorization": f"Bearer {valid_token}"},
|
||||
)
|
||||
assert res.status_code == 200
|
||||
assert res.json()["items"] == []
|
||||
|
||||
def test_returns_422_for_page_zero(self, client, valid_token):
|
||||
res = client.get(
|
||||
"/api/items?page=0",
|
||||
headers={"Authorization": f"Bearer {valid_token}"},
|
||||
)
|
||||
assert res.status_code == 422
|
||||
|
||||
def test_caps_page_size_at_maximum(self, client, valid_token):
|
||||
res = client.get(
|
||||
"/api/items?size=9999",
|
||||
headers={"Authorization": f"Bearer {valid_token}"},
|
||||
)
|
||||
assert res.status_code == 200
|
||||
assert len(res.json()["items"]) <= 100 # max page size
|
||||
|
||||
|
||||
class TestRateLimiting:
|
||||
def test_rate_limit_after_burst(self, client, valid_token):
|
||||
responses = []
|
||||
for _ in range(60): # exceed typical 50/min limit
|
||||
res = client.get(
|
||||
"/api/items",
|
||||
headers={"Authorization": f"Bearer {valid_token}"},
|
||||
)
|
||||
responses.append(res.status_code)
|
||||
if res.status_code == 429:
|
||||
break
|
||||
assert 429 in responses, "Rate limit was not triggered"
|
||||
|
||||
def test_rate_limit_response_has_retry_after(self, client, valid_token):
|
||||
for _ in range(60):
|
||||
res = client.get("/api/items", headers={"Authorization": f"Bearer {valid_token}"})
|
||||
if res.status_code == 429:
|
||||
assert "Retry-After" in res.headers or "retry_after" in res.json()
|
||||
break
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Generating Tests from Route Scan
|
||||
|
||||
When given a codebase, follow this process:
|
||||
|
||||
1. **Scan routes** using the detection commands above
|
||||
2. **Read each route handler** to understand:
|
||||
- Expected request body schema
|
||||
- Auth requirements (middleware, decorators)
|
||||
- Return types and status codes
|
||||
- Business rules (ownership, role checks)
|
||||
3. **Generate test file** per route group using the patterns above
|
||||
4. **Name tests descriptively**: `"returns 401 when token is expired"` not `"auth test 3"`
|
||||
5. **Use factories/fixtures** for test data — never hardcode IDs
|
||||
6. **Assert response shape**, not just status code
|
||||
|
||||
---
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
- **Testing only happy paths** — 80% of bugs live in error paths; test those first
|
||||
- **Hardcoded test data IDs** — use factories/fixtures; IDs change between environments
|
||||
- **Shared state between tests** — always clean up in afterEach/afterAll
|
||||
- **Testing implementation, not behavior** — test what the API returns, not how it does it
|
||||
- **Missing boundary tests** — off-by-one errors are extremely common in pagination and limits
|
||||
- **Not testing token expiry** — expired tokens behave differently from invalid ones
|
||||
- **Ignoring Content-Type** — test that API rejects wrong content types (xml when json expected)
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. One describe block per endpoint — keeps failures isolated and readable
|
||||
2. Seed minimal data — don't load the entire DB; create only what the test needs
|
||||
3. Use `beforeAll` for shared setup, `afterAll` for cleanup — not `beforeEach` for expensive ops
|
||||
4. Assert specific error messages/fields, not just status codes
|
||||
5. Test that sensitive fields (password, secret) are never in responses
|
||||
6. For auth tests, always test the "missing header" case separately from "invalid token"
|
||||
7. Add rate limit tests last — they can interfere with other test suites if run in parallel
|
||||
170
docs/skills/engineering/changelog-generator.md
Normal file
170
docs/skills/engineering/changelog-generator.md
Normal file
@@ -0,0 +1,170 @@
|
||||
---
|
||||
title: "Changelog Generator"
|
||||
description: "Changelog Generator - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Changelog Generator
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `changelog-generator` | **Source:** [`engineering/changelog-generator/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/changelog-generator/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering
|
||||
**Domain:** Release Management / Documentation
|
||||
|
||||
## Overview
|
||||
|
||||
Use this skill to produce consistent, auditable release notes from Conventional Commits. It separates commit parsing, semantic bump logic, and changelog rendering so teams can automate releases without losing editorial control.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- Parse commit messages using Conventional Commit rules
|
||||
- Detect semantic bump (`major`, `minor`, `patch`) from commit stream
|
||||
- Render Keep a Changelog sections (`Added`, `Changed`, `Fixed`, etc.)
|
||||
- Generate release entries from git ranges or provided commit input
|
||||
- Enforce commit format with a dedicated linter script
|
||||
- Support CI integration via machine-readable JSON output
|
||||
|
||||
## When to Use
|
||||
|
||||
- Before publishing a release tag
|
||||
- During CI to generate release notes automatically
|
||||
- During PR checks to block invalid commit message formats
|
||||
- In monorepos where package changelogs require scoped filtering
|
||||
- When converting raw git history into user-facing notes
|
||||
|
||||
## Key Workflows
|
||||
|
||||
### 1. Generate Changelog Entry From Git
|
||||
|
||||
```bash
|
||||
python3 scripts/generate_changelog.py \
|
||||
--from-tag v1.3.0 \
|
||||
--to-tag v1.4.0 \
|
||||
--next-version v1.4.0 \
|
||||
--format markdown
|
||||
```
|
||||
|
||||
### 2. Generate Entry From stdin/File Input
|
||||
|
||||
```bash
|
||||
git log v1.3.0..v1.4.0 --pretty=format:'%s' | \
|
||||
python3 scripts/generate_changelog.py --next-version v1.4.0 --format markdown
|
||||
|
||||
python3 scripts/generate_changelog.py --input commits.txt --next-version v1.4.0 --format json
|
||||
```
|
||||
|
||||
### 3. Update `CHANGELOG.md`
|
||||
|
||||
```bash
|
||||
python3 scripts/generate_changelog.py \
|
||||
--from-tag v1.3.0 \
|
||||
--to-tag HEAD \
|
||||
--next-version v1.4.0 \
|
||||
--write CHANGELOG.md
|
||||
```
|
||||
|
||||
### 4. Lint Commits Before Merge
|
||||
|
||||
```bash
|
||||
python3 scripts/commit_linter.py --from-ref origin/main --to-ref HEAD --strict --format text
|
||||
```
|
||||
|
||||
Or file/stdin:
|
||||
|
||||
```bash
|
||||
python3 scripts/commit_linter.py --input commits.txt --strict
|
||||
cat commits.txt | python3 scripts/commit_linter.py --format json
|
||||
```
|
||||
|
||||
## Conventional Commit Rules
|
||||
|
||||
Supported types:
|
||||
|
||||
- `feat`, `fix`, `perf`, `refactor`, `docs`, `test`, `build`, `ci`, `chore`
|
||||
- `security`, `deprecated`, `remove`
|
||||
|
||||
Breaking changes:
|
||||
|
||||
- `type(scope)!: summary`
|
||||
- Footer/body includes `BREAKING CHANGE:`
|
||||
|
||||
SemVer mapping:
|
||||
|
||||
- breaking -> `major`
|
||||
- non-breaking `feat` -> `minor`
|
||||
- all others -> `patch`
|
||||
|
||||
## Script Interfaces
|
||||
|
||||
- `python3 scripts/generate_changelog.py --help`
|
||||
- Reads commits from git or stdin/`--input`
|
||||
- Renders markdown or JSON
|
||||
- Optional in-place changelog prepend
|
||||
- `python3 scripts/commit_linter.py --help`
|
||||
- Validates commit format
|
||||
- Returns non-zero in `--strict` mode on violations
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
1. Mixing merge commit messages with release commit parsing
|
||||
2. Using vague commit summaries that cannot become release notes
|
||||
3. Failing to include migration guidance for breaking changes
|
||||
4. Treating docs/chore changes as user-facing features
|
||||
5. Overwriting historical changelog sections instead of prepending
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. Keep commits small and intent-driven.
|
||||
2. Scope commit messages (`feat(api): ...`) in multi-package repos.
|
||||
3. Enforce linter checks in PR pipelines.
|
||||
4. Review generated markdown before publishing.
|
||||
5. Tag releases only after changelog generation succeeds.
|
||||
6. Keep an `[Unreleased]` section for manual curation when needed.
|
||||
|
||||
## References
|
||||
|
||||
- [references/ci-integration.md](references/ci-integration.md)
|
||||
- [references/changelog-formatting-guide.md](references/changelog-formatting-guide.md)
|
||||
- [references/monorepo-strategy.md](references/monorepo-strategy.md)
|
||||
- [README.md](README.md)
|
||||
|
||||
## Release Governance
|
||||
|
||||
Use this release flow for predictability:
|
||||
|
||||
1. Lint commit history for target release range.
|
||||
2. Generate changelog draft from commits.
|
||||
3. Manually adjust wording for customer clarity.
|
||||
4. Validate semver bump recommendation.
|
||||
5. Tag release only after changelog is approved.
|
||||
|
||||
## Output Quality Checks
|
||||
|
||||
- Each bullet is user-meaningful, not implementation noise.
|
||||
- Breaking changes include migration action.
|
||||
- Security fixes are isolated in `Security` section.
|
||||
- Sections with no entries are omitted.
|
||||
- Duplicate bullets across sections are removed.
|
||||
|
||||
## CI Policy
|
||||
|
||||
- Run `commit_linter.py --strict` on all PRs.
|
||||
- Block merge on invalid conventional commits.
|
||||
- Auto-generate draft release notes on tag push.
|
||||
- Require human approval before writing into `CHANGELOG.md` on main branch.
|
||||
|
||||
## Monorepo Guidance
|
||||
|
||||
- Prefer commit scopes aligned to package names.
|
||||
- Filter commit stream by scope for package-specific releases.
|
||||
- Keep infra-wide changes in root changelog.
|
||||
- Store package changelogs near package roots for ownership clarity.
|
||||
|
||||
## Failure Handling
|
||||
|
||||
- If no valid conventional commits found: fail early, do not generate misleading empty notes.
|
||||
- If git range invalid: surface explicit range in error output.
|
||||
- If write target missing: create safe changelog header scaffolding.
|
||||
152
docs/skills/engineering/ci-cd-pipeline-builder.md
Normal file
152
docs/skills/engineering/ci-cd-pipeline-builder.md
Normal file
@@ -0,0 +1,152 @@
|
||||
---
|
||||
title: "CI/CD Pipeline Builder"
|
||||
description: "CI/CD Pipeline Builder - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# CI/CD Pipeline Builder
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `ci-cd-pipeline-builder` | **Source:** [`engineering/ci-cd-pipeline-builder/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/ci-cd-pipeline-builder/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering
|
||||
**Domain:** DevOps / Automation
|
||||
|
||||
## Overview
|
||||
|
||||
Use this skill to generate pragmatic CI/CD pipelines from detected project stack signals, not guesswork. It focuses on fast baseline generation, repeatable checks, and environment-aware deployment stages.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- Detect language/runtime/tooling from repository files
|
||||
- Recommend CI stages (`lint`, `test`, `build`, `deploy`)
|
||||
- Generate GitHub Actions or GitLab CI starter pipelines
|
||||
- Include caching and matrix strategy based on detected stack
|
||||
- Emit machine-readable detection output for automation
|
||||
- Keep pipeline logic aligned with project lockfiles and build commands
|
||||
|
||||
## When to Use
|
||||
|
||||
- Bootstrapping CI for a new repository
|
||||
- Replacing brittle copied pipeline files
|
||||
- Migrating between GitHub Actions and GitLab CI
|
||||
- Auditing whether pipeline steps match actual stack
|
||||
- Creating a reproducible baseline before custom hardening
|
||||
|
||||
## Key Workflows
|
||||
|
||||
### 1. Detect Stack
|
||||
|
||||
```bash
|
||||
python3 scripts/stack_detector.py --repo . --format text
|
||||
python3 scripts/stack_detector.py --repo . --format json > detected-stack.json
|
||||
```
|
||||
|
||||
Supports input via stdin or `--input` file for offline analysis payloads.
|
||||
|
||||
### 2. Generate Pipeline From Detection
|
||||
|
||||
```bash
|
||||
python3 scripts/pipeline_generator.py \
|
||||
--input detected-stack.json \
|
||||
--platform github \
|
||||
--output .github/workflows/ci.yml \
|
||||
--format text
|
||||
```
|
||||
|
||||
Or end-to-end from repo directly:
|
||||
|
||||
```bash
|
||||
python3 scripts/pipeline_generator.py --repo . --platform gitlab --output .gitlab-ci.yml
|
||||
```
|
||||
|
||||
### 3. Validate Before Merge
|
||||
|
||||
1. Confirm commands exist in project (`test`, `lint`, `build`).
|
||||
2. Run generated pipeline locally where possible.
|
||||
3. Ensure required secrets/env vars are documented.
|
||||
4. Keep deploy jobs gated by protected branches/environments.
|
||||
|
||||
### 4. Add Deployment Stages Safely
|
||||
|
||||
- Start with CI-only (`lint/test/build`).
|
||||
- Add staging deploy with explicit environment context.
|
||||
- Add production deploy with manual gate/approval.
|
||||
- Keep rollout/rollback commands explicit and auditable.
|
||||
|
||||
## Script Interfaces
|
||||
|
||||
- `python3 scripts/stack_detector.py --help`
|
||||
- Detects stack signals from repository files
|
||||
- Reads optional JSON input from stdin/`--input`
|
||||
- `python3 scripts/pipeline_generator.py --help`
|
||||
- Generates GitHub/GitLab YAML from detection payload
|
||||
- Writes to stdout or `--output`
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
1. Copying a Node pipeline into Python/Go repos
|
||||
2. Enabling deploy jobs before stable tests
|
||||
3. Forgetting dependency cache keys
|
||||
4. Running expensive matrix builds for every trivial branch
|
||||
5. Missing branch protections around prod deploy jobs
|
||||
6. Hardcoding secrets in YAML instead of CI secret stores
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. Detect stack first, then generate pipeline.
|
||||
2. Keep generated baseline under version control.
|
||||
3. Add one optimization at a time (cache, matrix, split jobs).
|
||||
4. Require green CI before deployment jobs.
|
||||
5. Use protected environments for production credentials.
|
||||
6. Regenerate pipeline when stack changes significantly.
|
||||
|
||||
## References
|
||||
|
||||
- [references/github-actions-templates.md](references/github-actions-templates.md)
|
||||
- [references/gitlab-ci-templates.md](references/gitlab-ci-templates.md)
|
||||
- [references/deployment-gates.md](references/deployment-gates.md)
|
||||
- [README.md](README.md)
|
||||
|
||||
## Detection Heuristics
|
||||
|
||||
The stack detector prioritizes deterministic file signals over heuristics:
|
||||
|
||||
- Lockfiles determine package manager preference
|
||||
- Language manifests determine runtime families
|
||||
- Script commands (if present) drive lint/test/build commands
|
||||
- Missing scripts trigger conservative placeholder commands
|
||||
|
||||
## Generation Strategy
|
||||
|
||||
Start with a minimal, reliable pipeline:
|
||||
|
||||
1. Checkout and setup runtime
|
||||
2. Install dependencies with cache strategy
|
||||
3. Run lint, test, build in separate steps
|
||||
4. Publish artifacts only after passing checks
|
||||
|
||||
Then layer advanced behavior (matrix builds, security scans, deploy gates).
|
||||
|
||||
## Platform Decision Notes
|
||||
|
||||
- GitHub Actions for tight GitHub ecosystem integration
|
||||
- GitLab CI for integrated SCM + CI in self-hosted environments
|
||||
- Keep one canonical pipeline source per repo to reduce drift
|
||||
|
||||
## Validation Checklist
|
||||
|
||||
1. Generated YAML parses successfully.
|
||||
2. All referenced commands exist in the repo.
|
||||
3. Cache strategy matches package manager.
|
||||
4. Required secrets are documented, not embedded.
|
||||
5. Branch/protected-environment rules match org policy.
|
||||
|
||||
## Scaling Guidance
|
||||
|
||||
- Split long jobs by stage when runtime exceeds 10 minutes.
|
||||
- Introduce test matrix only when compatibility truly requires it.
|
||||
- Separate deploy jobs from CI jobs to keep feedback fast.
|
||||
- Track pipeline duration and flakiness as first-class metrics.
|
||||
507
docs/skills/engineering/codebase-onboarding.md
Normal file
507
docs/skills/engineering/codebase-onboarding.md
Normal file
@@ -0,0 +1,507 @@
|
||||
---
|
||||
title: "Codebase Onboarding"
|
||||
description: "Codebase Onboarding - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Codebase Onboarding
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `codebase-onboarding` | **Source:** [`engineering/codebase-onboarding/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/codebase-onboarding/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering
|
||||
**Domain:** Documentation / Developer Experience
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Analyze a codebase and generate comprehensive onboarding documentation tailored to your audience. Produces architecture overviews, key file maps, local setup guides, common task runbooks, debugging guides, and contribution guidelines. Outputs to Markdown, Notion, or Confluence.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- **Architecture overview** — tech stack, system boundaries, data flow diagrams
|
||||
- **Key file map** — what's important and why, with annotations
|
||||
- **Local setup guide** — step-by-step from clone to running tests
|
||||
- **Common developer tasks** — how to add a route, run migrations, create a component
|
||||
- **Debugging guide** — common errors, log locations, useful queries
|
||||
- **Contribution guidelines** — branch strategy, PR process, code style
|
||||
- **Audience-aware output** — junior, senior, or contractor mode
|
||||
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
- Onboarding a new team member or contractor
|
||||
- After a major refactor that made existing docs stale
|
||||
- Before open-sourcing a project
|
||||
- Creating a team wiki page for a service
|
||||
- Self-documenting before a long vacation
|
||||
|
||||
---
|
||||
|
||||
## Codebase Analysis Commands
|
||||
|
||||
Run these before generating docs to gather facts:
|
||||
|
||||
```bash
|
||||
# Project overview
|
||||
cat package.json | jq '{name, version, scripts, dependencies: (.dependencies | keys), devDependencies: (.devDependencies | keys)}'
|
||||
|
||||
# Directory structure (top 2 levels)
|
||||
find . -maxdepth 2 -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/.next/*' | sort | head -60
|
||||
|
||||
# Largest files (often core modules)
|
||||
find src/ -name "*.ts" -not -path "*/test*" -exec wc -l {} + | sort -rn | head -20
|
||||
|
||||
# All routes (Next.js App Router)
|
||||
find app/ -name "route.ts" -o -name "page.tsx" | sort
|
||||
|
||||
# All routes (Express)
|
||||
grep -rn "router\.\(get\|post\|put\|patch\|delete\)" src/routes/ --include="*.ts"
|
||||
|
||||
# Recent major changes
|
||||
git log --oneline --since="90 days ago" | grep -E "feat|refactor|breaking"
|
||||
|
||||
# Top contributors
|
||||
git shortlog -sn --no-merges | head -10
|
||||
|
||||
# Test coverage summary
|
||||
pnpm test:ci --coverage 2>&1 | tail -20
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Generated Documentation Template
|
||||
|
||||
### README.md — Full Template
|
||||
|
||||
```markdown
|
||||
# [Project Name]
|
||||
|
||||
> One-sentence description of what this does and who uses it.
|
||||
|
||||
[](https://github.com/org/repo/actions/workflows/ci.yml)
|
||||
[](https://codecov.io/gh/org/repo)
|
||||
|
||||
## What is this?
|
||||
|
||||
[2-3 sentences: problem it solves, who uses it, current state]
|
||||
|
||||
**Live:** https://myapp.com
|
||||
**Staging:** https://staging.myapp.com
|
||||
**Docs:** https://docs.myapp.com
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Prerequisites
|
||||
|
||||
| Tool | Version | Install |
|
||||
|------|---------|---------|
|
||||
| Node.js | 20+ | `nvm install 20` |
|
||||
| pnpm | 8+ | `npm i -g pnpm` |
|
||||
| Docker | 24+ | [docker.com](https://docker.com) |
|
||||
| PostgreSQL | 16+ | via Docker (see below) |
|
||||
|
||||
### Setup (5 minutes)
|
||||
|
||||
```bash
|
||||
# 1. Clone
|
||||
git clone https://github.com/org/repo
|
||||
cd repo
|
||||
|
||||
# 2. Install dependencies
|
||||
pnpm install
|
||||
|
||||
# 3. Start infrastructure
|
||||
docker compose up -d # Starts Postgres, Redis
|
||||
|
||||
# 4. Environment
|
||||
cp .env.example .env
|
||||
# Edit .env — ask a teammate for real values or see Vault
|
||||
|
||||
# 5. Database setup
|
||||
pnpm db:migrate # Run migrations
|
||||
pnpm db:seed # Optional: load test data
|
||||
|
||||
# 6. Start dev server
|
||||
pnpm dev # → http://localhost:3000
|
||||
|
||||
# 7. Verify
|
||||
pnpm test # Should be all green
|
||||
```
|
||||
|
||||
### Verify it works
|
||||
|
||||
- [ ] `http://localhost:3000` loads the app
|
||||
- [ ] `http://localhost:3000/api/health` returns `{"status":"ok"}`
|
||||
- [ ] `pnpm test` passes
|
||||
|
||||
---
|
||||
|
||||
## Architecture
|
||||
|
||||
### System Overview
|
||||
|
||||
```
|
||||
Browser / Mobile
|
||||
│
|
||||
▼
|
||||
[Next.js App] ←──── [Auth: NextAuth]
|
||||
│
|
||||
├──→ [PostgreSQL] (primary data store)
|
||||
├──→ [Redis] (sessions, job queue)
|
||||
└──→ [S3] (file uploads)
|
||||
|
||||
Background:
|
||||
[BullMQ workers] ←── Redis queue
|
||||
└──→ [External APIs: Stripe, SendGrid]
|
||||
```
|
||||
|
||||
### Tech Stack
|
||||
|
||||
| Layer | Technology | Why |
|
||||
|-------|-----------|-----|
|
||||
| Frontend | Next.js 14 (App Router) | SSR, file-based routing |
|
||||
| Styling | Tailwind CSS + shadcn/ui | Rapid UI development |
|
||||
| API | Next.js Route Handlers | Co-located with frontend |
|
||||
| Database | PostgreSQL 16 | Relational, RLS for multi-tenancy |
|
||||
| ORM | Drizzle ORM | Type-safe, lightweight |
|
||||
| Auth | NextAuth v5 | OAuth + email/password |
|
||||
| Queue | BullMQ + Redis | Background jobs |
|
||||
| Storage | AWS S3 | File uploads |
|
||||
| Email | SendGrid | Transactional email |
|
||||
| Payments | Stripe | Subscriptions |
|
||||
| Deployment | Vercel (app) + Railway (workers) | |
|
||||
| Monitoring | Sentry + Datadog | |
|
||||
|
||||
---
|
||||
|
||||
## Key Files
|
||||
|
||||
| Path | Purpose |
|
||||
|------|---------|
|
||||
| `app/` | Next.js App Router — pages and API routes |
|
||||
| `app/api/` | API route handlers |
|
||||
| `app/(auth)/` | Auth pages (login, register, reset) |
|
||||
| `app/(app)/` | Protected app pages |
|
||||
| `src/db/` | Database schema, migrations, client |
|
||||
| `src/db/schema.ts` | **Drizzle schema — single source of truth** |
|
||||
| `src/lib/` | Shared utilities (auth, email, stripe) |
|
||||
| `src/lib/auth.ts` | **Auth configuration — read this first** |
|
||||
| `src/components/` | Reusable React components |
|
||||
| `src/hooks/` | Custom React hooks |
|
||||
| `src/types/` | Shared TypeScript types |
|
||||
| `workers/` | BullMQ background job processors |
|
||||
| `emails/` | React Email templates |
|
||||
| `tests/` | Test helpers, factories, integration tests |
|
||||
| `.env.example` | All env vars with descriptions |
|
||||
| `docker-compose.yml` | Local infrastructure |
|
||||
|
||||
---
|
||||
|
||||
## Common Developer Tasks
|
||||
|
||||
### Add a new API endpoint
|
||||
|
||||
```bash
|
||||
# 1. Create route handler
|
||||
touch app/api/my-resource/route.ts
|
||||
```
|
||||
|
||||
```typescript
|
||||
// app/api/my-resource/route.ts
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { auth } from '@/lib/auth'
|
||||
import { db } from '@/db/client'
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const session = await auth()
|
||||
if (!session) {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
||||
}
|
||||
|
||||
const data = await db.query.myResource.findMany({
|
||||
where: (r, { eq }) => eq(r.userId, session.user.id),
|
||||
})
|
||||
|
||||
return NextResponse.json({ data })
|
||||
}
|
||||
```
|
||||
|
||||
```bash
|
||||
# 2. Add tests
|
||||
touch tests/api/my-resource.test.ts
|
||||
|
||||
# 3. Add to OpenAPI spec (if applicable)
|
||||
pnpm generate:openapi
|
||||
```
|
||||
|
||||
### Run a database migration
|
||||
|
||||
```bash
|
||||
# Create migration
|
||||
pnpm db:generate # Generates SQL from schema changes
|
||||
|
||||
# Review the generated SQL
|
||||
cat drizzle/migrations/0001_my_change.sql
|
||||
|
||||
# Apply
|
||||
pnpm db:migrate
|
||||
|
||||
# Roll back (manual — inspect generated SQL and revert)
|
||||
psql $DATABASE_URL -f scripts/rollback_0001.sql
|
||||
```
|
||||
|
||||
### Add a new email template
|
||||
|
||||
```bash
|
||||
# 1. Create template
|
||||
touch emails/my-email.tsx
|
||||
|
||||
# 2. Preview in browser
|
||||
pnpm email:preview
|
||||
|
||||
# 3. Send in code
|
||||
import { sendEmail } from '@/lib/email'
|
||||
await sendEmail({
|
||||
to: user.email,
|
||||
subject: 'Subject line',
|
||||
template: 'my-email',
|
||||
props: { name: user.name },
|
||||
})
|
||||
```
|
||||
|
||||
### Add a background job
|
||||
|
||||
```typescript
|
||||
// 1. Define job in workers/jobs/my-job.ts
|
||||
import { Queue, Worker } from 'bullmq'
|
||||
import { redis } from '@/lib/redis'
|
||||
|
||||
export const myJobQueue = new Queue('my-job', { connection: redis })
|
||||
|
||||
export const myJobWorker = new Worker('my-job', async (job) => {
|
||||
const { userId, data } = job.data
|
||||
// do work
|
||||
}, { connection: redis })
|
||||
|
||||
// 2. Enqueue
|
||||
await myJobQueue.add('process', { userId, data }, {
|
||||
attempts: 3,
|
||||
backoff: { type: 'exponential', delay: 1000 },
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Debugging Guide
|
||||
|
||||
### Common Errors
|
||||
|
||||
**`Error: DATABASE_URL is not set`**
|
||||
```bash
|
||||
# Check your .env file exists and has the var
|
||||
cat .env | grep DATABASE_URL
|
||||
|
||||
# Start Postgres if not running
|
||||
docker compose up -d postgres
|
||||
```
|
||||
|
||||
**`PrismaClientKnownRequestError: P2002 Unique constraint failed`**
|
||||
```
|
||||
User already exists with that email. Check: is this a duplicate registration?
|
||||
Run: SELECT * FROM users WHERE email = 'test@example.com';
|
||||
```
|
||||
|
||||
**`Error: JWT expired`**
|
||||
```bash
|
||||
# Dev: extend token TTL in .env
|
||||
JWT_EXPIRES_IN=30d
|
||||
|
||||
# Check clock skew between server and client
|
||||
date && docker exec postgres date
|
||||
```
|
||||
|
||||
**`500 on /api/*` in local dev**
|
||||
```bash
|
||||
# 1. Check terminal for stack trace
|
||||
# 2. Check database connectivity
|
||||
psql $DATABASE_URL -c "SELECT 1"
|
||||
# 3. Check Redis
|
||||
redis-cli ping
|
||||
# 4. Check logs
|
||||
pnpm dev 2>&1 | grep -E "error|Error|ERROR"
|
||||
```
|
||||
|
||||
### Useful SQL Queries
|
||||
|
||||
```sql
|
||||
-- Find slow queries (requires pg_stat_statements)
|
||||
SELECT query, mean_exec_time, calls, total_exec_time
|
||||
FROM pg_stat_statements
|
||||
ORDER BY mean_exec_time DESC
|
||||
LIMIT 20;
|
||||
|
||||
-- Check active connections
|
||||
SELECT count(*), state FROM pg_stat_activity GROUP BY state;
|
||||
|
||||
-- Find bloated tables
|
||||
SELECT relname, n_dead_tup, n_live_tup,
|
||||
round(n_dead_tup::numeric/nullif(n_live_tup,0)*100, 2) AS dead_pct
|
||||
FROM pg_stat_user_tables
|
||||
ORDER BY n_dead_tup DESC;
|
||||
```
|
||||
|
||||
### Debug Authentication
|
||||
|
||||
```bash
|
||||
# Decode a JWT (no secret needed for header/payload)
|
||||
echo "YOUR_JWT" | cut -d. -f2 | base64 -d | jq .
|
||||
|
||||
# Check session in DB
|
||||
psql $DATABASE_URL -c "SELECT * FROM sessions WHERE user_id = 'usr_...' ORDER BY expires_at DESC LIMIT 5;"
|
||||
```
|
||||
|
||||
### Log Locations
|
||||
|
||||
| Environment | Logs |
|
||||
|-------------|------|
|
||||
| Local dev | Terminal running `pnpm dev` |
|
||||
| Vercel production | Vercel dashboard → Logs |
|
||||
| Workers (Railway) | Railway dashboard → Deployments → Logs |
|
||||
| Database | `docker logs postgres` (local) |
|
||||
| Background jobs | `pnpm worker:dev` terminal |
|
||||
|
||||
---
|
||||
|
||||
## Contribution Guidelines
|
||||
|
||||
### Branch Strategy
|
||||
|
||||
```
|
||||
main → production (protected, requires PR + CI)
|
||||
└── feature/PROJ-123-short-desc
|
||||
└── fix/PROJ-456-bug-description
|
||||
└── chore/update-dependencies
|
||||
```
|
||||
|
||||
### PR Requirements
|
||||
|
||||
- [ ] Branch name includes ticket ID (e.g., `feature/PROJ-123-...`)
|
||||
- [ ] PR description explains the why
|
||||
- [ ] All CI checks pass
|
||||
- [ ] Test coverage doesn't decrease
|
||||
- [ ] Self-reviewed (read your own diff before requesting review)
|
||||
- [ ] Screenshots/video for UI changes
|
||||
|
||||
### Commit Convention
|
||||
|
||||
```
|
||||
feat(scope): short description → new feature
|
||||
fix(scope): short description → bug fix
|
||||
chore: update dependencies → maintenance
|
||||
docs: update API reference → documentation
|
||||
```
|
||||
|
||||
### Code Style
|
||||
|
||||
```bash
|
||||
# Lint + format
|
||||
pnpm lint
|
||||
pnpm format
|
||||
|
||||
# Type check
|
||||
pnpm typecheck
|
||||
|
||||
# All checks (run before pushing)
|
||||
pnpm validate
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Audience-Specific Notes
|
||||
|
||||
### For Junior Developers
|
||||
- Start with `src/lib/auth.ts` to understand authentication
|
||||
- Read existing tests in `tests/api/` — they document expected behavior
|
||||
- Ask before touching anything in `src/db/schema.ts` — schema changes affect everyone
|
||||
- Use `pnpm db:seed` to get realistic local data
|
||||
|
||||
### For Senior Engineers / Tech Leads
|
||||
- Architecture decisions are documented in `docs/adr/` (Architecture Decision Records)
|
||||
- Performance benchmarks: `pnpm bench` — baseline is in `tests/benchmarks/baseline.json`
|
||||
- Security model: RLS policies in `src/db/rls.sql`, enforced at DB level
|
||||
- Scaling notes: `docs/scaling.md`
|
||||
|
||||
### For Contractors
|
||||
- Scope is limited to `src/features/[your-feature]/` unless discussed
|
||||
- Never push directly to `main`
|
||||
- All external API calls go through `src/lib/` wrappers (for mocking in tests)
|
||||
- Time estimates: log in Linear ticket comments daily
|
||||
|
||||
---
|
||||
|
||||
## Output Formats
|
||||
|
||||
### Notion Export
|
||||
|
||||
```javascript
|
||||
// Use Notion API to create onboarding page
|
||||
const { Client } = require('@notionhq/client')
|
||||
const notion = new Client({ auth: process.env.NOTION_TOKEN })
|
||||
|
||||
const blocks = markdownToNotionBlocks(onboardingMarkdown) // use notion-to-md
|
||||
await notion.pages.create({
|
||||
parent: { page_id: ONBOARDING_PARENT_PAGE_ID },
|
||||
properties: { title: { title: [{ text: { content: 'Engineer Onboarding — MyApp' } }] } },
|
||||
children: blocks,
|
||||
})
|
||||
```
|
||||
|
||||
### Confluence Export
|
||||
|
||||
```bash
|
||||
# Using confluence-cli or REST API
|
||||
curl -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-u "user@example.com:$CONFLUENCE_TOKEN" \
|
||||
"https://yourorg.atlassian.net/wiki/rest/api/content" \
|
||||
-d '{
|
||||
"type": "page",
|
||||
"title": "Codebase Onboarding",
|
||||
"space": {"key": "ENG"},
|
||||
"body": {
|
||||
"storage": {
|
||||
"value": "<p>Generated content...</p>",
|
||||
"representation": "storage"
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
- **Docs written once, never updated** — add doc updates to PR checklist
|
||||
- **Missing local setup step** — test setup instructions on a fresh machine quarterly
|
||||
- **No error troubleshooting** — debugging section is the most valuable part for new hires
|
||||
- **Too much detail for contractors** — they need task-specific, not architecture-deep docs
|
||||
- **No screenshots** — UI flows need screenshots; they go stale but are still valuable
|
||||
- **Skipping the "why"** — document why decisions were made, not just what was decided
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Keep setup under 10 minutes** — if it takes longer, fix the setup, not the docs
|
||||
2. **Test the docs** — have a new hire follow them literally, fix every gap they hit
|
||||
3. **Link, don't repeat** — link to ADRs, issues, and external docs instead of duplicating
|
||||
4. **Update in the same PR** — docs changes alongside code changes
|
||||
5. **Version-specific notes** — call out things that changed in recent versions
|
||||
6. **Runbooks over theory** — "run this command" beats "the system uses Redis for..."
|
||||
543
docs/skills/engineering/database-designer.md
Normal file
543
docs/skills/engineering/database-designer.md
Normal file
@@ -0,0 +1,543 @@
|
||||
---
|
||||
title: "Database Designer - POWERFUL Tier Skill"
|
||||
description: "Database Designer - POWERFUL Tier Skill - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Database Designer - POWERFUL Tier Skill
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `database-designer` | **Source:** [`engineering/database-designer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/database-designer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
A comprehensive database design skill that provides expert-level analysis, optimization, and migration capabilities for modern database systems. This skill combines theoretical principles with practical tools to help architects and developers create scalable, performant, and maintainable database schemas.
|
||||
|
||||
## Core Competencies
|
||||
|
||||
### Schema Design & Analysis
|
||||
- **Normalization Analysis**: Automated detection of normalization levels (1NF through BCNF)
|
||||
- **Denormalization Strategy**: Smart recommendations for performance optimization
|
||||
- **Data Type Optimization**: Identification of inappropriate types and size issues
|
||||
- **Constraint Analysis**: Missing foreign keys, unique constraints, and null checks
|
||||
- **Naming Convention Validation**: Consistent table and column naming patterns
|
||||
- **ERD Generation**: Automatic Mermaid diagram creation from DDL
|
||||
|
||||
### Index Optimization
|
||||
- **Index Gap Analysis**: Identification of missing indexes on foreign keys and query patterns
|
||||
- **Composite Index Strategy**: Optimal column ordering for multi-column indexes
|
||||
- **Index Redundancy Detection**: Elimination of overlapping and unused indexes
|
||||
- **Performance Impact Modeling**: Selectivity estimation and query cost analysis
|
||||
- **Index Type Selection**: B-tree, hash, partial, covering, and specialized indexes
|
||||
|
||||
### Migration Management
|
||||
- **Zero-Downtime Migrations**: Expand-contract pattern implementation
|
||||
- **Schema Evolution**: Safe column additions, deletions, and type changes
|
||||
- **Data Migration Scripts**: Automated data transformation and validation
|
||||
- **Rollback Strategy**: Complete reversal capabilities with validation
|
||||
- **Execution Planning**: Ordered migration steps with dependency resolution
|
||||
|
||||
## Database Design Principles
|
||||
|
||||
### Normalization Forms
|
||||
|
||||
#### First Normal Form (1NF)
|
||||
- **Atomic Values**: Each column contains indivisible values
|
||||
- **Unique Column Names**: No duplicate column names within a table
|
||||
- **Uniform Data Types**: Each column contains the same type of data
|
||||
- **Row Uniqueness**: No duplicate rows in the table
|
||||
|
||||
**Example Violation:**
|
||||
```sql
|
||||
-- BAD: Multiple phone numbers in one column
|
||||
CREATE TABLE contacts (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(100),
|
||||
phones VARCHAR(200) -- "123-456-7890, 098-765-4321"
|
||||
);
|
||||
|
||||
-- GOOD: Separate table for phone numbers
|
||||
CREATE TABLE contacts (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(100)
|
||||
);
|
||||
|
||||
CREATE TABLE contact_phones (
|
||||
id INT PRIMARY KEY,
|
||||
contact_id INT REFERENCES contacts(id),
|
||||
phone_number VARCHAR(20),
|
||||
phone_type VARCHAR(10)
|
||||
);
|
||||
```
|
||||
|
||||
#### Second Normal Form (2NF)
|
||||
- **1NF Compliance**: Must satisfy First Normal Form
|
||||
- **Full Functional Dependency**: Non-key attributes depend on the entire primary key
|
||||
- **Partial Dependency Elimination**: Remove attributes that depend on part of a composite key
|
||||
|
||||
**Example Violation:**
|
||||
```sql
|
||||
-- BAD: Student course table with partial dependencies
|
||||
CREATE TABLE student_courses (
|
||||
student_id INT,
|
||||
course_id INT,
|
||||
student_name VARCHAR(100), -- Depends only on student_id
|
||||
course_name VARCHAR(100), -- Depends only on course_id
|
||||
grade CHAR(1),
|
||||
PRIMARY KEY (student_id, course_id)
|
||||
);
|
||||
|
||||
-- GOOD: Separate tables eliminate partial dependencies
|
||||
CREATE TABLE students (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(100)
|
||||
);
|
||||
|
||||
CREATE TABLE courses (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(100)
|
||||
);
|
||||
|
||||
CREATE TABLE enrollments (
|
||||
student_id INT REFERENCES students(id),
|
||||
course_id INT REFERENCES courses(id),
|
||||
grade CHAR(1),
|
||||
PRIMARY KEY (student_id, course_id)
|
||||
);
|
||||
```
|
||||
|
||||
#### Third Normal Form (3NF)
|
||||
- **2NF Compliance**: Must satisfy Second Normal Form
|
||||
- **Transitive Dependency Elimination**: Non-key attributes should not depend on other non-key attributes
|
||||
- **Direct Dependency**: Non-key attributes depend directly on the primary key
|
||||
|
||||
**Example Violation:**
|
||||
```sql
|
||||
-- BAD: Employee table with transitive dependency
|
||||
CREATE TABLE employees (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(100),
|
||||
department_id INT,
|
||||
department_name VARCHAR(100), -- Depends on department_id, not employee id
|
||||
department_budget DECIMAL(10,2) -- Transitive dependency
|
||||
);
|
||||
|
||||
-- GOOD: Separate department information
|
||||
CREATE TABLE departments (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(100),
|
||||
budget DECIMAL(10,2)
|
||||
);
|
||||
|
||||
CREATE TABLE employees (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(100),
|
||||
department_id INT REFERENCES departments(id)
|
||||
);
|
||||
```
|
||||
|
||||
#### Boyce-Codd Normal Form (BCNF)
|
||||
- **3NF Compliance**: Must satisfy Third Normal Form
|
||||
- **Determinant Key Rule**: Every determinant must be a candidate key
|
||||
- **Stricter 3NF**: Handles anomalies not covered by 3NF
|
||||
|
||||
### Denormalization Strategies
|
||||
|
||||
#### When to Denormalize
|
||||
1. **Read-Heavy Workloads**: High query frequency with acceptable write trade-offs
|
||||
2. **Performance Bottlenecks**: Join operations causing significant latency
|
||||
3. **Aggregation Needs**: Frequent calculation of derived values
|
||||
4. **Caching Requirements**: Pre-computed results for common queries
|
||||
|
||||
#### Common Denormalization Patterns
|
||||
|
||||
**Redundant Storage**
|
||||
```sql
|
||||
-- Store calculated values to avoid expensive joins
|
||||
CREATE TABLE orders (
|
||||
id INT PRIMARY KEY,
|
||||
customer_id INT REFERENCES customers(id),
|
||||
customer_name VARCHAR(100), -- Denormalized from customers table
|
||||
order_total DECIMAL(10,2), -- Denormalized calculation
|
||||
created_at TIMESTAMP
|
||||
);
|
||||
```
|
||||
|
||||
**Materialized Aggregates**
|
||||
```sql
|
||||
-- Pre-computed summary tables
|
||||
CREATE TABLE customer_statistics (
|
||||
customer_id INT PRIMARY KEY,
|
||||
total_orders INT,
|
||||
lifetime_value DECIMAL(12,2),
|
||||
last_order_date DATE,
|
||||
updated_at TIMESTAMP
|
||||
);
|
||||
```
|
||||
|
||||
## Index Optimization Strategies
|
||||
|
||||
### B-Tree Indexes
|
||||
- **Default Choice**: Best for range queries, sorting, and equality matches
|
||||
- **Column Order**: Most selective columns first for composite indexes
|
||||
- **Prefix Matching**: Supports leading column subset queries
|
||||
- **Maintenance Cost**: Balanced tree structure with logarithmic operations
|
||||
|
||||
### Hash Indexes
|
||||
- **Equality Queries**: Optimal for exact match lookups
|
||||
- **Memory Efficiency**: Constant-time access for single-value queries
|
||||
- **Range Limitations**: Cannot support range or partial matches
|
||||
- **Use Cases**: Primary keys, unique constraints, cache keys
|
||||
|
||||
### Composite Indexes
|
||||
```sql
|
||||
-- Query pattern determines optimal column order
|
||||
-- Query: WHERE status = 'active' AND created_date > '2023-01-01' ORDER BY priority DESC
|
||||
CREATE INDEX idx_task_status_date_priority
|
||||
ON tasks (status, created_date, priority DESC);
|
||||
|
||||
-- Query: WHERE user_id = 123 AND category IN ('A', 'B') AND date_field BETWEEN '...' AND '...'
|
||||
CREATE INDEX idx_user_category_date
|
||||
ON user_activities (user_id, category, date_field);
|
||||
```
|
||||
|
||||
### Covering Indexes
|
||||
```sql
|
||||
-- Include additional columns to avoid table lookups
|
||||
CREATE INDEX idx_user_email_covering
|
||||
ON users (email)
|
||||
INCLUDE (first_name, last_name, status);
|
||||
|
||||
-- Query can be satisfied entirely from the index
|
||||
-- SELECT first_name, last_name, status FROM users WHERE email = 'user@example.com';
|
||||
```
|
||||
|
||||
### Partial Indexes
|
||||
```sql
|
||||
-- Index only relevant subset of data
|
||||
CREATE INDEX idx_active_users_email
|
||||
ON users (email)
|
||||
WHERE status = 'active';
|
||||
|
||||
-- Index for recent orders only
|
||||
CREATE INDEX idx_recent_orders_customer
|
||||
ON orders (customer_id, created_at)
|
||||
WHERE created_at > CURRENT_DATE - INTERVAL '30 days';
|
||||
```
|
||||
|
||||
## Query Analysis & Optimization
|
||||
|
||||
### Query Patterns Recognition
|
||||
1. **Equality Filters**: Single-column B-tree indexes
|
||||
2. **Range Queries**: B-tree with proper column ordering
|
||||
3. **Text Search**: Full-text indexes or trigram indexes
|
||||
4. **Join Operations**: Foreign key indexes on both sides
|
||||
5. **Sorting Requirements**: Indexes matching ORDER BY clauses
|
||||
|
||||
### Index Selection Algorithm
|
||||
```
|
||||
1. Identify WHERE clause columns
|
||||
2. Determine most selective columns first
|
||||
3. Consider JOIN conditions
|
||||
4. Include ORDER BY columns if possible
|
||||
5. Evaluate covering index opportunities
|
||||
6. Check for existing overlapping indexes
|
||||
```
|
||||
|
||||
## Data Modeling Patterns
|
||||
|
||||
### Star Schema (Data Warehousing)
|
||||
```sql
|
||||
-- Central fact table
|
||||
CREATE TABLE sales_facts (
|
||||
sale_id BIGINT PRIMARY KEY,
|
||||
product_id INT REFERENCES products(id),
|
||||
customer_id INT REFERENCES customers(id),
|
||||
date_id INT REFERENCES date_dimension(id),
|
||||
store_id INT REFERENCES stores(id),
|
||||
quantity INT,
|
||||
unit_price DECIMAL(8,2),
|
||||
total_amount DECIMAL(10,2)
|
||||
);
|
||||
|
||||
-- Dimension tables
|
||||
CREATE TABLE date_dimension (
|
||||
id INT PRIMARY KEY,
|
||||
date_value DATE,
|
||||
year INT,
|
||||
quarter INT,
|
||||
month INT,
|
||||
day_of_week INT,
|
||||
is_weekend BOOLEAN
|
||||
);
|
||||
```
|
||||
|
||||
### Snowflake Schema
|
||||
```sql
|
||||
-- Normalized dimension tables
|
||||
CREATE TABLE products (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(200),
|
||||
category_id INT REFERENCES product_categories(id),
|
||||
brand_id INT REFERENCES brands(id)
|
||||
);
|
||||
|
||||
CREATE TABLE product_categories (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(100),
|
||||
parent_category_id INT REFERENCES product_categories(id)
|
||||
);
|
||||
```
|
||||
|
||||
### Document Model (JSON Storage)
|
||||
```sql
|
||||
-- Flexible document storage with indexing
|
||||
CREATE TABLE documents (
|
||||
id UUID PRIMARY KEY,
|
||||
document_type VARCHAR(50),
|
||||
data JSONB,
|
||||
created_at TIMESTAMP DEFAULT NOW(),
|
||||
updated_at TIMESTAMP DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Index on JSON properties
|
||||
CREATE INDEX idx_documents_user_id
|
||||
ON documents USING GIN ((data->>'user_id'));
|
||||
|
||||
CREATE INDEX idx_documents_status
|
||||
ON documents ((data->>'status'))
|
||||
WHERE document_type = 'order';
|
||||
```
|
||||
|
||||
### Graph Data Patterns
|
||||
```sql
|
||||
-- Adjacency list for hierarchical data
|
||||
CREATE TABLE categories (
|
||||
id INT PRIMARY KEY,
|
||||
name VARCHAR(100),
|
||||
parent_id INT REFERENCES categories(id),
|
||||
level INT,
|
||||
path VARCHAR(500) -- Materialized path: "/1/5/12/"
|
||||
);
|
||||
|
||||
-- Many-to-many relationships
|
||||
CREATE TABLE relationships (
|
||||
id UUID PRIMARY KEY,
|
||||
from_entity_id UUID,
|
||||
to_entity_id UUID,
|
||||
relationship_type VARCHAR(50),
|
||||
created_at TIMESTAMP,
|
||||
INDEX (from_entity_id, relationship_type),
|
||||
INDEX (to_entity_id, relationship_type)
|
||||
);
|
||||
```
|
||||
|
||||
## Migration Strategies
|
||||
|
||||
### Zero-Downtime Migration (Expand-Contract Pattern)
|
||||
|
||||
**Phase 1: Expand**
|
||||
```sql
|
||||
-- Add new column without constraints
|
||||
ALTER TABLE users ADD COLUMN new_email VARCHAR(255);
|
||||
|
||||
-- Backfill data in batches
|
||||
UPDATE users SET new_email = email WHERE id BETWEEN 1 AND 1000;
|
||||
-- Continue in batches...
|
||||
|
||||
-- Add constraints after backfill
|
||||
ALTER TABLE users ADD CONSTRAINT users_new_email_unique UNIQUE (new_email);
|
||||
ALTER TABLE users ALTER COLUMN new_email SET NOT NULL;
|
||||
```
|
||||
|
||||
**Phase 2: Contract**
|
||||
```sql
|
||||
-- Update application to use new column
|
||||
-- Deploy application changes
|
||||
-- Verify new column is being used
|
||||
|
||||
-- Remove old column
|
||||
ALTER TABLE users DROP COLUMN email;
|
||||
-- Rename new column
|
||||
ALTER TABLE users RENAME COLUMN new_email TO email;
|
||||
```
|
||||
|
||||
### Data Type Changes
|
||||
```sql
|
||||
-- Safe string to integer conversion
|
||||
ALTER TABLE products ADD COLUMN sku_number INTEGER;
|
||||
UPDATE products SET sku_number = CAST(sku AS INTEGER) WHERE sku ~ '^[0-9]+$';
|
||||
-- Validate conversion success before dropping old column
|
||||
```
|
||||
|
||||
## Partitioning Strategies
|
||||
|
||||
### Horizontal Partitioning (Sharding)
|
||||
```sql
|
||||
-- Range partitioning by date
|
||||
CREATE TABLE sales_2023 PARTITION OF sales
|
||||
FOR VALUES FROM ('2023-01-01') TO ('2024-01-01');
|
||||
|
||||
CREATE TABLE sales_2024 PARTITION OF sales
|
||||
FOR VALUES FROM ('2024-01-01') TO ('2025-01-01');
|
||||
|
||||
-- Hash partitioning by user_id
|
||||
CREATE TABLE user_data_0 PARTITION OF user_data
|
||||
FOR VALUES WITH (MODULUS 4, REMAINDER 0);
|
||||
|
||||
CREATE TABLE user_data_1 PARTITION OF user_data
|
||||
FOR VALUES WITH (MODULUS 4, REMAINDER 1);
|
||||
```
|
||||
|
||||
### Vertical Partitioning
|
||||
```sql
|
||||
-- Separate frequently accessed columns
|
||||
CREATE TABLE users_core (
|
||||
id INT PRIMARY KEY,
|
||||
email VARCHAR(255),
|
||||
status VARCHAR(20),
|
||||
created_at TIMESTAMP
|
||||
);
|
||||
|
||||
-- Less frequently accessed profile data
|
||||
CREATE TABLE users_profile (
|
||||
user_id INT PRIMARY KEY REFERENCES users_core(id),
|
||||
bio TEXT,
|
||||
preferences JSONB,
|
||||
last_login TIMESTAMP
|
||||
);
|
||||
```
|
||||
|
||||
## Connection Management
|
||||
|
||||
### Connection Pooling
|
||||
- **Pool Size**: CPU cores × 2 + effective spindle count
|
||||
- **Connection Lifetime**: Rotate connections to prevent resource leaks
|
||||
- **Timeout Settings**: Connection, idle, and query timeouts
|
||||
- **Health Checks**: Regular connection validation
|
||||
|
||||
### Read Replicas Strategy
|
||||
```sql
|
||||
-- Write queries to primary
|
||||
INSERT INTO users (email, name) VALUES ('user@example.com', 'John Doe');
|
||||
|
||||
-- Read queries to replicas (with appropriate read preference)
|
||||
SELECT * FROM users WHERE status = 'active'; -- Route to read replica
|
||||
|
||||
-- Consistent reads when required
|
||||
SELECT * FROM users WHERE id = LAST_INSERT_ID(); -- Route to primary
|
||||
```
|
||||
|
||||
## Caching Layers
|
||||
|
||||
### Cache-Aside Pattern
|
||||
```python
|
||||
def get_user(user_id):
|
||||
# Try cache first
|
||||
user = cache.get(f"user:{user_id}")
|
||||
if user is None:
|
||||
# Cache miss - query database
|
||||
user = db.query("SELECT * FROM users WHERE id = %s", user_id)
|
||||
# Store in cache
|
||||
cache.set(f"user:{user_id}", user, ttl=3600)
|
||||
return user
|
||||
```
|
||||
|
||||
### Write-Through Cache
|
||||
- **Consistency**: Always keep cache and database in sync
|
||||
- **Write Latency**: Higher due to dual writes
|
||||
- **Data Safety**: No data loss on cache failures
|
||||
|
||||
### Cache Invalidation Strategies
|
||||
1. **TTL-Based**: Time-based expiration
|
||||
2. **Event-Driven**: Invalidate on data changes
|
||||
3. **Version-Based**: Use version numbers for consistency
|
||||
4. **Tag-Based**: Group related cache entries
|
||||
|
||||
## Database Selection Guide
|
||||
|
||||
### SQL Databases
|
||||
**PostgreSQL**
|
||||
- **Strengths**: ACID compliance, complex queries, JSON support, extensibility
|
||||
- **Use Cases**: OLTP applications, data warehousing, geospatial data
|
||||
- **Scale**: Vertical scaling with read replicas
|
||||
|
||||
**MySQL**
|
||||
- **Strengths**: Performance, replication, wide ecosystem support
|
||||
- **Use Cases**: Web applications, content management, e-commerce
|
||||
- **Scale**: Horizontal scaling through sharding
|
||||
|
||||
### NoSQL Databases
|
||||
|
||||
**Document Stores (MongoDB, CouchDB)**
|
||||
- **Strengths**: Flexible schema, horizontal scaling, developer productivity
|
||||
- **Use Cases**: Content management, catalogs, user profiles
|
||||
- **Trade-offs**: Eventual consistency, complex queries limitations
|
||||
|
||||
**Key-Value Stores (Redis, DynamoDB)**
|
||||
- **Strengths**: High performance, simple model, excellent caching
|
||||
- **Use Cases**: Session storage, real-time analytics, gaming leaderboards
|
||||
- **Trade-offs**: Limited query capabilities, data modeling constraints
|
||||
|
||||
**Column-Family (Cassandra, HBase)**
|
||||
- **Strengths**: Write-heavy workloads, linear scalability, fault tolerance
|
||||
- **Use Cases**: Time-series data, IoT applications, messaging systems
|
||||
- **Trade-offs**: Query flexibility, consistency model complexity
|
||||
|
||||
**Graph Databases (Neo4j, Amazon Neptune)**
|
||||
- **Strengths**: Relationship queries, pattern matching, recommendation engines
|
||||
- **Use Cases**: Social networks, fraud detection, knowledge graphs
|
||||
- **Trade-offs**: Specialized use cases, learning curve
|
||||
|
||||
### NewSQL Databases
|
||||
**Distributed SQL (CockroachDB, TiDB, Spanner)**
|
||||
- **Strengths**: SQL compatibility with horizontal scaling
|
||||
- **Use Cases**: Global applications requiring ACID guarantees
|
||||
- **Trade-offs**: Complexity, latency for distributed transactions
|
||||
|
||||
## Tools & Scripts
|
||||
|
||||
### Schema Analyzer
|
||||
- **Input**: SQL DDL files, JSON schema definitions
|
||||
- **Analysis**: Normalization compliance, constraint validation, naming conventions
|
||||
- **Output**: Analysis report, Mermaid ERD, improvement recommendations
|
||||
|
||||
### Index Optimizer
|
||||
- **Input**: Schema definition, query patterns
|
||||
- **Analysis**: Missing indexes, redundancy detection, selectivity estimation
|
||||
- **Output**: Index recommendations, CREATE INDEX statements, performance projections
|
||||
|
||||
### Migration Generator
|
||||
- **Input**: Current and target schemas
|
||||
- **Analysis**: Schema differences, dependency resolution, risk assessment
|
||||
- **Output**: Migration scripts, rollback plans, validation queries
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Schema Design
|
||||
1. **Use meaningful names**: Clear, consistent naming conventions
|
||||
2. **Choose appropriate data types**: Right-sized columns for storage efficiency
|
||||
3. **Define proper constraints**: Foreign keys, check constraints, unique indexes
|
||||
4. **Consider future growth**: Plan for scale from the beginning
|
||||
5. **Document relationships**: Clear foreign key relationships and business rules
|
||||
|
||||
### Performance Optimization
|
||||
1. **Index strategically**: Cover common query patterns without over-indexing
|
||||
2. **Monitor query performance**: Regular analysis of slow queries
|
||||
3. **Partition large tables**: Improve query performance and maintenance
|
||||
4. **Use appropriate isolation levels**: Balance consistency with performance
|
||||
5. **Implement connection pooling**: Efficient resource utilization
|
||||
|
||||
### Security Considerations
|
||||
1. **Principle of least privilege**: Grant minimal necessary permissions
|
||||
2. **Encrypt sensitive data**: At rest and in transit
|
||||
3. **Audit access patterns**: Monitor and log database access
|
||||
4. **Validate inputs**: Prevent SQL injection attacks
|
||||
5. **Regular security updates**: Keep database software current
|
||||
|
||||
## Conclusion
|
||||
|
||||
Effective database design requires balancing multiple competing concerns: performance, scalability, maintainability, and business requirements. This skill provides the tools and knowledge to make informed decisions throughout the database lifecycle, from initial schema design through production optimization and evolution.
|
||||
|
||||
The included tools automate common analysis and optimization tasks, while the comprehensive guides provide the theoretical foundation for making sound architectural decisions. Whether building a new system or optimizing an existing one, these resources provide expert-level guidance for creating robust, scalable database solutions.
|
||||
532
docs/skills/engineering/database-schema-designer.md
Normal file
532
docs/skills/engineering/database-schema-designer.md
Normal file
@@ -0,0 +1,532 @@
|
||||
---
|
||||
title: "Database Schema Designer"
|
||||
description: "Database Schema Designer - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Database Schema Designer
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `database-schema-designer` | **Source:** [`engineering/database-schema-designer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/database-schema-designer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering
|
||||
**Domain:** Data Architecture / Backend
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Design relational database schemas from requirements and generate migrations, TypeScript/Python types, seed data, RLS policies, and indexes. Handles multi-tenancy, soft deletes, audit trails, versioning, and polymorphic associations.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- **Schema design** — normalize requirements into tables, relationships, constraints
|
||||
- **Migration generation** — Drizzle, Prisma, TypeORM, Alembic
|
||||
- **Type generation** — TypeScript interfaces, Python dataclasses/Pydantic models
|
||||
- **RLS policies** — Row-Level Security for multi-tenant apps
|
||||
- **Index strategy** — composite indexes, partial indexes, covering indexes
|
||||
- **Seed data** — realistic test data generation
|
||||
- **ERD generation** — Mermaid diagram from schema
|
||||
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
- Designing a new feature that needs database tables
|
||||
- Reviewing a schema for performance or normalization issues
|
||||
- Adding multi-tenancy to an existing schema
|
||||
- Generating TypeScript types from a Prisma schema
|
||||
- Planning a schema migration for a breaking change
|
||||
|
||||
---
|
||||
|
||||
## Schema Design Process
|
||||
|
||||
### Step 1: Requirements → Entities
|
||||
|
||||
Given requirements:
|
||||
> "Users can create projects. Each project has tasks. Tasks can have labels. Tasks can be assigned to users. We need a full audit trail."
|
||||
|
||||
Extract entities:
|
||||
```
|
||||
User, Project, Task, Label, TaskLabel (junction), TaskAssignment, AuditLog
|
||||
```
|
||||
|
||||
### Step 2: Identify Relationships
|
||||
|
||||
```
|
||||
User 1──* Project (owner)
|
||||
Project 1──* Task
|
||||
Task *──* Label (via TaskLabel)
|
||||
Task *──* User (via TaskAssignment)
|
||||
User 1──* AuditLog
|
||||
```
|
||||
|
||||
### Step 3: Add Cross-cutting Concerns
|
||||
|
||||
- Multi-tenancy: add `organization_id` to all tenant-scoped tables
|
||||
- Soft deletes: add `deleted_at TIMESTAMPTZ` instead of hard deletes
|
||||
- Audit trail: add `created_by`, `updated_by`, `created_at`, `updated_at`
|
||||
- Versioning: add `version INTEGER` for optimistic locking
|
||||
|
||||
---
|
||||
|
||||
## Full Schema Example (Task Management SaaS)
|
||||
|
||||
### Prisma Schema
|
||||
|
||||
```prisma
|
||||
// schema.prisma
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
// ── Multi-tenancy ─────────────────────────────────────────────────────────────
|
||||
|
||||
model Organization {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
slug String @unique
|
||||
plan Plan @default(FREE)
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
|
||||
users OrganizationMember[]
|
||||
projects Project[]
|
||||
auditLogs AuditLog[]
|
||||
|
||||
@@map("organizations")
|
||||
}
|
||||
|
||||
model OrganizationMember {
|
||||
id String @id @default(cuid())
|
||||
organizationId String @map("organization_id")
|
||||
userId String @map("user_id")
|
||||
role OrgRole @default(MEMBER)
|
||||
joinedAt DateTime @default(now()) @map("joined_at")
|
||||
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([organizationId, userId])
|
||||
@@index([userId])
|
||||
@@map("organization_members")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
email String @unique
|
||||
name String?
|
||||
avatarUrl String? @map("avatar_url")
|
||||
passwordHash String? @map("password_hash")
|
||||
emailVerifiedAt DateTime? @map("email_verified_at")
|
||||
lastLoginAt DateTime? @map("last_login_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
|
||||
memberships OrganizationMember[]
|
||||
ownedProjects Project[] @relation("ProjectOwner")
|
||||
assignedTasks TaskAssignment[]
|
||||
comments Comment[]
|
||||
auditLogs AuditLog[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
// ── Core entities ─────────────────────────────────────────────────────────────
|
||||
|
||||
model Project {
|
||||
id String @id @default(cuid())
|
||||
organizationId String @map("organization_id")
|
||||
ownerId String @map("owner_id")
|
||||
name String
|
||||
description String?
|
||||
status ProjectStatus @default(ACTIVE)
|
||||
settings Json @default("{}")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
|
||||
organization Organization @relation(fields: [organizationId], references: [id])
|
||||
owner User @relation("ProjectOwner", fields: [ownerId], references: [id])
|
||||
tasks Task[]
|
||||
labels Label[]
|
||||
|
||||
@@index([organizationId])
|
||||
@@index([organizationId, status])
|
||||
@@index([deletedAt])
|
||||
@@map("projects")
|
||||
}
|
||||
|
||||
model Task {
|
||||
id String @id @default(cuid())
|
||||
projectId String @map("project_id")
|
||||
title String
|
||||
description String?
|
||||
status TaskStatus @default(TODO)
|
||||
priority Priority @default(MEDIUM)
|
||||
dueDate DateTime? @map("due_date")
|
||||
position Float @default(0) // For drag-and-drop ordering
|
||||
version Int @default(1) // Optimistic locking
|
||||
createdById String @map("created_by_id")
|
||||
updatedById String @map("updated_by_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
deletedAt DateTime? @map("deleted_at")
|
||||
|
||||
project Project @relation(fields: [projectId], references: [id])
|
||||
assignments TaskAssignment[]
|
||||
labels TaskLabel[]
|
||||
comments Comment[]
|
||||
attachments Attachment[]
|
||||
|
||||
@@index([projectId])
|
||||
@@index([projectId, status])
|
||||
@@index([projectId, deletedAt])
|
||||
@@index([dueDate], where: { deletedAt: null }) // Partial index
|
||||
@@map("tasks")
|
||||
}
|
||||
|
||||
// ── Polymorphic attachments ───────────────────────────────────────────────────
|
||||
|
||||
model Attachment {
|
||||
id String @id @default(cuid())
|
||||
// Polymorphic association
|
||||
entityType String @map("entity_type") // "task" | "comment"
|
||||
entityId String @map("entity_id")
|
||||
filename String
|
||||
mimeType String @map("mime_type")
|
||||
sizeBytes Int @map("size_bytes")
|
||||
storageKey String @map("storage_key") // S3 key
|
||||
uploadedById String @map("uploaded_by_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
// Only one concrete relation (task) — polymorphic handled at app level
|
||||
task Task? @relation(fields: [entityId], references: [id], map: "attachment_task_fk")
|
||||
|
||||
@@index([entityType, entityId])
|
||||
@@map("attachments")
|
||||
}
|
||||
|
||||
// ── Audit trail ───────────────────────────────────────────────────────────────
|
||||
|
||||
model AuditLog {
|
||||
id String @id @default(cuid())
|
||||
organizationId String @map("organization_id")
|
||||
userId String? @map("user_id")
|
||||
action String // "task.created", "task.status_changed"
|
||||
entityType String @map("entity_type")
|
||||
entityId String @map("entity_id")
|
||||
before Json? // Previous state
|
||||
after Json? // New state
|
||||
ipAddress String? @map("ip_address")
|
||||
userAgent String? @map("user_agent")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
organization Organization @relation(fields: [organizationId], references: [id])
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
|
||||
@@index([organizationId, createdAt(sort: Desc)])
|
||||
@@index([entityType, entityId])
|
||||
@@index([userId])
|
||||
@@map("audit_logs")
|
||||
}
|
||||
|
||||
enum Plan { FREE STARTER GROWTH ENTERPRISE }
|
||||
enum OrgRole { OWNER ADMIN MEMBER VIEWER }
|
||||
enum ProjectStatus { ACTIVE ARCHIVED }
|
||||
enum TaskStatus { TODO IN_PROGRESS IN_REVIEW DONE CANCELLED }
|
||||
enum Priority { LOW MEDIUM HIGH CRITICAL }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Drizzle Schema (TypeScript)
|
||||
|
||||
```typescript
|
||||
// db/schema.ts
|
||||
import {
|
||||
pgTable, text, timestamp, integer, boolean,
|
||||
varchar, jsonb, real, pgEnum, uniqueIndex, index,
|
||||
} from 'drizzle-orm/pg-core'
|
||||
import { createId } from '@paralleldrive/cuid2'
|
||||
|
||||
export const taskStatusEnum = pgEnum('task_status', [
|
||||
'todo', 'in_progress', 'in_review', 'done', 'cancelled'
|
||||
])
|
||||
export const priorityEnum = pgEnum('priority', ['low', 'medium', 'high', 'critical'])
|
||||
|
||||
export const tasks = pgTable('tasks', {
|
||||
id: text('id').primaryKey().$defaultFn(() => createId()),
|
||||
projectId: text('project_id').notNull().references(() => projects.id),
|
||||
title: varchar('title', { length: 500 }).notNull(),
|
||||
description: text('description'),
|
||||
status: taskStatusEnum('status').notNull().default('todo'),
|
||||
priority: priorityEnum('priority').notNull().default('medium'),
|
||||
dueDate: timestamp('due_date', { withTimezone: true }),
|
||||
position: real('position').notNull().default(0),
|
||||
version: integer('version').notNull().default(1),
|
||||
createdById: text('created_by_id').notNull().references(() => users.id),
|
||||
updatedById: text('updated_by_id').notNull().references(() => users.id),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
deletedAt: timestamp('deleted_at', { withTimezone: true }),
|
||||
}, (table) => ({
|
||||
projectIdx: index('tasks_project_id_idx').on(table.projectId),
|
||||
projectStatusIdx: index('tasks_project_status_idx').on(table.projectId, table.status),
|
||||
}))
|
||||
|
||||
// Infer TypeScript types
|
||||
export type Task = typeof tasks.$inferSelect
|
||||
export type NewTask = typeof tasks.$inferInsert
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Alembic Migration (Python / SQLAlchemy)
|
||||
|
||||
```python
|
||||
# alembic/versions/20260301_create_tasks.py
|
||||
"""Create tasks table
|
||||
|
||||
Revision ID: a1b2c3d4e5f6
|
||||
Revises: previous_revision
|
||||
Create Date: 2026-03-01 12:00:00
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
revision = 'a1b2c3d4e5f6'
|
||||
down_revision = 'previous_revision'
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Create enums
|
||||
task_status = postgresql.ENUM(
|
||||
'todo', 'in_progress', 'in_review', 'done', 'cancelled',
|
||||
name='task_status'
|
||||
)
|
||||
task_status.create(op.get_bind())
|
||||
|
||||
op.create_table(
|
||||
'tasks',
|
||||
sa.Column('id', sa.Text(), primary_key=True),
|
||||
sa.Column('project_id', sa.Text(), sa.ForeignKey('projects.id'), nullable=False),
|
||||
sa.Column('title', sa.VARCHAR(500), nullable=False),
|
||||
sa.Column('description', sa.Text()),
|
||||
sa.Column('status', postgresql.ENUM('todo', 'in_progress', 'in_review', 'done', 'cancelled', name='task_status', create_type=False), nullable=False, server_default='todo'),
|
||||
sa.Column('priority', sa.Text(), nullable=False, server_default='medium'),
|
||||
sa.Column('due_date', sa.TIMESTAMP(timezone=True)),
|
||||
sa.Column('position', sa.Float(), nullable=False, server_default='0'),
|
||||
sa.Column('version', sa.Integer(), nullable=False, server_default='1'),
|
||||
sa.Column('created_by_id', sa.Text(), sa.ForeignKey('users.id'), nullable=False),
|
||||
sa.Column('updated_by_id', sa.Text(), sa.ForeignKey('users.id'), nullable=False),
|
||||
sa.Column('created_at', sa.TIMESTAMP(timezone=True), nullable=False, server_default=sa.text('NOW()')),
|
||||
sa.Column('updated_at', sa.TIMESTAMP(timezone=True), nullable=False, server_default=sa.text('NOW()')),
|
||||
sa.Column('deleted_at', sa.TIMESTAMP(timezone=True)),
|
||||
)
|
||||
|
||||
# Indexes
|
||||
op.create_index('tasks_project_id_idx', 'tasks', ['project_id'])
|
||||
op.create_index('tasks_project_status_idx', 'tasks', ['project_id', 'status'])
|
||||
# Partial index for active tasks only
|
||||
op.create_index(
|
||||
'tasks_due_date_active_idx',
|
||||
'tasks', ['due_date'],
|
||||
postgresql_where=sa.text('deleted_at IS NULL')
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_table('tasks')
|
||||
op.execute("DROP TYPE IF EXISTS task_status")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Row-Level Security (RLS) Policies
|
||||
|
||||
```sql
|
||||
-- Enable RLS
|
||||
ALTER TABLE tasks ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE projects ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- Create app role
|
||||
CREATE ROLE app_user;
|
||||
|
||||
-- Users can only see tasks in their organization's projects
|
||||
CREATE POLICY tasks_org_isolation ON tasks
|
||||
FOR ALL TO app_user
|
||||
USING (
|
||||
project_id IN (
|
||||
SELECT p.id FROM projects p
|
||||
JOIN organization_members om ON om.organization_id = p.organization_id
|
||||
WHERE om.user_id = current_setting('app.current_user_id')::text
|
||||
)
|
||||
);
|
||||
|
||||
-- Soft delete: never show deleted records
|
||||
CREATE POLICY tasks_no_deleted ON tasks
|
||||
FOR SELECT TO app_user
|
||||
USING (deleted_at IS NULL);
|
||||
|
||||
-- Only task creator or admin can delete
|
||||
CREATE POLICY tasks_delete_policy ON tasks
|
||||
FOR DELETE TO app_user
|
||||
USING (
|
||||
created_by_id = current_setting('app.current_user_id')::text
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM organization_members om
|
||||
JOIN projects p ON p.organization_id = om.organization_id
|
||||
WHERE p.id = tasks.project_id
|
||||
AND om.user_id = current_setting('app.current_user_id')::text
|
||||
AND om.role IN ('owner', 'admin')
|
||||
)
|
||||
);
|
||||
|
||||
-- Set user context (call at start of each request)
|
||||
SELECT set_config('app.current_user_id', $1, true);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Seed Data Generation
|
||||
|
||||
```typescript
|
||||
// db/seed.ts
|
||||
import { faker } from '@faker-js/faker'
|
||||
import { db } from './client'
|
||||
import { organizations, users, projects, tasks } from './schema'
|
||||
import { createId } from '@paralleldrive/cuid2'
|
||||
import { hashPassword } from '../src/lib/auth'
|
||||
|
||||
async function seed() {
|
||||
console.log('Seeding database...')
|
||||
|
||||
// Create org
|
||||
const [org] = await db.insert(organizations).values({
|
||||
id: createId(),
|
||||
name: 'Acme Corp',
|
||||
slug: 'acme',
|
||||
plan: 'growth',
|
||||
}).returning()
|
||||
|
||||
// Create users
|
||||
const adminUser = await db.insert(users).values({
|
||||
id: createId(),
|
||||
email: 'admin@acme.com',
|
||||
name: 'Alice Admin',
|
||||
passwordHash: await hashPassword('password123'),
|
||||
}).returning().then(r => r[0])
|
||||
|
||||
// Create projects
|
||||
const projectsData = Array.from({ length: 3 }, () => ({
|
||||
id: createId(),
|
||||
organizationId: org.id,
|
||||
ownerId: adminUser.id,
|
||||
name: faker.company.catchPhrase(),
|
||||
description: faker.lorem.paragraph(),
|
||||
status: 'active' as const,
|
||||
}))
|
||||
|
||||
const createdProjects = await db.insert(projects).values(projectsData).returning()
|
||||
|
||||
// Create tasks for each project
|
||||
for (const project of createdProjects) {
|
||||
const tasksData = Array.from({ length: faker.number.int({ min: 5, max: 20 }) }, (_, i) => ({
|
||||
id: createId(),
|
||||
projectId: project.id,
|
||||
title: faker.hacker.phrase(),
|
||||
description: faker.lorem.sentences(2),
|
||||
status: faker.helpers.arrayElement(['todo', 'in_progress', 'done'] as const),
|
||||
priority: faker.helpers.arrayElement(['low', 'medium', 'high'] as const),
|
||||
position: i * 1000,
|
||||
createdById: adminUser.id,
|
||||
updatedById: adminUser.id,
|
||||
}))
|
||||
|
||||
await db.insert(tasks).values(tasksData)
|
||||
}
|
||||
|
||||
console.log(`✅ Seeded: 1 org, ${projectsData.length} projects, tasks`)
|
||||
}
|
||||
|
||||
seed().catch(console.error).finally(() => process.exit(0))
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ERD Generation (Mermaid)
|
||||
|
||||
```
|
||||
erDiagram
|
||||
Organization ||--o{ OrganizationMember : has
|
||||
Organization ||--o{ Project : owns
|
||||
User ||--o{ OrganizationMember : joins
|
||||
User ||--o{ Task : "created by"
|
||||
Project ||--o{ Task : contains
|
||||
Task ||--o{ TaskAssignment : has
|
||||
Task ||--o{ TaskLabel : has
|
||||
Task ||--o{ Comment : has
|
||||
Task ||--o{ Attachment : has
|
||||
Label ||--o{ TaskLabel : "applied to"
|
||||
User ||--o{ TaskAssignment : assigned
|
||||
|
||||
Organization {
|
||||
string id PK
|
||||
string name
|
||||
string slug
|
||||
string plan
|
||||
}
|
||||
|
||||
Task {
|
||||
string id PK
|
||||
string project_id FK
|
||||
string title
|
||||
string status
|
||||
string priority
|
||||
timestamp due_date
|
||||
timestamp deleted_at
|
||||
int version
|
||||
}
|
||||
```
|
||||
|
||||
Generate from Prisma:
|
||||
```bash
|
||||
npx prisma-erd-generator
|
||||
# or: npx @dbml/cli prisma2dbml -i schema.prisma | npx dbml-to-mermaid
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
- **Soft delete without index** — `WHERE deleted_at IS NULL` without index = full scan
|
||||
- **Missing composite indexes** — `WHERE org_id = ? AND status = ?` needs a composite index
|
||||
- **Mutable surrogate keys** — never use email or slug as PK; use UUID/CUID
|
||||
- **Non-nullable without default** — adding a NOT NULL column to existing table requires default or migration plan
|
||||
- **No optimistic locking** — concurrent updates overwrite each other; add `version` column
|
||||
- **RLS not tested** — always test RLS with a non-superuser role
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Timestamps everywhere** — `created_at`, `updated_at` on every table
|
||||
2. **Soft deletes for auditable data** — `deleted_at` instead of DELETE
|
||||
3. **Audit log for compliance** — log before/after JSON for regulated domains
|
||||
4. **UUIDs or CUIDs as PKs** — avoid sequential integer leakage
|
||||
5. **Index foreign keys** — every FK column should have an index
|
||||
6. **Partial indexes** — use `WHERE deleted_at IS NULL` for active-only queries
|
||||
7. **RLS over application-level filtering** — database enforces tenancy, not just app code
|
||||
343
docs/skills/engineering/dependency-auditor.md
Normal file
343
docs/skills/engineering/dependency-auditor.md
Normal file
@@ -0,0 +1,343 @@
|
||||
---
|
||||
title: "Dependency Auditor"
|
||||
description: "Dependency Auditor - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Dependency Auditor
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `dependency-auditor` | **Source:** [`engineering/dependency-auditor/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/dependency-auditor/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
> **Skill Type:** POWERFUL
|
||||
> **Category:** Engineering
|
||||
> **Domain:** Dependency Management & Security
|
||||
|
||||
## Overview
|
||||
|
||||
The **Dependency Auditor** is a comprehensive toolkit for analyzing, auditing, and managing dependencies across multi-language software projects. This skill provides deep visibility into your project's dependency ecosystem, enabling teams to identify vulnerabilities, ensure license compliance, optimize dependency trees, and plan safe upgrades.
|
||||
|
||||
In modern software development, dependencies form complex webs that can introduce significant security, legal, and maintenance risks. A single project might have hundreds of direct and transitive dependencies, each potentially introducing vulnerabilities, license conflicts, or maintenance burden. This skill addresses these challenges through automated analysis and actionable recommendations.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
### 1. Vulnerability Scanning & CVE Matching
|
||||
|
||||
**Comprehensive Security Analysis**
|
||||
- Scans dependencies against built-in vulnerability databases
|
||||
- Matches Common Vulnerabilities and Exposures (CVE) patterns
|
||||
- Identifies known security issues across multiple ecosystems
|
||||
- Analyzes transitive dependency vulnerabilities
|
||||
- Provides CVSS scores and exploit assessments
|
||||
- Tracks vulnerability disclosure timelines
|
||||
- Maps vulnerabilities to dependency paths
|
||||
|
||||
**Multi-Language Support**
|
||||
- **JavaScript/Node.js**: package.json, package-lock.json, yarn.lock
|
||||
- **Python**: requirements.txt, pyproject.toml, Pipfile.lock, poetry.lock
|
||||
- **Go**: go.mod, go.sum
|
||||
- **Rust**: Cargo.toml, Cargo.lock
|
||||
- **Ruby**: Gemfile, Gemfile.lock
|
||||
- **Java/Maven**: pom.xml, gradle.lockfile
|
||||
- **PHP**: composer.json, composer.lock
|
||||
- **C#/.NET**: packages.config, project.assets.json
|
||||
|
||||
### 2. License Compliance & Legal Risk Assessment
|
||||
|
||||
**License Classification System**
|
||||
- **Permissive Licenses**: MIT, Apache 2.0, BSD (2-clause, 3-clause), ISC
|
||||
- **Copyleft (Strong)**: GPL (v2, v3), AGPL (v3)
|
||||
- **Copyleft (Weak)**: LGPL (v2.1, v3), MPL (v2.0)
|
||||
- **Proprietary**: Commercial, custom, or restrictive licenses
|
||||
- **Dual Licensed**: Multi-license scenarios and compatibility
|
||||
- **Unknown/Ambiguous**: Missing or unclear licensing
|
||||
|
||||
**Conflict Detection**
|
||||
- Identifies incompatible license combinations
|
||||
- Warns about GPL contamination in permissive projects
|
||||
- Analyzes license inheritance through dependency chains
|
||||
- Provides compliance recommendations for distribution
|
||||
- Generates legal risk matrices for decision-making
|
||||
|
||||
### 3. Outdated Dependency Detection
|
||||
|
||||
**Version Analysis**
|
||||
- Identifies dependencies with available updates
|
||||
- Categorizes updates by severity (patch, minor, major)
|
||||
- Detects pinned versions that may be outdated
|
||||
- Analyzes semantic versioning patterns
|
||||
- Identifies floating version specifiers
|
||||
- Tracks release frequencies and maintenance status
|
||||
|
||||
**Maintenance Status Assessment**
|
||||
- Identifies abandoned or unmaintained packages
|
||||
- Analyzes commit frequency and contributor activity
|
||||
- Tracks last release dates and security patch availability
|
||||
- Identifies packages with known end-of-life dates
|
||||
- Assesses upstream maintenance quality
|
||||
|
||||
### 4. Dependency Bloat Analysis
|
||||
|
||||
**Unused Dependency Detection**
|
||||
- Identifies dependencies that aren't actually imported/used
|
||||
- Analyzes import statements and usage patterns
|
||||
- Detects redundant dependencies with overlapping functionality
|
||||
- Identifies oversized packages for simple use cases
|
||||
- Maps actual vs. declared dependency usage
|
||||
|
||||
**Redundancy Analysis**
|
||||
- Identifies multiple packages providing similar functionality
|
||||
- Detects version conflicts in transitive dependencies
|
||||
- Analyzes bundle size impact of dependencies
|
||||
- Identifies opportunities for dependency consolidation
|
||||
- Maps dependency overlap and duplication
|
||||
|
||||
### 5. Upgrade Path Planning & Breaking Change Risk
|
||||
|
||||
**Semantic Versioning Analysis**
|
||||
- Analyzes semver patterns to predict breaking changes
|
||||
- Identifies safe upgrade paths (patch/minor versions)
|
||||
- Flags major version updates requiring attention
|
||||
- Tracks breaking changes across dependency updates
|
||||
- Provides rollback strategies for failed upgrades
|
||||
|
||||
**Risk Assessment Matrix**
|
||||
- Low Risk: Patch updates, security fixes
|
||||
- Medium Risk: Minor updates with new features
|
||||
- High Risk: Major version updates, API changes
|
||||
- Critical Risk: Dependencies with known breaking changes
|
||||
|
||||
**Upgrade Prioritization**
|
||||
- Security patches: Highest priority
|
||||
- Bug fixes: High priority
|
||||
- Feature updates: Medium priority
|
||||
- Major rewrites: Planned priority
|
||||
- Deprecated features: Immediate attention
|
||||
|
||||
### 6. Supply Chain Security
|
||||
|
||||
**Dependency Provenance**
|
||||
- Verifies package signatures and checksums
|
||||
- Analyzes package download sources and mirrors
|
||||
- Identifies suspicious or compromised packages
|
||||
- Tracks package ownership changes and maintainer shifts
|
||||
- Detects typosquatting and malicious packages
|
||||
|
||||
**Transitive Risk Analysis**
|
||||
- Maps complete dependency trees
|
||||
- Identifies high-risk transitive dependencies
|
||||
- Analyzes dependency depth and complexity
|
||||
- Tracks influence of indirect dependencies
|
||||
- Provides supply chain risk scoring
|
||||
|
||||
### 7. Lockfile Analysis & Deterministic Builds
|
||||
|
||||
**Lockfile Validation**
|
||||
- Ensures lockfiles are up-to-date with manifests
|
||||
- Validates integrity hashes and version consistency
|
||||
- Identifies drift between environments
|
||||
- Analyzes lockfile conflicts and resolution strategies
|
||||
- Ensures deterministic, reproducible builds
|
||||
|
||||
**Environment Consistency**
|
||||
- Compares dependencies across environments (dev/staging/prod)
|
||||
- Identifies version mismatches between team members
|
||||
- Validates CI/CD environment consistency
|
||||
- Tracks dependency resolution differences
|
||||
|
||||
## Technical Architecture
|
||||
|
||||
### Scanner Engine (`dep_scanner.py`)
|
||||
- Multi-format parser supporting 8+ package ecosystems
|
||||
- Built-in vulnerability database with 500+ CVE patterns
|
||||
- Transitive dependency resolution from lockfiles
|
||||
- JSON and human-readable output formats
|
||||
- Configurable scanning depth and exclusion patterns
|
||||
|
||||
### License Analyzer (`license_checker.py`)
|
||||
- License detection from package metadata and files
|
||||
- Compatibility matrix with 20+ license types
|
||||
- Conflict detection engine with remediation suggestions
|
||||
- Risk scoring based on distribution and usage context
|
||||
- Export capabilities for legal review
|
||||
|
||||
### Upgrade Planner (`upgrade_planner.py`)
|
||||
- Semantic version analysis with breaking change prediction
|
||||
- Dependency ordering based on risk and interdependence
|
||||
- Migration checklists with testing recommendations
|
||||
- Rollback procedures for failed upgrades
|
||||
- Timeline estimation for upgrade cycles
|
||||
|
||||
## Use Cases & Applications
|
||||
|
||||
### Security Teams
|
||||
- **Vulnerability Management**: Continuous scanning for security issues
|
||||
- **Incident Response**: Rapid assessment of vulnerable dependencies
|
||||
- **Supply Chain Monitoring**: Tracking third-party security posture
|
||||
- **Compliance Reporting**: Automated security compliance documentation
|
||||
|
||||
### Legal & Compliance Teams
|
||||
- **License Auditing**: Comprehensive license compliance verification
|
||||
- **Risk Assessment**: Legal risk analysis for software distribution
|
||||
- **Due Diligence**: Dependency licensing for M&A activities
|
||||
- **Policy Enforcement**: Automated license policy compliance
|
||||
|
||||
### Development Teams
|
||||
- **Dependency Hygiene**: Regular cleanup of unused dependencies
|
||||
- **Upgrade Planning**: Strategic dependency update scheduling
|
||||
- **Performance Optimization**: Bundle size optimization through dep analysis
|
||||
- **Technical Debt**: Identifying and prioritizing dependency technical debt
|
||||
|
||||
### DevOps & Platform Teams
|
||||
- **Build Optimization**: Faster builds through dependency optimization
|
||||
- **Security Automation**: Automated vulnerability scanning in CI/CD
|
||||
- **Environment Consistency**: Ensuring consistent dependencies across environments
|
||||
- **Release Management**: Dependency-aware release planning
|
||||
|
||||
## Integration Patterns
|
||||
|
||||
### CI/CD Pipeline Integration
|
||||
```bash
|
||||
# Security gate in CI
|
||||
python dep_scanner.py /project --format json --fail-on-high
|
||||
python license_checker.py /project --policy strict --format json
|
||||
```
|
||||
|
||||
### Scheduled Audits
|
||||
```bash
|
||||
# Weekly dependency audit
|
||||
./audit_dependencies.sh > weekly_report.html
|
||||
python upgrade_planner.py deps.json --timeline 30days
|
||||
```
|
||||
|
||||
### Development Workflow
|
||||
```bash
|
||||
# Pre-commit dependency check
|
||||
python dep_scanner.py . --quick-scan
|
||||
python license_checker.py . --warn-conflicts
|
||||
```
|
||||
|
||||
## Advanced Features
|
||||
|
||||
### Custom Vulnerability Databases
|
||||
- Support for internal/proprietary vulnerability feeds
|
||||
- Custom CVE pattern definitions
|
||||
- Organization-specific risk scoring
|
||||
- Integration with enterprise security tools
|
||||
|
||||
### Policy-Based Scanning
|
||||
- Configurable license policies by project type
|
||||
- Custom risk thresholds and escalation rules
|
||||
- Automated policy enforcement and notifications
|
||||
- Exception management for approved violations
|
||||
|
||||
### Reporting & Dashboards
|
||||
- Executive summaries for management
|
||||
- Technical reports for development teams
|
||||
- Trend analysis and dependency health metrics
|
||||
- Integration with project management tools
|
||||
|
||||
### Multi-Project Analysis
|
||||
- Portfolio-level dependency analysis
|
||||
- Shared dependency impact analysis
|
||||
- Organization-wide license compliance
|
||||
- Cross-project vulnerability propagation
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Scanning Frequency
|
||||
- **Security Scans**: Daily or on every commit
|
||||
- **License Audits**: Weekly or monthly
|
||||
- **Upgrade Planning**: Monthly or quarterly
|
||||
- **Full Dependency Audit**: Quarterly
|
||||
|
||||
### Risk Management
|
||||
1. **Prioritize Security**: Address high/critical CVEs immediately
|
||||
2. **License First**: Ensure compliance before functionality
|
||||
3. **Gradual Updates**: Incremental dependency updates
|
||||
4. **Test Thoroughly**: Comprehensive testing after updates
|
||||
5. **Monitor Continuously**: Automated monitoring and alerting
|
||||
|
||||
### Team Workflows
|
||||
1. **Security Champions**: Designate dependency security owners
|
||||
2. **Review Process**: Mandatory review for new dependencies
|
||||
3. **Update Cycles**: Regular, scheduled dependency updates
|
||||
4. **Documentation**: Maintain dependency rationale and decisions
|
||||
5. **Training**: Regular team education on dependency security
|
||||
|
||||
## Metrics & KPIs
|
||||
|
||||
### Security Metrics
|
||||
- Mean Time to Patch (MTTP) for vulnerabilities
|
||||
- Number of high/critical vulnerabilities
|
||||
- Percentage of dependencies with known vulnerabilities
|
||||
- Security debt accumulation rate
|
||||
|
||||
### Compliance Metrics
|
||||
- License compliance percentage
|
||||
- Number of license conflicts
|
||||
- Time to resolve compliance issues
|
||||
- Policy violation frequency
|
||||
|
||||
### Maintenance Metrics
|
||||
- Percentage of up-to-date dependencies
|
||||
- Average dependency age
|
||||
- Number of abandoned dependencies
|
||||
- Upgrade success rate
|
||||
|
||||
### Efficiency Metrics
|
||||
- Bundle size reduction percentage
|
||||
- Unused dependency elimination rate
|
||||
- Build time improvement
|
||||
- Developer productivity impact
|
||||
|
||||
## Troubleshooting Guide
|
||||
|
||||
### Common Issues
|
||||
1. **False Positives**: Tuning vulnerability detection sensitivity
|
||||
2. **License Ambiguity**: Resolving unclear or multiple licenses
|
||||
3. **Breaking Changes**: Managing major version upgrades
|
||||
4. **Performance Impact**: Optimizing scanning for large codebases
|
||||
|
||||
### Resolution Strategies
|
||||
- Whitelist false positives with documentation
|
||||
- Contact maintainers for license clarification
|
||||
- Implement feature flags for risky upgrades
|
||||
- Use incremental scanning for large projects
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
### Planned Features
|
||||
- Machine learning for vulnerability prediction
|
||||
- Automated dependency update pull requests
|
||||
- Integration with container image scanning
|
||||
- Real-time dependency monitoring dashboards
|
||||
- Natural language policy definition
|
||||
|
||||
### Ecosystem Expansion
|
||||
- Additional language support (Swift, Kotlin, Dart)
|
||||
- Container and infrastructure dependencies
|
||||
- Development tool and build system dependencies
|
||||
- Cloud service and SaaS dependency tracking
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Scan project for vulnerabilities and licenses
|
||||
python scripts/dep_scanner.py /path/to/project
|
||||
|
||||
# Check license compliance
|
||||
python scripts/license_checker.py /path/to/project --policy strict
|
||||
|
||||
# Plan dependency upgrades
|
||||
python scripts/upgrade_planner.py deps.json --risk-threshold medium
|
||||
```
|
||||
|
||||
For detailed usage instructions, see [README.md](README.md).
|
||||
|
||||
---
|
||||
|
||||
*This skill provides comprehensive dependency management capabilities essential for maintaining secure, compliant, and efficient software projects. Regular use helps teams stay ahead of security threats, maintain legal compliance, and optimize their dependency ecosystems.*
|
||||
696
docs/skills/engineering/env-secrets-manager.md
Normal file
696
docs/skills/engineering/env-secrets-manager.md
Normal file
@@ -0,0 +1,696 @@
|
||||
---
|
||||
title: "Env & Secrets Manager"
|
||||
description: "Env & Secrets Manager - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Env & Secrets Manager
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `env-secrets-manager` | **Source:** [`engineering/env-secrets-manager/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/env-secrets-manager/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering
|
||||
**Domain:** Security / DevOps / Configuration Management
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Complete environment and secrets management workflow: .env file lifecycle across dev/staging/prod,
|
||||
.env.example auto-generation, required-var validation, secret leak detection in git history, and
|
||||
credential rotation playbook. Integrates with HashiCorp Vault, AWS SSM, 1Password CLI, and Doppler.
|
||||
|
||||
---
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- **.env lifecycle** — create, validate, sync across environments
|
||||
- **.env.example generation** — strip values, preserve keys and comments
|
||||
- **Validation script** — fail-fast on missing required vars at startup
|
||||
- **Secret leak detection** — regex scan of git history and working tree
|
||||
- **Rotation workflow** — detect → scope → rotate → deploy → verify
|
||||
- **Secret manager integrations** — Vault KV v2, AWS SSM, 1Password, Doppler
|
||||
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
- Setting up a new project — scaffold .env.example and validation
|
||||
- Before every commit — scan for accidentally staged secrets
|
||||
- Post-incident response — leaked credential rotation procedure
|
||||
- Onboarding new developers — they need all vars, not just some
|
||||
- Environment drift investigation — prod behaving differently from staging
|
||||
|
||||
---
|
||||
|
||||
## .env File Structure
|
||||
|
||||
### Canonical Layout
|
||||
```bash
|
||||
# .env.example — committed to git (no values)
|
||||
# .env.local — developer machine (gitignored)
|
||||
# .env.staging — CI/CD or secret manager reference
|
||||
# .env.prod — never on disk; pulled from secret manager at runtime
|
||||
|
||||
# Application
|
||||
APP_NAME=
|
||||
APP_ENV= # dev | staging | prod
|
||||
APP_PORT=3000 # default port if not set
|
||||
APP_SECRET= # REQUIRED: JWT signing secret (min 32 chars)
|
||||
APP_URL= # REQUIRED: public base URL
|
||||
|
||||
# Database
|
||||
DATABASE_URL= # REQUIRED: full connection string
|
||||
DATABASE_POOL_MIN=2
|
||||
DATABASE_POOL_MAX=10
|
||||
|
||||
# Auth
|
||||
AUTH_JWT_SECRET= # REQUIRED
|
||||
AUTH_JWT_EXPIRY=3600 # seconds
|
||||
AUTH_REFRESH_SECRET= # REQUIRED
|
||||
|
||||
# Third-party APIs
|
||||
STRIPE_SECRET_KEY= # REQUIRED in prod
|
||||
STRIPE_WEBHOOK_SECRET= # REQUIRED in prod
|
||||
SENDGRID_API_KEY=
|
||||
|
||||
# Storage
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_REGION=eu-central-1
|
||||
AWS_S3_BUCKET=
|
||||
|
||||
# Monitoring
|
||||
SENTRY_DSN=
|
||||
DD_API_KEY=
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## .gitignore Patterns
|
||||
|
||||
Add to your project's `.gitignore`:
|
||||
|
||||
```gitignore
|
||||
# Environment files — NEVER commit these
|
||||
.env
|
||||
.env.local
|
||||
.env.development
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.staging
|
||||
.env.staging.local
|
||||
.env.production
|
||||
.env.production.local
|
||||
.env.prod
|
||||
.env.*.local
|
||||
|
||||
# Secret files
|
||||
*.pem
|
||||
*.key
|
||||
*.p12
|
||||
*.pfx
|
||||
secrets.json
|
||||
secrets.yaml
|
||||
secrets.yml
|
||||
credentials.json
|
||||
service-account.json
|
||||
|
||||
# AWS
|
||||
.aws/credentials
|
||||
|
||||
# Terraform state (may contain secrets)
|
||||
*.tfstate
|
||||
*.tfstate.backup
|
||||
.terraform/
|
||||
|
||||
# Kubernetes secrets
|
||||
*-secret.yaml
|
||||
*-secrets.yaml
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## .env.example Auto-Generation
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# scripts/gen-env-example.sh
|
||||
# Strips values from .env, preserves keys, defaults, and comments
|
||||
|
||||
INPUT="${1:-.env}"
|
||||
OUTPUT="${2:-.env.example}"
|
||||
|
||||
if [ ! -f "$INPUT" ]; then
|
||||
echo "ERROR: $INPUT not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
python3 - "$INPUT" "$OUTPUT" << 'PYEOF'
|
||||
import sys, re
|
||||
|
||||
input_file = sys.argv[1]
|
||||
output_file = sys.argv[2]
|
||||
lines = []
|
||||
|
||||
with open(input_file) as f:
|
||||
for line in f:
|
||||
stripped = line.rstrip('\n')
|
||||
# Keep blank lines and comments as-is
|
||||
if stripped == '' or stripped.startswith('#'):
|
||||
lines.append(stripped)
|
||||
continue
|
||||
# Match KEY=VALUE or KEY="VALUE"
|
||||
m = re.match(r'^([A-Z_][A-Z0-9_]*)=(.*)$', stripped)
|
||||
if m:
|
||||
key = m.group(1)
|
||||
value = m.group(2).strip('"\'')
|
||||
# Keep non-sensitive defaults (ports, regions, feature flags)
|
||||
safe_defaults = re.compile(
|
||||
r'^(APP_PORT|APP_ENV|APP_NAME|AWS_REGION|DATABASE_POOL_|LOG_LEVEL|'
|
||||
r'FEATURE_|CACHE_TTL|RATE_LIMIT_|PAGINATION_|TIMEOUT_)',
|
||||
re.I
|
||||
)
|
||||
sensitive = re.compile(
|
||||
r'(SECRET|KEY|TOKEN|PASSWORD|PASS|CREDENTIAL|DSN|AUTH|PRIVATE|CERT)',
|
||||
re.I
|
||||
)
|
||||
if safe_defaults.match(key) and value:
|
||||
lines.append(f"{key}={value} # default")
|
||||
else:
|
||||
lines.append(f"{key}=")
|
||||
else:
|
||||
lines.append(stripped)
|
||||
|
||||
with open(output_file, 'w') as f:
|
||||
f.write('\n'.join(lines) + '\n')
|
||||
|
||||
print(f"Generated {output_file} from {input_file}")
|
||||
PYEOF
|
||||
```
|
||||
|
||||
Usage:
|
||||
```bash
|
||||
bash scripts/gen-env-example.sh .env .env.example
|
||||
# Commit .env.example, never .env
|
||||
git add .env.example
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Required Variable Validation Script
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# scripts/validate-env.sh
|
||||
# Run at app startup or in CI before deploy
|
||||
# Exit 1 if any required var is missing or empty
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
MISSING=()
|
||||
WARNINGS=()
|
||||
|
||||
# --- Define required vars by environment ---
|
||||
ALWAYS_REQUIRED=(
|
||||
APP_SECRET
|
||||
APP_URL
|
||||
DATABASE_URL
|
||||
AUTH_JWT_SECRET
|
||||
AUTH_REFRESH_SECRET
|
||||
)
|
||||
|
||||
PROD_REQUIRED=(
|
||||
STRIPE_SECRET_KEY
|
||||
STRIPE_WEBHOOK_SECRET
|
||||
SENTRY_DSN
|
||||
)
|
||||
|
||||
# --- Check always-required vars ---
|
||||
for var in "${ALWAYS_REQUIRED[@]}"; do
|
||||
if [ -z "${!var:-}" ]; then
|
||||
MISSING+=("$var")
|
||||
fi
|
||||
done
|
||||
|
||||
# --- Check prod-only vars ---
|
||||
if [ "${APP_ENV:-}" = "production" ] || [ "${NODE_ENV:-}" = "production" ]; then
|
||||
for var in "${PROD_REQUIRED[@]}"; do
|
||||
if [ -z "${!var:-}" ]; then
|
||||
MISSING+=("$var (required in production)")
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# --- Validate format/length constraints ---
|
||||
if [ -n "${AUTH_JWT_SECRET:-}" ] && [ ${#AUTH_JWT_SECRET} -lt 32 ]; then
|
||||
WARNINGS+=("AUTH_JWT_SECRET is shorter than 32 chars — insecure")
|
||||
fi
|
||||
|
||||
if [ -n "${DATABASE_URL:-}" ]; then
|
||||
if ! echo "$DATABASE_URL" | grep -qE "^(postgres|postgresql|mysql|mongodb|redis)://"; then
|
||||
WARNINGS+=("DATABASE_URL doesn't look like a valid connection string")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${APP_PORT:-}" ]; then
|
||||
if ! [[ "$APP_PORT" =~ ^[0-9]+$ ]] || [ "$APP_PORT" -lt 1 ] || [ "$APP_PORT" -gt 65535 ]; then
|
||||
WARNINGS+=("APP_PORT=$APP_PORT is not a valid port number")
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- Report ---
|
||||
if [ ${#WARNINGS[@]} -gt 0 ]; then
|
||||
echo "WARNINGS:"
|
||||
for w in "${WARNINGS[@]}"; do
|
||||
echo " ⚠️ $w"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ${#MISSING[@]} -gt 0 ]; then
|
||||
echo ""
|
||||
echo "FATAL: Missing required environment variables:"
|
||||
for var in "${MISSING[@]}"; do
|
||||
echo " ❌ $var"
|
||||
done
|
||||
echo ""
|
||||
echo "Copy .env.example to .env and fill in missing values."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ All required environment variables are set"
|
||||
```
|
||||
|
||||
Node.js equivalent:
|
||||
```typescript
|
||||
// src/config/validateEnv.ts
|
||||
const required = [
|
||||
'APP_SECRET', 'APP_URL', 'DATABASE_URL',
|
||||
'AUTH_JWT_SECRET', 'AUTH_REFRESH_SECRET',
|
||||
]
|
||||
|
||||
const missing = required.filter(key => !process.env[key])
|
||||
|
||||
if (missing.length > 0) {
|
||||
console.error('FATAL: Missing required environment variables:', missing)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (process.env.AUTH_JWT_SECRET && process.env.AUTH_JWT_SECRET.length < 32) {
|
||||
console.error('FATAL: AUTH_JWT_SECRET must be at least 32 characters')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
export const config = {
|
||||
appSecret: process.env.APP_SECRET!,
|
||||
appUrl: process.env.APP_URL!,
|
||||
databaseUrl: process.env.DATABASE_URL!,
|
||||
jwtSecret: process.env.AUTH_JWT_SECRET!,
|
||||
refreshSecret: process.env.AUTH_REFRESH_SECRET!,
|
||||
stripeKey: process.env.STRIPE_SECRET_KEY, // optional
|
||||
port: parseInt(process.env.APP_PORT ?? '3000', 10),
|
||||
} as const
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Secret Leak Detection
|
||||
|
||||
### Scan Working Tree
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# scripts/scan-secrets.sh
|
||||
# Scan staged files and working tree for common secret patterns
|
||||
|
||||
FAIL=0
|
||||
|
||||
check() {
|
||||
local label="$1"
|
||||
local pattern="$2"
|
||||
local matches
|
||||
|
||||
matches=$(git diff --cached -U0 2>/dev/null | grep "^+" | grep -vE "^(\+\+\+|#|\/\/)" | \
|
||||
grep -E "$pattern" | grep -v ".env.example" | grep -v "test\|mock\|fixture\|fake" || true)
|
||||
|
||||
if [ -n "$matches" ]; then
|
||||
echo "SECRET DETECTED [$label]:"
|
||||
echo "$matches" | head -5
|
||||
FAIL=1
|
||||
fi
|
||||
}
|
||||
|
||||
# AWS Access Keys
|
||||
check "AWS Access Key" "AKIA[0-9A-Z]{16}"
|
||||
check "AWS Secret Key" "aws_secret_access_key\s*=\s*['\"]?[A-Za-z0-9/+]{40}"
|
||||
|
||||
# Stripe
|
||||
check "Stripe Live Key" "sk_live_[0-9a-zA-Z]{24,}"
|
||||
check "Stripe Test Key" "sk_test_[0-9a-zA-Z]{24,}"
|
||||
check "Stripe Webhook" "whsec_[0-9a-zA-Z]{32,}"
|
||||
|
||||
# JWT / Generic secrets
|
||||
check "Hardcoded JWT" "eyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{20,}"
|
||||
check "Generic Secret" "(secret|password|passwd|api_key|apikey|token)\s*[:=]\s*['\"][^'\"]{12,}['\"]"
|
||||
|
||||
# Private keys
|
||||
check "Private Key Block" "-----BEGIN (RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----"
|
||||
check "PEM Certificate" "-----BEGIN CERTIFICATE-----"
|
||||
|
||||
# Connection strings with credentials
|
||||
check "DB Connection" "(postgres|mysql|mongodb)://[^:]+:[^@]+@"
|
||||
check "Redis Auth" "redis://:[^@]+@\|rediss://:[^@]+@"
|
||||
|
||||
# Google
|
||||
check "Google API Key" "AIza[0-9A-Za-z_-]{35}"
|
||||
check "Google OAuth" "[0-9]+-[0-9A-Za-z_]{32}\.apps\.googleusercontent\.com"
|
||||
|
||||
# GitHub
|
||||
check "GitHub Token" "gh[ps]_[A-Za-z0-9]{36,}"
|
||||
check "GitHub Fine-grained" "github_pat_[A-Za-z0-9_]{82}"
|
||||
|
||||
# Slack
|
||||
check "Slack Token" "xox[baprs]-[0-9A-Za-z]{10,}"
|
||||
check "Slack Webhook" "https://hooks\.slack\.com/services/[A-Z0-9]{9,}/[A-Z0-9]{9,}/[A-Za-z0-9]{24,}"
|
||||
|
||||
# Twilio
|
||||
check "Twilio SID" "AC[a-z0-9]{32}"
|
||||
check "Twilio Token" "SK[a-z0-9]{32}"
|
||||
|
||||
if [ $FAIL -eq 1 ]; then
|
||||
echo ""
|
||||
echo "BLOCKED: Secrets detected in staged changes."
|
||||
echo "Remove secrets before committing. Use environment variables instead."
|
||||
echo "If this is a false positive, add it to .secretsignore or use:"
|
||||
echo " git commit --no-verify (only if you're 100% certain it's safe)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "No secrets detected in staged changes."
|
||||
```
|
||||
|
||||
### Scan Git History (post-incident)
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# scripts/scan-history.sh — scan entire git history for leaked secrets
|
||||
|
||||
PATTERNS=(
|
||||
"AKIA[0-9A-Z]{16}"
|
||||
"sk_live_[0-9a-zA-Z]{24}"
|
||||
"sk_test_[0-9a-zA-Z]{24}"
|
||||
"-----BEGIN.*PRIVATE KEY-----"
|
||||
"AIza[0-9A-Za-z_-]{35}"
|
||||
"ghp_[A-Za-z0-9]{36}"
|
||||
"xox[baprs]-[0-9A-Za-z]{10,}"
|
||||
)
|
||||
|
||||
for pattern in "${PATTERNS[@]}"; do
|
||||
echo "Scanning for: $pattern"
|
||||
git log --all -p --no-color 2>/dev/null | \
|
||||
grep -n "$pattern" | \
|
||||
grep "^+" | \
|
||||
grep -v "^+++" | \
|
||||
head -10
|
||||
done
|
||||
|
||||
# Alternative: use truffleHog or gitleaks for comprehensive scanning
|
||||
# gitleaks detect --source . --log-opts="--all"
|
||||
# trufflehog git file://. --only-verified
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pre-commit Hook Installation
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# Install the pre-commit hook
|
||||
HOOK_PATH=".git/hooks/pre-commit"
|
||||
|
||||
cat > "$HOOK_PATH" << 'HOOK'
|
||||
#!/bin/bash
|
||||
# Pre-commit: scan for secrets before every commit
|
||||
|
||||
SCRIPT="scripts/scan-secrets.sh"
|
||||
|
||||
if [ -f "$SCRIPT" ]; then
|
||||
bash "$SCRIPT"
|
||||
else
|
||||
# Inline fallback if script not present
|
||||
if git diff --cached -U0 | grep "^+" | grep -qE "AKIA[0-9A-Z]{16}|sk_live_|-----BEGIN.*PRIVATE KEY"; then
|
||||
echo "BLOCKED: Possible secret detected in staged changes."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
HOOK
|
||||
|
||||
chmod +x "$HOOK_PATH"
|
||||
echo "Pre-commit hook installed at $HOOK_PATH"
|
||||
```
|
||||
|
||||
Using `pre-commit` framework (recommended for teams):
|
||||
```yaml
|
||||
# .pre-commit-config.yaml
|
||||
repos:
|
||||
- repo: https://github.com/gitleaks/gitleaks
|
||||
rev: v8.18.0
|
||||
hooks:
|
||||
- id: gitleaks
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: validate-env-example
|
||||
name: Check .env.example is up to date
|
||||
language: script
|
||||
entry: bash scripts/check-env-example.sh
|
||||
pass_filenames: false
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Credential Rotation Workflow
|
||||
|
||||
When a secret is leaked or compromised:
|
||||
|
||||
### Step 1 — Detect & Confirm
|
||||
```bash
|
||||
# Confirm which secret was exposed
|
||||
git log --all -p --no-color | grep -A2 -B2 "AKIA\|sk_live_\|SECRET"
|
||||
|
||||
# Check if secret is in any open PRs
|
||||
gh pr list --state open | while read pr; do
|
||||
gh pr diff $(echo $pr | awk '{print $1}') | grep -E "AKIA|sk_live_" && echo "Found in PR: $pr"
|
||||
done
|
||||
```
|
||||
|
||||
### Step 2 — Identify Exposure Window
|
||||
```bash
|
||||
# Find first commit that introduced the secret
|
||||
git log --all -p --no-color -- "*.env" "*.json" "*.yaml" "*.ts" "*.py" | \
|
||||
grep -B 10 "THE_LEAKED_VALUE" | grep "^commit" | tail -1
|
||||
|
||||
# Get commit date
|
||||
git show --format="%ci" COMMIT_HASH | head -1
|
||||
|
||||
# Check if secret appears in public repos (GitHub)
|
||||
gh api search/code -X GET -f q="THE_LEAKED_VALUE" | jq '.total_count, .items[].html_url'
|
||||
```
|
||||
|
||||
### Step 3 — Rotate Credential
|
||||
Per service — rotate immediately:
|
||||
- **AWS**: IAM console → delete access key → create new → update everywhere
|
||||
- **Stripe**: Dashboard → Developers → API keys → Roll key
|
||||
- **GitHub PAT**: Settings → Developer Settings → Personal access tokens → Revoke → Create new
|
||||
- **DB password**: `ALTER USER app_user PASSWORD 'new-strong-password-here';`
|
||||
- **JWT secret**: Rotate key (all existing sessions invalidated — users re-login)
|
||||
|
||||
### Step 4 — Update All Environments
|
||||
```bash
|
||||
# Update secret manager (source of truth)
|
||||
# Then redeploy to pull new values
|
||||
|
||||
# Vault KV v2
|
||||
vault kv put secret/myapp/prod \
|
||||
STRIPE_SECRET_KEY="sk_live_NEW..." \
|
||||
APP_SECRET="new-secret-here"
|
||||
|
||||
# AWS SSM
|
||||
aws ssm put-parameter \
|
||||
--name "/myapp/prod/STRIPE_SECRET_KEY" \
|
||||
--value "sk_live_NEW..." \
|
||||
--type "SecureString" \
|
||||
--overwrite
|
||||
|
||||
# 1Password
|
||||
op item edit "MyApp Prod" \
|
||||
--field "STRIPE_SECRET_KEY[password]=sk_live_NEW..."
|
||||
|
||||
# Doppler
|
||||
doppler secrets set STRIPE_SECRET_KEY="sk_live_NEW..." --project myapp --config prod
|
||||
```
|
||||
|
||||
### Step 5 — Remove from Git History
|
||||
```bash
|
||||
# WARNING: rewrites history — coordinate with team first
|
||||
git filter-repo --path-glob "*.env" --invert-paths
|
||||
|
||||
# Or remove specific string from all commits
|
||||
git filter-repo --replace-text <(echo "LEAKED_VALUE==>REDACTED")
|
||||
|
||||
# Force push all branches (requires team coordination + force push permissions)
|
||||
git push origin --force --all
|
||||
|
||||
# Notify all developers to re-clone
|
||||
```
|
||||
|
||||
### Step 6 — Verify
|
||||
```bash
|
||||
# Confirm secret no longer in history
|
||||
git log --all -p | grep "LEAKED_VALUE" | wc -l # should be 0
|
||||
|
||||
# Test new credentials work
|
||||
curl -H "Authorization: Bearer $NEW_TOKEN" https://api.service.com/test
|
||||
|
||||
# Monitor for unauthorized usage of old credential (check service audit logs)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Secret Manager Integrations
|
||||
|
||||
### HashiCorp Vault KV v2
|
||||
```bash
|
||||
# Setup
|
||||
export VAULT_ADDR="https://vault.internal.company.com"
|
||||
export VAULT_TOKEN="$(vault login -method=oidc -format=json | jq -r '.auth.client_token')"
|
||||
|
||||
# Write secrets
|
||||
vault kv put secret/myapp/prod \
|
||||
DATABASE_URL="postgres://user:pass@host/db" \
|
||||
APP_SECRET="$(openssl rand -base64 32)"
|
||||
|
||||
# Read secrets into env
|
||||
eval $(vault kv get -format=json secret/myapp/prod | \
|
||||
jq -r '.data.data | to_entries[] | "export \(.key)=\(.value)"')
|
||||
|
||||
# In CI/CD (GitHub Actions)
|
||||
# Use vault-action: hashicorp/vault-action@v2
|
||||
```
|
||||
|
||||
### AWS SSM Parameter Store
|
||||
```bash
|
||||
# Write (SecureString = encrypted with KMS)
|
||||
aws ssm put-parameter \
|
||||
--name "/myapp/prod/DATABASE_URL" \
|
||||
--value "postgres://..." \
|
||||
--type "SecureString" \
|
||||
--key-id "alias/myapp-secrets"
|
||||
|
||||
# Read all params for an app/env into shell
|
||||
eval $(aws ssm get-parameters-by-path \
|
||||
--path "/myapp/prod/" \
|
||||
--with-decryption \
|
||||
--query "Parameters[*].[Name,Value]" \
|
||||
--output text | \
|
||||
awk '{split($1,a,"/"); print "export " a[length(a)] "=\"" $2 "\""}')
|
||||
|
||||
# In Node.js at startup
|
||||
# Use @aws-sdk/client-ssm to pull params before server starts
|
||||
```
|
||||
|
||||
### 1Password CLI
|
||||
```bash
|
||||
# Authenticate
|
||||
eval $(op signin)
|
||||
|
||||
# Get a specific field
|
||||
op read "op://MyVault/MyApp Prod/STRIPE_SECRET_KEY"
|
||||
|
||||
# Export all fields from an item as env vars
|
||||
op item get "MyApp Prod" --format json | \
|
||||
jq -r '.fields[] | select(.value != null) | "export \(.label)=\"\(.value)\""' | \
|
||||
grep -E "^export [A-Z_]+" | source /dev/stdin
|
||||
|
||||
# .env injection
|
||||
op inject -i .env.tpl -o .env
|
||||
# .env.tpl uses {{ op://Vault/Item/field }} syntax
|
||||
```
|
||||
|
||||
### Doppler
|
||||
```bash
|
||||
# Setup
|
||||
doppler setup # interactive: select project + config
|
||||
|
||||
# Run any command with secrets injected
|
||||
doppler run -- node server.js
|
||||
doppler run -- npm run dev
|
||||
|
||||
# Export to .env (local dev only — never commit output)
|
||||
doppler secrets download --no-file --format env > .env.local
|
||||
|
||||
# Pull specific secret
|
||||
doppler secrets get DATABASE_URL --plain
|
||||
|
||||
# Sync to another environment
|
||||
doppler secrets upload --project myapp --config staging < .env.staging.example
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Environment Drift Detection
|
||||
|
||||
Check if staging and prod have the same set of keys (values may differ):
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
# scripts/check-env-drift.sh
|
||||
|
||||
# Pull key names from both environments (not values)
|
||||
STAGING_KEYS=$(doppler secrets --project myapp --config staging --format json 2>/dev/null | \
|
||||
jq -r 'keys[]' | sort)
|
||||
PROD_KEYS=$(doppler secrets --project myapp --config prod --format json 2>/dev/null | \
|
||||
jq -r 'keys[]' | sort)
|
||||
|
||||
ONLY_IN_STAGING=$(comm -23 <(echo "$STAGING_KEYS") <(echo "$PROD_KEYS"))
|
||||
ONLY_IN_PROD=$(comm -13 <(echo "$STAGING_KEYS") <(echo "$PROD_KEYS"))
|
||||
|
||||
if [ -n "$ONLY_IN_STAGING" ]; then
|
||||
echo "Keys in STAGING but NOT in PROD:"
|
||||
echo "$ONLY_IN_STAGING" | sed 's/^/ /'
|
||||
fi
|
||||
|
||||
if [ -n "$ONLY_IN_PROD" ]; then
|
||||
echo "Keys in PROD but NOT in STAGING:"
|
||||
echo "$ONLY_IN_PROD" | sed 's/^/ /'
|
||||
fi
|
||||
|
||||
if [ -z "$ONLY_IN_STAGING" ] && [ -z "$ONLY_IN_PROD" ]; then
|
||||
echo "✅ No env drift detected — staging and prod have identical key sets"
|
||||
fi
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
- **Committing .env instead of .env.example** — add `.env` to .gitignore on day 1; use pre-commit hooks
|
||||
- **Storing secrets in CI/CD logs** — never `echo $SECRET`; mask vars in CI settings
|
||||
- **Rotating only one place** — secrets often appear in Heroku, Vercel, Docker, K8s, CI — update ALL
|
||||
- **Forgetting to invalidate sessions after JWT secret rotation** — all users will be logged out; communicate this
|
||||
- **Using .env.example with real values** — example files are public; strip everything sensitive
|
||||
- **Not monitoring after rotation** — watch audit logs for 24h after rotation to catch unauthorized old-credential use
|
||||
- **Weak secrets** — `APP_SECRET=mysecret` is not a secret. Use `openssl rand -base64 32`
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Secret manager is source of truth** — .env files are for local dev only; never in prod
|
||||
2. **Rotate on a schedule**, not just after incidents — quarterly minimum for long-lived keys
|
||||
3. **Principle of least privilege** — each service gets its own API key with minimal permissions
|
||||
4. **Audit access** — log every secret read in Vault/SSM; alert on anomalous access
|
||||
5. **Never log secrets** — add log scrubbing middleware that redacts known secret patterns
|
||||
6. **Use short-lived credentials** — prefer OIDC/instance roles over long-lived access keys
|
||||
7. **Separate secrets per environment** — never share a key between dev and prod
|
||||
8. **Document rotation runbooks** — before an incident, not during one
|
||||
198
docs/skills/engineering/git-worktree-manager.md
Normal file
198
docs/skills/engineering/git-worktree-manager.md
Normal file
@@ -0,0 +1,198 @@
|
||||
---
|
||||
title: "Git Worktree Manager"
|
||||
description: "Git Worktree Manager - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Git Worktree Manager
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `git-worktree-manager` | **Source:** [`engineering/git-worktree-manager/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/git-worktree-manager/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering
|
||||
**Domain:** Parallel Development & Branch Isolation
|
||||
|
||||
## Overview
|
||||
|
||||
Use this skill to run parallel feature work safely with Git worktrees. It standardizes branch isolation, port allocation, environment sync, and cleanup so each worktree behaves like an independent local app without stepping on another branch.
|
||||
|
||||
This skill is optimized for multi-agent workflows where each agent or terminal session owns one worktree.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- Create worktrees from new or existing branches with deterministic naming
|
||||
- Auto-allocate non-conflicting ports per worktree and persist assignments
|
||||
- Copy local environment files (`.env*`) from main repo to new worktree
|
||||
- Optionally install dependencies based on lockfile detection
|
||||
- Detect stale worktrees and uncommitted changes before cleanup
|
||||
- Identify merged branches and safely remove outdated worktrees
|
||||
|
||||
## When to Use
|
||||
|
||||
- You need 2+ concurrent branches open locally
|
||||
- You want isolated dev servers for feature, hotfix, and PR validation
|
||||
- You are working with multiple agents that must not share a branch
|
||||
- Your current branch is blocked but you need to ship a quick fix now
|
||||
- You want repeatable cleanup instead of ad-hoc `rm -rf` operations
|
||||
|
||||
## Key Workflows
|
||||
|
||||
### 1. Create a Fully-Prepared Worktree
|
||||
|
||||
1. Pick a branch name and worktree name.
|
||||
2. Run the manager script (creates branch if missing).
|
||||
3. Review generated port map.
|
||||
4. Start app using allocated ports.
|
||||
|
||||
```bash
|
||||
python scripts/worktree_manager.py \
|
||||
--repo . \
|
||||
--branch feature/new-auth \
|
||||
--name wt-auth \
|
||||
--base-branch main \
|
||||
--install-deps \
|
||||
--format text
|
||||
```
|
||||
|
||||
If you use JSON automation input:
|
||||
|
||||
```bash
|
||||
cat config.json | python scripts/worktree_manager.py --format json
|
||||
# or
|
||||
python scripts/worktree_manager.py --input config.json --format json
|
||||
```
|
||||
|
||||
### 2. Run Parallel Sessions
|
||||
|
||||
Recommended convention:
|
||||
|
||||
- Main repo: integration branch (`main`/`develop`) on default port
|
||||
- Worktree A: feature branch + offset ports
|
||||
- Worktree B: hotfix branch + next offset
|
||||
|
||||
Each worktree contains `.worktree-ports.json` with assigned ports.
|
||||
|
||||
### 3. Cleanup with Safety Checks
|
||||
|
||||
1. Scan all worktrees and stale age.
|
||||
2. Inspect dirty trees and branch merge status.
|
||||
3. Remove only merged + clean worktrees, or force explicitly.
|
||||
|
||||
```bash
|
||||
python scripts/worktree_cleanup.py --repo . --stale-days 14 --format text
|
||||
python scripts/worktree_cleanup.py --repo . --remove-merged --format text
|
||||
```
|
||||
|
||||
### 4. Docker Compose Pattern
|
||||
|
||||
Use per-worktree override files mapped from allocated ports. The script outputs a deterministic port map; apply it to `docker-compose.worktree.yml`.
|
||||
|
||||
See [docker-compose-patterns.md](references/docker-compose-patterns.md) for concrete templates.
|
||||
|
||||
### 5. Port Allocation Strategy
|
||||
|
||||
Default strategy is `base + (index * stride)` with collision checks:
|
||||
|
||||
- App: `3000`
|
||||
- Postgres: `5432`
|
||||
- Redis: `6379`
|
||||
- Stride: `10`
|
||||
|
||||
See [port-allocation-strategy.md](references/port-allocation-strategy.md) for the full strategy and edge cases.
|
||||
|
||||
## Script Interfaces
|
||||
|
||||
- `python scripts/worktree_manager.py --help`
|
||||
- Create/list worktrees
|
||||
- Allocate/persist ports
|
||||
- Copy `.env*` files
|
||||
- Optional dependency installation
|
||||
- `python scripts/worktree_cleanup.py --help`
|
||||
- Stale detection by age
|
||||
- Dirty-state detection
|
||||
- Merged-branch detection
|
||||
- Optional safe removal
|
||||
|
||||
Both tools support stdin JSON and `--input` file mode for automation pipelines.
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
1. Creating worktrees inside the main repo directory
|
||||
2. Reusing `localhost:3000` across all branches
|
||||
3. Sharing one database URL across isolated feature branches
|
||||
4. Removing a worktree with uncommitted changes
|
||||
5. Forgetting to prune old metadata after branch deletion
|
||||
6. Assuming merged status without checking against the target branch
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. One branch per worktree, one agent per worktree.
|
||||
2. Keep worktrees short-lived; remove after merge.
|
||||
3. Use a deterministic naming pattern (`wt-<topic>`).
|
||||
4. Persist port mappings in file, not memory or terminal notes.
|
||||
5. Run cleanup scan weekly in active repos.
|
||||
6. Use `--format json` for machine flows and `--format text` for human review.
|
||||
7. Never force-remove dirty worktrees unless changes are intentionally discarded.
|
||||
|
||||
## Validation Checklist
|
||||
|
||||
Before claiming setup complete:
|
||||
|
||||
1. `git worktree list` shows expected path + branch.
|
||||
2. `.worktree-ports.json` exists and contains unique ports.
|
||||
3. `.env` files copied successfully (if present in source repo).
|
||||
4. Dependency install command exits with code `0` (if enabled).
|
||||
5. Cleanup scan reports no unintended stale dirty trees.
|
||||
|
||||
## References
|
||||
|
||||
- [port-allocation-strategy.md](references/port-allocation-strategy.md)
|
||||
- [docker-compose-patterns.md](references/docker-compose-patterns.md)
|
||||
- [README.md](README.md) for quick start and installation details
|
||||
|
||||
## Decision Matrix
|
||||
|
||||
Use this quick selector before creating a new worktree:
|
||||
|
||||
- Need isolated dependencies and server ports -> create a new worktree
|
||||
- Need only a quick local diff review -> stay on current tree
|
||||
- Need hotfix while feature branch is dirty -> create dedicated hotfix worktree
|
||||
- Need ephemeral reproduction branch for bug triage -> create temporary worktree and cleanup same day
|
||||
|
||||
## Operational Checklist
|
||||
|
||||
### Before Creation
|
||||
|
||||
1. Confirm main repo has clean baseline or intentional WIP commits.
|
||||
2. Confirm target branch naming convention.
|
||||
3. Confirm required base branch exists (`main`/`develop`).
|
||||
4. Confirm no reserved local ports are already occupied by non-repo services.
|
||||
|
||||
### After Creation
|
||||
|
||||
1. Verify `git status` branch matches expected branch.
|
||||
2. Verify `.worktree-ports.json` exists.
|
||||
3. Verify app boots on allocated app port.
|
||||
4. Verify DB and cache endpoints target isolated ports.
|
||||
|
||||
### Before Removal
|
||||
|
||||
1. Verify branch has upstream and is merged when intended.
|
||||
2. Verify no uncommitted files remain.
|
||||
3. Verify no running containers/processes depend on this worktree path.
|
||||
|
||||
## CI and Team Integration
|
||||
|
||||
- Use worktree path naming that maps to task ID (`wt-1234-auth`).
|
||||
- Include the worktree path in terminal title to avoid wrong-window commits.
|
||||
- In automated setups, persist creation metadata in CI artifacts/logs.
|
||||
- Trigger cleanup report in scheduled jobs and post summary to team channel.
|
||||
|
||||
## Failure Recovery
|
||||
|
||||
- If `git worktree add` fails due to existing path: inspect path, do not overwrite.
|
||||
- If dependency install fails: keep worktree created, mark status and continue manual recovery.
|
||||
- If env copy fails: continue with warning and explicit missing file list.
|
||||
- If port allocation collides with external service: rerun with adjusted base ports.
|
||||
36
docs/skills/engineering/index.md
Normal file
36
docs/skills/engineering/index.md
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: "Engineering - POWERFUL Skills"
|
||||
description: "All Engineering - POWERFUL skills for Claude Code, OpenAI Codex, and OpenClaw."
|
||||
---
|
||||
|
||||
# Engineering - POWERFUL Skills
|
||||
|
||||
25 skills in this domain.
|
||||
|
||||
| Skill | Description |
|
||||
|-------|-------------|
|
||||
| [Agent Designer - Multi-Agent System Architecture](agent-designer.md) | `agent-designer` |
|
||||
| [Agent Workflow Designer](agent-workflow-designer.md) | `agent-workflow-designer` |
|
||||
| [API Design Reviewer](api-design-reviewer.md) | `api-design-reviewer` |
|
||||
| [API Test Suite Builder](api-test-suite-builder.md) | `api-test-suite-builder` |
|
||||
| [Changelog Generator](changelog-generator.md) | `changelog-generator` |
|
||||
| [CI/CD Pipeline Builder](ci-cd-pipeline-builder.md) | `ci-cd-pipeline-builder` |
|
||||
| [Codebase Onboarding](codebase-onboarding.md) | `codebase-onboarding` |
|
||||
| [Database Designer - POWERFUL Tier Skill](database-designer.md) | `database-designer` |
|
||||
| [Database Schema Designer](database-schema-designer.md) | `database-schema-designer` |
|
||||
| [Dependency Auditor](dependency-auditor.md) | `dependency-auditor` |
|
||||
| [Env & Secrets Manager](env-secrets-manager.md) | `env-secrets-manager` |
|
||||
| [Git Worktree Manager](git-worktree-manager.md) | `git-worktree-manager` |
|
||||
| [Interview System Designer](interview-system-designer.md) | `interview-system-designer` |
|
||||
| [MCP Server Builder](mcp-server-builder.md) | `mcp-server-builder` |
|
||||
| [Migration Architect](migration-architect.md) | `migration-architect` |
|
||||
| [Monorepo Navigator](monorepo-navigator.md) | `monorepo-navigator` |
|
||||
| [Observability Designer (POWERFUL)](observability-designer.md) | `observability-designer` |
|
||||
| [Performance Profiler](performance-profiler.md) | `performance-profiler` |
|
||||
| [PR Review Expert](pr-review-expert.md) | `pr-review-expert` |
|
||||
| [RAG Architect - POWERFUL](rag-architect.md) | `rag-architect` |
|
||||
| [Release Manager](release-manager.md) | `release-manager` |
|
||||
| [Runbook Generator](runbook-generator.md) | `runbook-generator` |
|
||||
| [Skill Security Auditor](skill-security-auditor.md) | `skill-security-auditor` |
|
||||
| [Skill Tester](skill-tester.md) | `skill-tester` |
|
||||
| [Tech Debt Tracker](tech-debt-tracker.md) | `tech-debt-tracker` |
|
||||
465
docs/skills/engineering/interview-system-designer.md
Normal file
465
docs/skills/engineering/interview-system-designer.md
Normal file
@@ -0,0 +1,465 @@
|
||||
---
|
||||
title: "Interview System Designer"
|
||||
description: "Interview System Designer - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Interview System Designer
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `interview-system-designer` | **Source:** [`engineering/interview-system-designer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/interview-system-designer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
# Interview System Designer
|
||||
|
||||
Comprehensive interview system design, competency assessment, and hiring process optimization.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Quick Start](#quick-start)
|
||||
- [Tools Overview](#tools-overview)
|
||||
- [Interview Loop Designer](#1-interview-loop-designer)
|
||||
- [Question Bank Generator](#2-question-bank-generator)
|
||||
- [Hiring Calibrator](#3-hiring-calibrator)
|
||||
- [Interview System Workflows](#interview-system-workflows)
|
||||
- [Role-Specific Loop Design](#role-specific-loop-design)
|
||||
- [Competency Matrix Development](#competency-matrix-development)
|
||||
- [Question Bank Creation](#question-bank-creation)
|
||||
- [Bias Mitigation Framework](#bias-mitigation-framework)
|
||||
- [Hiring Bar Calibration](#hiring-bar-calibration)
|
||||
- [Competency Frameworks](#competency-frameworks)
|
||||
- [Scoring & Calibration](#scoring--calibration)
|
||||
- [Reference Documentation](#reference-documentation)
|
||||
- [Industry Standards](#industry-standards)
|
||||
|
||||
---
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Design a complete interview loop for a senior software engineer role
|
||||
python loop_designer.py --role "Senior Software Engineer" --level senior --team platform --output loops/
|
||||
|
||||
# Generate a comprehensive question bank for a product manager position
|
||||
python question_bank_generator.py --role "Product Manager" --level senior --competencies leadership,strategy,analytics --output questions/
|
||||
|
||||
# Analyze interview calibration across multiple candidates and interviewers
|
||||
python hiring_calibrator.py --input interview_data.json --output calibration_report.json --analysis-type full
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tools Overview
|
||||
|
||||
### 1. Interview Loop Designer
|
||||
|
||||
Generates calibrated interview loops tailored to specific roles, levels, and teams.
|
||||
|
||||
**Input:** Role definition (title, level, team, competency requirements)
|
||||
**Output:** Complete interview loop with rounds, focus areas, time allocation, scorecard templates
|
||||
|
||||
**Key Features:**
|
||||
- Role-specific competency mapping
|
||||
- Level-appropriate question difficulty
|
||||
- Interviewer skill requirements
|
||||
- Time-optimized scheduling
|
||||
- Standardized scorecards
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Design loop for a specific role
|
||||
python loop_designer.py --role "Staff Data Scientist" --level staff --team ml-platform
|
||||
|
||||
# Generate loop with specific focus areas
|
||||
python loop_designer.py --role "Engineering Manager" --level senior --competencies leadership,technical,strategy
|
||||
|
||||
# Create loop for multiple levels
|
||||
python loop_designer.py --role "Backend Engineer" --levels junior,mid,senior --output loops/backend/
|
||||
```
|
||||
|
||||
### 2. Question Bank Generator
|
||||
|
||||
Creates comprehensive, competency-based interview questions with detailed scoring criteria.
|
||||
|
||||
**Input:** Role requirements, competency areas, experience level
|
||||
**Output:** Structured question bank with scoring rubrics, follow-up probes, and calibration examples
|
||||
|
||||
**Key Features:**
|
||||
- Competency-based question organization
|
||||
- Level-appropriate difficulty progression
|
||||
- Behavioral and technical question types
|
||||
- Anti-bias question design
|
||||
- Calibration examples (poor/good/great answers)
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Generate questions for technical competencies
|
||||
python question_bank_generator.py --role "Frontend Engineer" --competencies react,typescript,system-design
|
||||
|
||||
# Create behavioral question bank
|
||||
python question_bank_generator.py --role "Product Manager" --question-types behavioral,leadership --output pm_questions/
|
||||
|
||||
# Generate questions for all levels
|
||||
python question_bank_generator.py --role "DevOps Engineer" --levels junior,mid,senior,staff
|
||||
```
|
||||
|
||||
### 3. Hiring Calibrator
|
||||
|
||||
Analyzes interview scores to detect bias, calibration issues, and recommends improvements.
|
||||
|
||||
**Input:** Interview results data (candidate scores, interviewer feedback, demographics)
|
||||
**Output:** Calibration analysis, bias detection report, interviewer coaching recommendations
|
||||
|
||||
**Key Features:**
|
||||
- Statistical bias detection
|
||||
- Interviewer calibration analysis
|
||||
- Score distribution analysis
|
||||
- Recommendation engine
|
||||
- Trend tracking over time
|
||||
|
||||
**Usage:**
|
||||
```bash
|
||||
# Analyze calibration across all interviews
|
||||
python hiring_calibrator.py --input interview_results.json --analysis-type comprehensive
|
||||
|
||||
# Focus on specific competency areas
|
||||
python hiring_calibrator.py --input data.json --competencies technical,leadership --output bias_report.json
|
||||
|
||||
# Track calibration trends over time
|
||||
python hiring_calibrator.py --input historical_data.json --trend-analysis --period quarterly
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Interview System Workflows
|
||||
|
||||
### Role-Specific Loop Design
|
||||
|
||||
#### Software Engineering Roles
|
||||
|
||||
**Junior/Mid Software Engineer (2-4 years)**
|
||||
- **Duration:** 3-4 hours across 3-4 rounds
|
||||
- **Focus Areas:** Coding fundamentals, debugging, system understanding, growth mindset
|
||||
- **Rounds:**
|
||||
1. Technical Phone Screen (45min) - Coding fundamentals, algorithms
|
||||
2. Coding Deep Dive (60min) - Problem-solving, code quality, testing
|
||||
3. System Design Basics (45min) - Component interaction, basic scalability
|
||||
4. Behavioral & Values (30min) - Team collaboration, learning agility
|
||||
|
||||
**Senior Software Engineer (5-8 years)**
|
||||
- **Duration:** 4-5 hours across 4-5 rounds
|
||||
- **Focus Areas:** System design, technical leadership, mentoring capability, domain expertise
|
||||
- **Rounds:**
|
||||
1. Technical Phone Screen (45min) - Advanced algorithms, optimization
|
||||
2. System Design (60min) - Scalability, trade-offs, architectural decisions
|
||||
3. Coding Excellence (60min) - Code quality, testing strategies, refactoring
|
||||
4. Technical Leadership (45min) - Mentoring, technical decisions, cross-team collaboration
|
||||
5. Behavioral & Culture (30min) - Leadership examples, conflict resolution
|
||||
|
||||
**Staff+ Engineer (8+ years)**
|
||||
- **Duration:** 5-6 hours across 5-6 rounds
|
||||
- **Focus Areas:** Architectural vision, organizational impact, technical strategy, cross-functional leadership
|
||||
- **Rounds:**
|
||||
1. Technical Phone Screen (45min) - System architecture, complex problem-solving
|
||||
2. Architecture Design (90min) - Large-scale systems, technology choices, evolution patterns
|
||||
3. Technical Strategy (60min) - Technical roadmaps, technology adoption, risk assessment
|
||||
4. Leadership & Influence (60min) - Cross-team impact, technical vision, stakeholder management
|
||||
5. Coding & Best Practices (45min) - Code quality standards, development processes
|
||||
6. Cultural & Strategic Fit (30min) - Company values, strategic thinking
|
||||
|
||||
#### Product Management Roles
|
||||
|
||||
**Product Manager (3-6 years)**
|
||||
- **Duration:** 3-4 hours across 4 rounds
|
||||
- **Focus Areas:** Product sense, analytical thinking, stakeholder management, execution
|
||||
- **Rounds:**
|
||||
1. Product Sense (60min) - Feature prioritization, user empathy, market understanding
|
||||
2. Analytical Thinking (45min) - Data interpretation, metrics design, experimentation
|
||||
3. Execution & Process (45min) - Project management, cross-functional collaboration
|
||||
4. Behavioral & Leadership (30min) - Stakeholder management, conflict resolution
|
||||
|
||||
**Senior Product Manager (6-10 years)**
|
||||
- **Duration:** 4-5 hours across 4-5 rounds
|
||||
- **Focus Areas:** Product strategy, team leadership, business impact, market analysis
|
||||
- **Rounds:**
|
||||
1. Product Strategy (75min) - Market analysis, competitive positioning, roadmap planning
|
||||
2. Leadership & Influence (60min) - Team building, stakeholder management, decision-making
|
||||
3. Data & Analytics (45min) - Advanced metrics, experimentation design, business intelligence
|
||||
4. Technical Collaboration (45min) - Technical trade-offs, engineering partnership
|
||||
5. Case Study Presentation (45min) - Past impact, lessons learned, strategic thinking
|
||||
|
||||
#### Design Roles
|
||||
|
||||
**UX Designer (2-5 years)**
|
||||
- **Duration:** 3-4 hours across 3-4 rounds
|
||||
- **Focus Areas:** Design process, user research, visual design, collaboration
|
||||
- **Rounds:**
|
||||
1. Portfolio Review (60min) - Design process, problem-solving approach, visual skills
|
||||
2. Design Challenge (90min) - User-centered design, wireframing, iteration
|
||||
3. Collaboration & Process (45min) - Cross-functional work, feedback incorporation
|
||||
4. Behavioral & Values (30min) - User advocacy, creative problem-solving
|
||||
|
||||
**Senior UX Designer (5+ years)**
|
||||
- **Duration:** 4-5 hours across 4-5 rounds
|
||||
- **Focus Areas:** Design leadership, system thinking, research methodology, business impact
|
||||
- **Rounds:**
|
||||
1. Portfolio Deep Dive (75min) - Design impact, methodology, leadership examples
|
||||
2. Design System Challenge (90min) - Systems thinking, scalability, consistency
|
||||
3. Research & Strategy (60min) - User research methods, data-driven design decisions
|
||||
4. Leadership & Mentoring (45min) - Design team leadership, process improvement
|
||||
5. Business & Strategy (30min) - Design's business impact, stakeholder management
|
||||
|
||||
### Competency Matrix Development
|
||||
|
||||
#### Technical Competencies
|
||||
|
||||
**Software Engineering**
|
||||
- **Coding Proficiency:** Algorithm design, data structures, language expertise
|
||||
- **System Design:** Architecture patterns, scalability, performance optimization
|
||||
- **Testing & Quality:** Unit testing, integration testing, code review practices
|
||||
- **DevOps & Tools:** CI/CD, monitoring, debugging, development workflows
|
||||
|
||||
**Data Science & Analytics**
|
||||
- **Statistical Analysis:** Statistical methods, hypothesis testing, experimental design
|
||||
- **Machine Learning:** Algorithm selection, model evaluation, feature engineering
|
||||
- **Data Engineering:** ETL processes, data pipeline design, data quality
|
||||
- **Business Intelligence:** Metrics design, dashboard creation, stakeholder communication
|
||||
|
||||
**Product Management**
|
||||
- **Product Strategy:** Market analysis, competitive research, roadmap planning
|
||||
- **User Research:** User interviews, usability testing, persona development
|
||||
- **Data Analysis:** Metrics interpretation, A/B testing, cohort analysis
|
||||
- **Technical Understanding:** API design, database concepts, system architecture
|
||||
|
||||
#### Behavioral Competencies
|
||||
|
||||
**Leadership & Influence**
|
||||
- **Team Building:** Hiring, onboarding, team culture development
|
||||
- **Mentoring & Coaching:** Skill development, career guidance, feedback delivery
|
||||
- **Strategic Thinking:** Long-term planning, vision setting, decision-making frameworks
|
||||
- **Change Management:** Process improvement, organizational change, resistance handling
|
||||
|
||||
**Communication & Collaboration**
|
||||
- **Stakeholder Management:** Expectation setting, conflict resolution, alignment building
|
||||
- **Cross-Functional Partnership:** Engineering-Product-Design collaboration
|
||||
- **Presentation Skills:** Technical communication, executive briefings, documentation
|
||||
- **Active Listening:** Empathy, question asking, perspective taking
|
||||
|
||||
**Problem-Solving & Innovation**
|
||||
- **Analytical Thinking:** Problem decomposition, root cause analysis, hypothesis formation
|
||||
- **Creative Problem-Solving:** Alternative solution generation, constraint navigation
|
||||
- **Learning Agility:** Skill acquisition, adaptation to change, knowledge transfer
|
||||
- **Risk Assessment:** Uncertainty navigation, trade-off analysis, mitigation planning
|
||||
|
||||
### Question Bank Creation
|
||||
|
||||
#### Technical Questions by Level
|
||||
|
||||
**Junior Level Questions**
|
||||
- **Coding:** "Implement a function to find the second largest element in an array"
|
||||
- **System Design:** "How would you design a simple URL shortener for 1000 users?"
|
||||
- **Debugging:** "Walk through how you would debug a slow-loading web page"
|
||||
|
||||
**Senior Level Questions**
|
||||
- **Architecture:** "Design a real-time chat system supporting 1M concurrent users"
|
||||
- **Leadership:** "Describe how you would onboard a new team member in your area"
|
||||
- **Trade-offs:** "Compare microservices vs monolith for a rapidly scaling startup"
|
||||
|
||||
**Staff+ Level Questions**
|
||||
- **Strategy:** "How would you evaluate and introduce a new programming language to the organization?"
|
||||
- **Influence:** "Describe a time you drove technical consensus across multiple teams"
|
||||
- **Vision:** "How do you balance technical debt against feature development?"
|
||||
|
||||
#### Behavioral Questions Framework
|
||||
|
||||
**STAR Method Implementation**
|
||||
- **Situation:** Context and background of the scenario
|
||||
- **Task:** Specific challenge or goal that needed to be addressed
|
||||
- **Action:** Concrete steps taken to address the challenge
|
||||
- **Result:** Measurable outcomes and lessons learned
|
||||
|
||||
**Sample Questions:**
|
||||
- "Tell me about a time you had to influence a decision without formal authority"
|
||||
- "Describe a situation where you had to deliver difficult feedback to a colleague"
|
||||
- "Give an example of when you had to adapt your communication style for different audiences"
|
||||
- "Walk me through a time when you had to make a decision with incomplete information"
|
||||
|
||||
### Bias Mitigation Framework
|
||||
|
||||
#### Structural Bias Prevention
|
||||
|
||||
**Interview Panel Composition**
|
||||
- Diverse interviewer panels (gender, ethnicity, experience level)
|
||||
- Rotating panel assignments to prevent pattern bias
|
||||
- Anonymous resume screening for initial phone screens
|
||||
- Standardized question sets to ensure consistency
|
||||
|
||||
**Process Standardization**
|
||||
- Structured interview guides with required probing questions
|
||||
- Consistent time allocation across all candidates
|
||||
- Standardized evaluation criteria and scoring rubrics
|
||||
- Required justification for all scoring decisions
|
||||
|
||||
#### Cognitive Bias Recognition
|
||||
|
||||
**Common Interview Biases**
|
||||
- **Halo Effect:** One strong impression influences overall assessment
|
||||
- **Confirmation Bias:** Seeking information that confirms initial impressions
|
||||
- **Similarity Bias:** Favoring candidates with similar backgrounds/experiences
|
||||
- **Contrast Effect:** Comparing candidates against each other rather than standard
|
||||
- **Anchoring Bias:** Over-relying on first piece of information received
|
||||
|
||||
**Mitigation Strategies**
|
||||
- Pre-interview bias awareness training for all interviewers
|
||||
- Structured debrief sessions with independent score recording
|
||||
- Regular calibration sessions with example candidate discussions
|
||||
- Statistical monitoring of scoring patterns by interviewer and demographic
|
||||
|
||||
### Hiring Bar Calibration
|
||||
|
||||
#### Calibration Methodology
|
||||
|
||||
**Regular Calibration Sessions**
|
||||
- Monthly interviewer calibration meetings
|
||||
- Shadow interviewing for new interviewers (minimum 5 sessions)
|
||||
- Quarterly cross-team calibration reviews
|
||||
- Annual hiring bar review and adjustment process
|
||||
|
||||
**Performance Tracking**
|
||||
- New hire performance correlation with interview scores
|
||||
- Interviewer accuracy tracking (prediction vs actual performance)
|
||||
- False positive/negative analysis
|
||||
- Offer acceptance rate analysis by interviewer
|
||||
|
||||
**Feedback Loops**
|
||||
- Six-month new hire performance reviews
|
||||
- Manager feedback on interview process effectiveness
|
||||
- Candidate experience surveys and feedback integration
|
||||
- Continuous process improvement based on data analysis
|
||||
|
||||
---
|
||||
|
||||
## Competency Frameworks
|
||||
|
||||
### Engineering Competency Levels
|
||||
|
||||
#### Level 1-2: Individual Contributor (Junior/Mid)
|
||||
- **Technical Skills:** Language proficiency, testing basics, code review participation
|
||||
- **Problem Solving:** Structured approach to debugging, logical thinking
|
||||
- **Communication:** Clear status updates, effective question asking
|
||||
- **Learning:** Proactive skill development, mentorship seeking
|
||||
|
||||
#### Level 3-4: Senior Individual Contributor
|
||||
- **Technical Leadership:** Architecture decisions, code quality advocacy
|
||||
- **Mentoring:** Junior developer guidance, knowledge sharing
|
||||
- **Project Ownership:** End-to-end feature delivery, stakeholder communication
|
||||
- **Innovation:** Process improvement, technology evaluation
|
||||
|
||||
#### Level 5-6: Staff+ Engineer
|
||||
- **Organizational Impact:** Cross-team technical leadership, strategic planning
|
||||
- **Technical Vision:** Long-term architectural planning, technology roadmap
|
||||
- **People Development:** Team growth, hiring contribution, culture building
|
||||
- **External Influence:** Industry contribution, thought leadership
|
||||
|
||||
### Product Management Competency Levels
|
||||
|
||||
#### Level 1-2: Associate/Product Manager
|
||||
- **Product Execution:** Feature specification, requirements gathering
|
||||
- **User Focus:** User research participation, feedback collection
|
||||
- **Data Analysis:** Basic metrics analysis, experiment interpretation
|
||||
- **Stakeholder Management:** Cross-functional collaboration, communication
|
||||
|
||||
#### Level 3-4: Senior Product Manager
|
||||
- **Strategic Thinking:** Market analysis, competitive positioning
|
||||
- **Leadership:** Cross-functional team leadership, decision making
|
||||
- **Business Impact:** Revenue impact, market share growth
|
||||
- **Process Innovation:** Product development process improvement
|
||||
|
||||
#### Level 5-6: Principal Product Manager
|
||||
- **Vision Setting:** Product strategy, market direction
|
||||
- **Organizational Influence:** Executive communication, team building
|
||||
- **Innovation Leadership:** New market creation, disruptive thinking
|
||||
- **Talent Development:** PM team growth, hiring leadership
|
||||
|
||||
---
|
||||
|
||||
## Scoring & Calibration
|
||||
|
||||
### Scoring Rubric Framework
|
||||
|
||||
#### 4-Point Scoring Scale
|
||||
- **4 - Exceeds Expectations:** Demonstrates mastery beyond required level
|
||||
- **3 - Meets Expectations:** Solid performance meeting all requirements
|
||||
- **2 - Partially Meets:** Shows potential but has development areas
|
||||
- **1 - Does Not Meet:** Significant gaps in required competencies
|
||||
|
||||
#### Competency-Specific Scoring
|
||||
|
||||
**Technical Competencies**
|
||||
- Code Quality (4): Clean, maintainable, well-tested code with excellent documentation
|
||||
- Code Quality (3): Functional code with good structure and basic testing
|
||||
- Code Quality (2): Working code with some structural issues or missing tests
|
||||
- Code Quality (1): Non-functional or poorly structured code with significant issues
|
||||
|
||||
**Leadership Competencies**
|
||||
- Team Influence (4): Drives team success, develops others, creates lasting positive change
|
||||
- Team Influence (3): Contributes positively to team dynamics and outcomes
|
||||
- Team Influence (2): Shows leadership potential with some effective examples
|
||||
- Team Influence (1): Limited evidence of leadership ability or negative team impact
|
||||
|
||||
### Calibration Standards
|
||||
|
||||
#### Statistical Benchmarks
|
||||
- Target score distribution: 20% (4s), 40% (3s), 30% (2s), 10% (1s)
|
||||
- Interviewer consistency target: <0.5 standard deviation from team average
|
||||
- Pass rate target: 15-25% for most roles (varies by level and market conditions)
|
||||
- Time to hire target: 2-3 weeks from first interview to offer
|
||||
|
||||
#### Quality Metrics
|
||||
- New hire 6-month performance correlation: >0.6 with interview scores
|
||||
- Interviewer agreement rate: >80% within 1 point on final recommendations
|
||||
- Candidate experience satisfaction: >4.0/5.0 average rating
|
||||
- Offer acceptance rate: >85% for preferred candidates
|
||||
|
||||
---
|
||||
|
||||
## Reference Documentation
|
||||
|
||||
### Interview Templates
|
||||
- Role-specific interview guides and question banks
|
||||
- Scorecard templates for consistent evaluation
|
||||
- Debrief facilitation guides for effective team discussions
|
||||
|
||||
### Bias Mitigation Resources
|
||||
- Unconscious bias training materials and exercises
|
||||
- Structured interviewing best practices checklist
|
||||
- Demographic diversity tracking and reporting templates
|
||||
|
||||
### Calibration Tools
|
||||
- Interview performance correlation analysis templates
|
||||
- Interviewer coaching and development frameworks
|
||||
- Hiring pipeline metrics and dashboard specifications
|
||||
|
||||
---
|
||||
|
||||
## Industry Standards
|
||||
|
||||
### Best Practices Integration
|
||||
- Google's structured interviewing methodology
|
||||
- Amazon's Leadership Principles assessment framework
|
||||
- Microsoft's competency-based evaluation system
|
||||
- Netflix's culture fit assessment approach
|
||||
|
||||
### Compliance & Legal Considerations
|
||||
- EEOC compliance requirements and documentation
|
||||
- ADA accommodation procedures and guidelines
|
||||
- International hiring law considerations
|
||||
- Privacy and data protection requirements (GDPR, CCPA)
|
||||
|
||||
### Continuous Improvement Framework
|
||||
- Regular process auditing and refinement cycles
|
||||
- Industry benchmarking and comparative analysis
|
||||
- Technology integration for interview optimization
|
||||
- Candidate experience enhancement initiatives
|
||||
|
||||
This comprehensive interview system design framework provides the structure and tools necessary to build fair, effective, and scalable hiring processes that consistently identify top talent while minimizing bias and maximizing candidate experience.
|
||||
169
docs/skills/engineering/mcp-server-builder.md
Normal file
169
docs/skills/engineering/mcp-server-builder.md
Normal file
@@ -0,0 +1,169 @@
|
||||
---
|
||||
title: "MCP Server Builder"
|
||||
description: "MCP Server Builder - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# MCP Server Builder
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `mcp-server-builder` | **Source:** [`engineering/mcp-server-builder/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/mcp-server-builder/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering
|
||||
**Domain:** AI / API Integration
|
||||
|
||||
## Overview
|
||||
|
||||
Use this skill to design and ship production-ready MCP servers from API contracts instead of hand-written one-off tool wrappers. It focuses on fast scaffolding, schema quality, validation, and safe evolution.
|
||||
|
||||
The workflow supports both Python and TypeScript MCP implementations and treats OpenAPI as the source of truth.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- Convert OpenAPI paths/operations into MCP tool definitions
|
||||
- Generate starter server scaffolds (Python or TypeScript)
|
||||
- Enforce naming, descriptions, and schema consistency
|
||||
- Validate MCP tool manifests for common production failures
|
||||
- Apply versioning and backward-compatibility checks
|
||||
- Separate transport/runtime decisions from tool contract design
|
||||
|
||||
## When to Use
|
||||
|
||||
- You need to expose an internal/external REST API to an LLM agent
|
||||
- You are replacing brittle browser automation with typed tools
|
||||
- You want one MCP server shared across teams and assistants
|
||||
- You need repeatable quality checks before publishing MCP tools
|
||||
- You want to bootstrap an MCP server from existing OpenAPI specs
|
||||
|
||||
## Key Workflows
|
||||
|
||||
### 1. OpenAPI to MCP Scaffold
|
||||
|
||||
1. Start from a valid OpenAPI spec.
|
||||
2. Generate tool manifest + starter server code.
|
||||
3. Review naming and auth strategy.
|
||||
4. Add endpoint-specific runtime logic.
|
||||
|
||||
```bash
|
||||
python3 scripts/openapi_to_mcp.py \
|
||||
--input openapi.json \
|
||||
--server-name billing-mcp \
|
||||
--language python \
|
||||
--output-dir ./out \
|
||||
--format text
|
||||
```
|
||||
|
||||
Supports stdin as well:
|
||||
|
||||
```bash
|
||||
cat openapi.json | python3 scripts/openapi_to_mcp.py --server-name billing-mcp --language typescript
|
||||
```
|
||||
|
||||
### 2. Validate MCP Tool Definitions
|
||||
|
||||
Run validator before integration tests:
|
||||
|
||||
```bash
|
||||
python3 scripts/mcp_validator.py --input out/tool_manifest.json --strict --format text
|
||||
```
|
||||
|
||||
Checks include duplicate names, invalid schema shape, missing descriptions, empty required fields, and naming hygiene.
|
||||
|
||||
### 3. Runtime Selection
|
||||
|
||||
- Choose **Python** for fast iteration and data-heavy backends.
|
||||
- Choose **TypeScript** for unified JS stacks and tighter frontend/backend contract reuse.
|
||||
- Keep tool contracts stable even if transport/runtime changes.
|
||||
|
||||
### 4. Auth & Safety Design
|
||||
|
||||
- Keep secrets in env, not in tool schemas.
|
||||
- Prefer explicit allowlists for outbound hosts.
|
||||
- Return structured errors (`code`, `message`, `details`) for agent recovery.
|
||||
- Avoid destructive operations without explicit confirmation inputs.
|
||||
|
||||
### 5. Versioning Strategy
|
||||
|
||||
- Additive fields only for non-breaking updates.
|
||||
- Never rename tool names in-place.
|
||||
- Introduce new tool IDs for breaking behavior changes.
|
||||
- Maintain changelog of tool contracts per release.
|
||||
|
||||
## Script Interfaces
|
||||
|
||||
- `python3 scripts/openapi_to_mcp.py --help`
|
||||
- Reads OpenAPI from stdin or `--input`
|
||||
- Produces manifest + server scaffold
|
||||
- Emits JSON summary or text report
|
||||
- `python3 scripts/mcp_validator.py --help`
|
||||
- Validates manifests and optional runtime config
|
||||
- Returns non-zero exit in strict mode when errors exist
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
1. Tool names derived directly from raw paths (`get__v1__users___id`)
|
||||
2. Missing operation descriptions (agents choose tools poorly)
|
||||
3. Ambiguous parameter schemas with no required fields
|
||||
4. Mixing transport errors and domain errors in one opaque message
|
||||
5. Building tool contracts that expose secret values
|
||||
6. Breaking clients by changing schema keys without versioning
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. Use `operationId` as canonical tool name when available.
|
||||
2. Keep one task intent per tool; avoid mega-tools.
|
||||
3. Add concise descriptions with action verbs.
|
||||
4. Validate contracts in CI using strict mode.
|
||||
5. Keep generated scaffold committed, then customize incrementally.
|
||||
6. Pair contract changes with changelog entries.
|
||||
|
||||
## Reference Material
|
||||
|
||||
- [references/openapi-extraction-guide.md](references/openapi-extraction-guide.md)
|
||||
- [references/python-server-template.md](references/python-server-template.md)
|
||||
- [references/typescript-server-template.md](references/typescript-server-template.md)
|
||||
- [references/validation-checklist.md](references/validation-checklist.md)
|
||||
- [README.md](README.md)
|
||||
|
||||
## Architecture Decisions
|
||||
|
||||
Choose the server approach per constraint:
|
||||
|
||||
- Python runtime: faster iteration, data pipelines, backend-heavy teams
|
||||
- TypeScript runtime: shared types with JS stack, frontend-heavy teams
|
||||
- Single MCP server: easiest operations, broader blast radius
|
||||
- Split domain servers: cleaner ownership and safer change boundaries
|
||||
|
||||
## Contract Quality Gates
|
||||
|
||||
Before publishing a manifest:
|
||||
|
||||
1. Every tool has clear verb-first name.
|
||||
2. Every tool description explains intent and expected result.
|
||||
3. Every required field is explicitly typed.
|
||||
4. Destructive actions include confirmation parameters.
|
||||
5. Error payload format is consistent across all tools.
|
||||
6. Validator returns zero errors in strict mode.
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
- Unit: validate transformation from OpenAPI operation to MCP tool schema.
|
||||
- Contract: snapshot `tool_manifest.json` and review diffs in PR.
|
||||
- Integration: call generated tool handlers against staging API.
|
||||
- Resilience: simulate 4xx/5xx upstream errors and verify structured responses.
|
||||
|
||||
## Deployment Practices
|
||||
|
||||
- Pin MCP runtime dependencies per environment.
|
||||
- Roll out server updates behind versioned endpoint/process.
|
||||
- Keep backward compatibility for one release window minimum.
|
||||
- Add changelog notes for new/removed/changed tool contracts.
|
||||
|
||||
## Security Controls
|
||||
|
||||
- Keep outbound host allowlist explicit.
|
||||
- Do not proxy arbitrary URLs from user-provided input.
|
||||
- Redact secrets and auth headers from logs.
|
||||
- Rate-limit high-cost tools and add request timeouts.
|
||||
483
docs/skills/engineering/migration-architect.md
Normal file
483
docs/skills/engineering/migration-architect.md
Normal file
@@ -0,0 +1,483 @@
|
||||
---
|
||||
title: "Migration Architect"
|
||||
description: "Migration Architect - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Migration Architect
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `migration-architect` | **Source:** [`engineering/migration-architect/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/migration-architect/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering - Migration Strategy
|
||||
**Purpose:** Zero-downtime migration planning, compatibility validation, and rollback strategy generation
|
||||
|
||||
## Overview
|
||||
|
||||
The Migration Architect skill provides comprehensive tools and methodologies for planning, executing, and validating complex system migrations with minimal business impact. This skill combines proven migration patterns with automated planning tools to ensure successful transitions between systems, databases, and infrastructure.
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
### 1. Migration Strategy Planning
|
||||
- **Phased Migration Planning:** Break complex migrations into manageable phases with clear validation gates
|
||||
- **Risk Assessment:** Identify potential failure points and mitigation strategies before execution
|
||||
- **Timeline Estimation:** Generate realistic timelines based on migration complexity and resource constraints
|
||||
- **Stakeholder Communication:** Create communication templates and progress dashboards
|
||||
|
||||
### 2. Compatibility Analysis
|
||||
- **Schema Evolution:** Analyze database schema changes for backward compatibility issues
|
||||
- **API Versioning:** Detect breaking changes in REST/GraphQL APIs and microservice interfaces
|
||||
- **Data Type Validation:** Identify data format mismatches and conversion requirements
|
||||
- **Constraint Analysis:** Validate referential integrity and business rule changes
|
||||
|
||||
### 3. Rollback Strategy Generation
|
||||
- **Automated Rollback Plans:** Generate comprehensive rollback procedures for each migration phase
|
||||
- **Data Recovery Scripts:** Create point-in-time data restoration procedures
|
||||
- **Service Rollback:** Plan service version rollbacks with traffic management
|
||||
- **Validation Checkpoints:** Define success criteria and rollback triggers
|
||||
|
||||
## Migration Patterns
|
||||
|
||||
### Database Migrations
|
||||
|
||||
#### Schema Evolution Patterns
|
||||
1. **Expand-Contract Pattern**
|
||||
- **Expand:** Add new columns/tables alongside existing schema
|
||||
- **Dual Write:** Application writes to both old and new schema
|
||||
- **Migration:** Backfill historical data to new schema
|
||||
- **Contract:** Remove old columns/tables after validation
|
||||
|
||||
2. **Parallel Schema Pattern**
|
||||
- Run new schema in parallel with existing schema
|
||||
- Use feature flags to route traffic between schemas
|
||||
- Validate data consistency between parallel systems
|
||||
- Cutover when confidence is high
|
||||
|
||||
3. **Event Sourcing Migration**
|
||||
- Capture all changes as events during migration window
|
||||
- Apply events to new schema for consistency
|
||||
- Enable replay capability for rollback scenarios
|
||||
|
||||
#### Data Migration Strategies
|
||||
1. **Bulk Data Migration**
|
||||
- **Snapshot Approach:** Full data copy during maintenance window
|
||||
- **Incremental Sync:** Continuous data synchronization with change tracking
|
||||
- **Stream Processing:** Real-time data transformation pipelines
|
||||
|
||||
2. **Dual-Write Pattern**
|
||||
- Write to both source and target systems during migration
|
||||
- Implement compensation patterns for write failures
|
||||
- Use distributed transactions where consistency is critical
|
||||
|
||||
3. **Change Data Capture (CDC)**
|
||||
- Stream database changes to target system
|
||||
- Maintain eventual consistency during migration
|
||||
- Enable zero-downtime migrations for large datasets
|
||||
|
||||
### Service Migrations
|
||||
|
||||
#### Strangler Fig Pattern
|
||||
1. **Intercept Requests:** Route traffic through proxy/gateway
|
||||
2. **Gradually Replace:** Implement new service functionality incrementally
|
||||
3. **Legacy Retirement:** Remove old service components as new ones prove stable
|
||||
4. **Monitoring:** Track performance and error rates throughout transition
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
A[Client Requests] --> B[API Gateway]
|
||||
B --> C{Route Decision}
|
||||
C -->|Legacy Path| D[Legacy Service]
|
||||
C -->|New Path| E[New Service]
|
||||
D --> F[Legacy Database]
|
||||
E --> G[New Database]
|
||||
```
|
||||
|
||||
#### Parallel Run Pattern
|
||||
1. **Dual Execution:** Run both old and new services simultaneously
|
||||
2. **Shadow Traffic:** Route production traffic to both systems
|
||||
3. **Result Comparison:** Compare outputs to validate correctness
|
||||
4. **Gradual Cutover:** Shift traffic percentage based on confidence
|
||||
|
||||
#### Canary Deployment Pattern
|
||||
1. **Limited Rollout:** Deploy new service to small percentage of users
|
||||
2. **Monitoring:** Track key metrics (latency, errors, business KPIs)
|
||||
3. **Gradual Increase:** Increase traffic percentage as confidence grows
|
||||
4. **Full Rollout:** Complete migration once validation passes
|
||||
|
||||
### Infrastructure Migrations
|
||||
|
||||
#### Cloud-to-Cloud Migration
|
||||
1. **Assessment Phase**
|
||||
- Inventory existing resources and dependencies
|
||||
- Map services to target cloud equivalents
|
||||
- Identify vendor-specific features requiring refactoring
|
||||
|
||||
2. **Pilot Migration**
|
||||
- Migrate non-critical workloads first
|
||||
- Validate performance and cost models
|
||||
- Refine migration procedures
|
||||
|
||||
3. **Production Migration**
|
||||
- Use infrastructure as code for consistency
|
||||
- Implement cross-cloud networking during transition
|
||||
- Maintain disaster recovery capabilities
|
||||
|
||||
#### On-Premises to Cloud Migration
|
||||
1. **Lift and Shift**
|
||||
- Minimal changes to existing applications
|
||||
- Quick migration with optimization later
|
||||
- Use cloud migration tools and services
|
||||
|
||||
2. **Re-architecture**
|
||||
- Redesign applications for cloud-native patterns
|
||||
- Adopt microservices, containers, and serverless
|
||||
- Implement cloud security and scaling practices
|
||||
|
||||
3. **Hybrid Approach**
|
||||
- Keep sensitive data on-premises
|
||||
- Migrate compute workloads to cloud
|
||||
- Implement secure connectivity between environments
|
||||
|
||||
## Feature Flags for Migrations
|
||||
|
||||
### Progressive Feature Rollout
|
||||
```python
|
||||
# Example feature flag implementation
|
||||
class MigrationFeatureFlag:
|
||||
def __init__(self, flag_name, rollout_percentage=0):
|
||||
self.flag_name = flag_name
|
||||
self.rollout_percentage = rollout_percentage
|
||||
|
||||
def is_enabled_for_user(self, user_id):
|
||||
hash_value = hash(f"{self.flag_name}:{user_id}")
|
||||
return (hash_value % 100) < self.rollout_percentage
|
||||
|
||||
def gradual_rollout(self, target_percentage, step_size=10):
|
||||
while self.rollout_percentage < target_percentage:
|
||||
self.rollout_percentage = min(
|
||||
self.rollout_percentage + step_size,
|
||||
target_percentage
|
||||
)
|
||||
yield self.rollout_percentage
|
||||
```
|
||||
|
||||
### Circuit Breaker Pattern
|
||||
Implement automatic fallback to legacy systems when new systems show degraded performance:
|
||||
|
||||
```python
|
||||
class MigrationCircuitBreaker:
|
||||
def __init__(self, failure_threshold=5, timeout=60):
|
||||
self.failure_count = 0
|
||||
self.failure_threshold = failure_threshold
|
||||
self.timeout = timeout
|
||||
self.last_failure_time = None
|
||||
self.state = 'CLOSED' # CLOSED, OPEN, HALF_OPEN
|
||||
|
||||
def call_new_service(self, request):
|
||||
if self.state == 'OPEN':
|
||||
if self.should_attempt_reset():
|
||||
self.state = 'HALF_OPEN'
|
||||
else:
|
||||
return self.fallback_to_legacy(request)
|
||||
|
||||
try:
|
||||
response = self.new_service.process(request)
|
||||
self.on_success()
|
||||
return response
|
||||
except Exception as e:
|
||||
self.on_failure()
|
||||
return self.fallback_to_legacy(request)
|
||||
```
|
||||
|
||||
## Data Validation and Reconciliation
|
||||
|
||||
### Validation Strategies
|
||||
1. **Row Count Validation**
|
||||
- Compare record counts between source and target
|
||||
- Account for soft deletes and filtered records
|
||||
- Implement threshold-based alerting
|
||||
|
||||
2. **Checksums and Hashing**
|
||||
- Generate checksums for critical data subsets
|
||||
- Compare hash values to detect data drift
|
||||
- Use sampling for large datasets
|
||||
|
||||
3. **Business Logic Validation**
|
||||
- Run critical business queries on both systems
|
||||
- Compare aggregate results (sums, counts, averages)
|
||||
- Validate derived data and calculations
|
||||
|
||||
### Reconciliation Patterns
|
||||
1. **Delta Detection**
|
||||
```sql
|
||||
-- Example delta query for reconciliation
|
||||
SELECT 'missing_in_target' as issue_type, source_id
|
||||
FROM source_table s
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM target_table t
|
||||
WHERE t.id = s.id
|
||||
)
|
||||
UNION ALL
|
||||
SELECT 'extra_in_target' as issue_type, target_id
|
||||
FROM target_table t
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM source_table s
|
||||
WHERE s.id = t.id
|
||||
);
|
||||
```
|
||||
|
||||
2. **Automated Correction**
|
||||
- Implement data repair scripts for common issues
|
||||
- Use idempotent operations for safe re-execution
|
||||
- Log all correction actions for audit trails
|
||||
|
||||
## Rollback Strategies
|
||||
|
||||
### Database Rollback
|
||||
1. **Schema Rollback**
|
||||
- Maintain schema version control
|
||||
- Use backward-compatible migrations when possible
|
||||
- Keep rollback scripts for each migration step
|
||||
|
||||
2. **Data Rollback**
|
||||
- Point-in-time recovery using database backups
|
||||
- Transaction log replay for precise rollback points
|
||||
- Maintain data snapshots at migration checkpoints
|
||||
|
||||
### Service Rollback
|
||||
1. **Blue-Green Deployment**
|
||||
- Keep previous service version running during migration
|
||||
- Switch traffic back to blue environment if issues arise
|
||||
- Maintain parallel infrastructure during migration window
|
||||
|
||||
2. **Rolling Rollback**
|
||||
- Gradually shift traffic back to previous version
|
||||
- Monitor system health during rollback process
|
||||
- Implement automated rollback triggers
|
||||
|
||||
### Infrastructure Rollback
|
||||
1. **Infrastructure as Code**
|
||||
- Version control all infrastructure definitions
|
||||
- Maintain rollback terraform/CloudFormation templates
|
||||
- Test rollback procedures in staging environments
|
||||
|
||||
2. **Data Persistence**
|
||||
- Preserve data in original location during migration
|
||||
- Implement data sync back to original systems
|
||||
- Maintain backup strategies across both environments
|
||||
|
||||
## Risk Assessment Framework
|
||||
|
||||
### Risk Categories
|
||||
1. **Technical Risks**
|
||||
- Data loss or corruption
|
||||
- Service downtime or degraded performance
|
||||
- Integration failures with dependent systems
|
||||
- Scalability issues under production load
|
||||
|
||||
2. **Business Risks**
|
||||
- Revenue impact from service disruption
|
||||
- Customer experience degradation
|
||||
- Compliance and regulatory concerns
|
||||
- Brand reputation impact
|
||||
|
||||
3. **Operational Risks**
|
||||
- Team knowledge gaps
|
||||
- Insufficient testing coverage
|
||||
- Inadequate monitoring and alerting
|
||||
- Communication breakdowns
|
||||
|
||||
### Risk Mitigation Strategies
|
||||
1. **Technical Mitigations**
|
||||
- Comprehensive testing (unit, integration, load, chaos)
|
||||
- Gradual rollout with automated rollback triggers
|
||||
- Data validation and reconciliation processes
|
||||
- Performance monitoring and alerting
|
||||
|
||||
2. **Business Mitigations**
|
||||
- Stakeholder communication plans
|
||||
- Business continuity procedures
|
||||
- Customer notification strategies
|
||||
- Revenue protection measures
|
||||
|
||||
3. **Operational Mitigations**
|
||||
- Team training and documentation
|
||||
- Runbook creation and testing
|
||||
- On-call rotation planning
|
||||
- Post-migration review processes
|
||||
|
||||
## Migration Runbooks
|
||||
|
||||
### Pre-Migration Checklist
|
||||
- [ ] Migration plan reviewed and approved
|
||||
- [ ] Rollback procedures tested and validated
|
||||
- [ ] Monitoring and alerting configured
|
||||
- [ ] Team roles and responsibilities defined
|
||||
- [ ] Stakeholder communication plan activated
|
||||
- [ ] Backup and recovery procedures verified
|
||||
- [ ] Test environment validation complete
|
||||
- [ ] Performance benchmarks established
|
||||
- [ ] Security review completed
|
||||
- [ ] Compliance requirements verified
|
||||
|
||||
### During Migration
|
||||
- [ ] Execute migration phases in planned order
|
||||
- [ ] Monitor key performance indicators continuously
|
||||
- [ ] Validate data consistency at each checkpoint
|
||||
- [ ] Communicate progress to stakeholders
|
||||
- [ ] Document any deviations from plan
|
||||
- [ ] Execute rollback if success criteria not met
|
||||
- [ ] Coordinate with dependent teams
|
||||
- [ ] Maintain detailed execution logs
|
||||
|
||||
### Post-Migration
|
||||
- [ ] Validate all success criteria met
|
||||
- [ ] Perform comprehensive system health checks
|
||||
- [ ] Execute data reconciliation procedures
|
||||
- [ ] Monitor system performance over 72 hours
|
||||
- [ ] Update documentation and runbooks
|
||||
- [ ] Decommission legacy systems (if applicable)
|
||||
- [ ] Conduct post-migration retrospective
|
||||
- [ ] Archive migration artifacts
|
||||
- [ ] Update disaster recovery procedures
|
||||
|
||||
## Communication Templates
|
||||
|
||||
### Executive Summary Template
|
||||
```
|
||||
Migration Status: [IN_PROGRESS | COMPLETED | ROLLED_BACK]
|
||||
Start Time: [YYYY-MM-DD HH:MM UTC]
|
||||
Current Phase: [X of Y]
|
||||
Overall Progress: [X%]
|
||||
|
||||
Key Metrics:
|
||||
- System Availability: [X.XX%]
|
||||
- Data Migration Progress: [X.XX%]
|
||||
- Performance Impact: [+/-X%]
|
||||
- Issues Encountered: [X]
|
||||
|
||||
Next Steps:
|
||||
1. [Action item 1]
|
||||
2. [Action item 2]
|
||||
|
||||
Risk Assessment: [LOW | MEDIUM | HIGH]
|
||||
Rollback Status: [AVAILABLE | NOT_AVAILABLE]
|
||||
```
|
||||
|
||||
### Technical Team Update Template
|
||||
```
|
||||
Phase: [Phase Name] - [Status]
|
||||
Duration: [Started] - [Expected End]
|
||||
|
||||
Completed Tasks:
|
||||
✓ [Task 1]
|
||||
✓ [Task 2]
|
||||
|
||||
In Progress:
|
||||
🔄 [Task 3] - [X% complete]
|
||||
|
||||
Upcoming:
|
||||
⏳ [Task 4] - [Expected start time]
|
||||
|
||||
Issues:
|
||||
⚠️ [Issue description] - [Severity] - [ETA resolution]
|
||||
|
||||
Metrics:
|
||||
- Migration Rate: [X records/minute]
|
||||
- Error Rate: [X.XX%]
|
||||
- System Load: [CPU/Memory/Disk]
|
||||
```
|
||||
|
||||
## Success Metrics
|
||||
|
||||
### Technical Metrics
|
||||
- **Migration Completion Rate:** Percentage of data/services successfully migrated
|
||||
- **Downtime Duration:** Total system unavailability during migration
|
||||
- **Data Consistency Score:** Percentage of data validation checks passing
|
||||
- **Performance Delta:** Performance change compared to baseline
|
||||
- **Error Rate:** Percentage of failed operations during migration
|
||||
|
||||
### Business Metrics
|
||||
- **Customer Impact Score:** Measure of customer experience degradation
|
||||
- **Revenue Protection:** Percentage of revenue maintained during migration
|
||||
- **Time to Value:** Duration from migration start to business value realization
|
||||
- **Stakeholder Satisfaction:** Post-migration stakeholder feedback scores
|
||||
|
||||
### Operational Metrics
|
||||
- **Plan Adherence:** Percentage of migration executed according to plan
|
||||
- **Issue Resolution Time:** Average time to resolve migration issues
|
||||
- **Team Efficiency:** Resource utilization and productivity metrics
|
||||
- **Knowledge Transfer Score:** Team readiness for post-migration operations
|
||||
|
||||
## Tools and Technologies
|
||||
|
||||
### Migration Planning Tools
|
||||
- **migration_planner.py:** Automated migration plan generation
|
||||
- **compatibility_checker.py:** Schema and API compatibility analysis
|
||||
- **rollback_generator.py:** Comprehensive rollback procedure generation
|
||||
|
||||
### Validation Tools
|
||||
- Database comparison utilities (schema and data)
|
||||
- API contract testing frameworks
|
||||
- Performance benchmarking tools
|
||||
- Data quality validation pipelines
|
||||
|
||||
### Monitoring and Alerting
|
||||
- Real-time migration progress dashboards
|
||||
- Automated rollback trigger systems
|
||||
- Business metric monitoring
|
||||
- Stakeholder notification systems
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Planning Phase
|
||||
1. **Start with Risk Assessment:** Identify all potential failure modes before planning
|
||||
2. **Design for Rollback:** Every migration step should have a tested rollback procedure
|
||||
3. **Validate in Staging:** Execute full migration process in production-like environment
|
||||
4. **Plan for Gradual Rollout:** Use feature flags and traffic routing for controlled migration
|
||||
|
||||
### Execution Phase
|
||||
1. **Monitor Continuously:** Track both technical and business metrics throughout
|
||||
2. **Communicate Proactively:** Keep all stakeholders informed of progress and issues
|
||||
3. **Document Everything:** Maintain detailed logs for post-migration analysis
|
||||
4. **Stay Flexible:** Be prepared to adjust timeline based on real-world performance
|
||||
|
||||
### Validation Phase
|
||||
1. **Automate Validation:** Use automated tools for data consistency and performance checks
|
||||
2. **Business Logic Testing:** Validate critical business processes end-to-end
|
||||
3. **Load Testing:** Verify system performance under expected production load
|
||||
4. **Security Validation:** Ensure security controls function properly in new environment
|
||||
|
||||
## Integration with Development Lifecycle
|
||||
|
||||
### CI/CD Integration
|
||||
```yaml
|
||||
# Example migration pipeline stage
|
||||
migration_validation:
|
||||
stage: test
|
||||
script:
|
||||
- python scripts/compatibility_checker.py --before=old_schema.json --after=new_schema.json
|
||||
- python scripts/migration_planner.py --config=migration_config.json --validate
|
||||
artifacts:
|
||||
reports:
|
||||
- compatibility_report.json
|
||||
- migration_plan.json
|
||||
```
|
||||
|
||||
### Infrastructure as Code
|
||||
```terraform
|
||||
# Example Terraform for blue-green infrastructure
|
||||
resource "aws_instance" "blue_environment" {
|
||||
count = var.migration_phase == "preparation" ? var.instance_count : 0
|
||||
# Blue environment configuration
|
||||
}
|
||||
|
||||
resource "aws_instance" "green_environment" {
|
||||
count = var.migration_phase == "execution" ? var.instance_count : 0
|
||||
# Green environment configuration
|
||||
}
|
||||
```
|
||||
|
||||
This Migration Architect skill provides a comprehensive framework for planning, executing, and validating complex system migrations while minimizing business impact and technical risk. The combination of automated tools, proven patterns, and detailed procedures enables organizations to confidently undertake even the most complex migration projects.
|
||||
605
docs/skills/engineering/monorepo-navigator.md
Normal file
605
docs/skills/engineering/monorepo-navigator.md
Normal file
@@ -0,0 +1,605 @@
|
||||
---
|
||||
title: "Monorepo Navigator"
|
||||
description: "Monorepo Navigator - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Monorepo Navigator
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `monorepo-navigator` | **Source:** [`engineering/monorepo-navigator/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/monorepo-navigator/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Tier:** POWERFUL
|
||||
**Category:** Engineering
|
||||
**Domain:** Monorepo Architecture / Build Systems
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Navigate, manage, and optimize monorepos. Covers Turborepo, Nx, pnpm workspaces, and Lerna. Enables cross-package impact analysis, selective builds/tests on affected packages only, remote caching, dependency graph visualization, and structured migrations from multi-repo to monorepo. Includes Claude Code configuration for workspace-aware development.
|
||||
|
||||
---
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
- **Cross-package impact analysis** — determine which apps break when a shared package changes
|
||||
- **Selective commands** — run tests/builds only for affected packages (not everything)
|
||||
- **Dependency graph** — visualize package relationships as Mermaid diagrams
|
||||
- **Build optimization** — remote caching, incremental builds, parallel execution
|
||||
- **Migration** — step-by-step multi-repo → monorepo with zero history loss
|
||||
- **Publishing** — changesets for versioning, pre-release channels, npm publish workflows
|
||||
- **Claude Code config** — workspace-aware CLAUDE.md with per-package instructions
|
||||
|
||||
---
|
||||
|
||||
## When to Use
|
||||
|
||||
Use when:
|
||||
- Multiple packages/apps share code (UI components, utils, types, API clients)
|
||||
- Build times are slow because everything rebuilds when anything changes
|
||||
- Migrating from multiple repos to a single repo
|
||||
- Need to publish packages to npm with coordinated versioning
|
||||
- Teams work across multiple packages and need unified tooling
|
||||
|
||||
Skip when:
|
||||
- Single-app project with no shared packages
|
||||
- Team/project boundaries are completely isolated (polyrepo is fine)
|
||||
- Shared code is minimal and copy-paste overhead is acceptable
|
||||
|
||||
---
|
||||
|
||||
## Tool Selection
|
||||
|
||||
| Tool | Best For | Key Feature |
|
||||
|---|---|---|
|
||||
| **Turborepo** | JS/TS monorepos, simple pipeline config | Best-in-class remote caching, minimal config |
|
||||
| **Nx** | Large enterprises, plugin ecosystem | Project graph, code generation, affected commands |
|
||||
| **pnpm workspaces** | Workspace protocol, disk efficiency | `workspace:*` for local package refs |
|
||||
| **Lerna** | npm publishing, versioning | Batch publishing, conventional commits |
|
||||
| **Changesets** | Modern versioning (preferred over Lerna) | Changelog generation, pre-release channels |
|
||||
|
||||
Most modern setups: **pnpm workspaces + Turborepo + Changesets**
|
||||
|
||||
---
|
||||
|
||||
## Turborepo
|
||||
|
||||
### turbo.json pipeline config
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "https://turbo.build/schema.json",
|
||||
"globalEnv": ["NODE_ENV", "DATABASE_URL"],
|
||||
"pipeline": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"], // build deps first (topological order)
|
||||
"outputs": [".next/**", "dist/**", "build/**"],
|
||||
"env": ["NEXT_PUBLIC_API_URL"]
|
||||
},
|
||||
"test": {
|
||||
"dependsOn": ["^build"], // need built deps to test
|
||||
"outputs": ["coverage/**"],
|
||||
"cache": true
|
||||
},
|
||||
"lint": {
|
||||
"outputs": [],
|
||||
"cache": true
|
||||
},
|
||||
"dev": {
|
||||
"cache": false, // never cache dev servers
|
||||
"persistent": true // long-running process
|
||||
},
|
||||
"type-check": {
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": []
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Key commands
|
||||
|
||||
```bash
|
||||
# Build everything (respects dependency order)
|
||||
turbo run build
|
||||
|
||||
# Build only affected packages (requires --filter)
|
||||
turbo run build --filter=...[HEAD^1] # changed since last commit
|
||||
turbo run build --filter=...[main] # changed vs main branch
|
||||
|
||||
# Test only affected
|
||||
turbo run test --filter=...[HEAD^1]
|
||||
|
||||
# Run for a specific app and all its dependencies
|
||||
turbo run build --filter=@myorg/web...
|
||||
|
||||
# Run for a specific package only (no dependencies)
|
||||
turbo run build --filter=@myorg/ui
|
||||
|
||||
# Dry-run — see what would run without executing
|
||||
turbo run build --dry-run
|
||||
|
||||
# Enable remote caching (Vercel Remote Cache)
|
||||
turbo login
|
||||
turbo link
|
||||
```
|
||||
|
||||
### Remote caching setup
|
||||
|
||||
```bash
|
||||
# .turbo/config.json (auto-created by turbo link)
|
||||
{
|
||||
"teamid": "team_xxxx",
|
||||
"apiurl": "https://vercel.com"
|
||||
}
|
||||
|
||||
# Self-hosted cache server (open-source alternative)
|
||||
# Run ducktape/turborepo-remote-cache or Turborepo's official server
|
||||
TURBO_API=http://your-cache-server.internal \
|
||||
TURBO_TOKEN=your-token \
|
||||
TURBO_TEAM=your-team \
|
||||
turbo run build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Nx
|
||||
|
||||
### Project graph and affected commands
|
||||
|
||||
```bash
|
||||
# Install
|
||||
npx create-nx-workspace@latest my-monorepo
|
||||
|
||||
# Visualize the project graph (opens browser)
|
||||
nx graph
|
||||
|
||||
# Show affected packages for the current branch
|
||||
nx affected:graph
|
||||
|
||||
# Run only affected tests
|
||||
nx affected --target=test
|
||||
|
||||
# Run only affected builds
|
||||
nx affected --target=build
|
||||
|
||||
# Run affected with base/head (for CI)
|
||||
nx affected --target=test --base=main --head=HEAD
|
||||
```
|
||||
|
||||
### nx.json configuration
|
||||
|
||||
```json
|
||||
{
|
||||
"$schema": "./node_modules/nx/schemas/nx-schema.json",
|
||||
"targetDefaults": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"cache": true
|
||||
},
|
||||
"test": {
|
||||
"cache": true,
|
||||
"inputs": ["default", "^production"]
|
||||
}
|
||||
},
|
||||
"namedInputs": {
|
||||
"default": ["{projectRoot}/**/*", "sharedGlobals"],
|
||||
"production": ["default", "!{projectRoot}/**/*.spec.ts", "!{projectRoot}/jest.config.*"],
|
||||
"sharedGlobals": []
|
||||
},
|
||||
"parallel": 4,
|
||||
"cacheDirectory": "/tmp/nx-cache"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## pnpm Workspaces
|
||||
|
||||
### pnpm-workspace.yaml
|
||||
|
||||
```yaml
|
||||
packages:
|
||||
- 'apps/*'
|
||||
- 'packages/*'
|
||||
- 'tools/*'
|
||||
```
|
||||
|
||||
### workspace:* protocol for local packages
|
||||
|
||||
```json
|
||||
// apps/web/package.json
|
||||
{
|
||||
"name": "@myorg/web",
|
||||
"dependencies": {
|
||||
"@myorg/ui": "workspace:*", // always use local version
|
||||
"@myorg/utils": "workspace:^", // local, but respect semver on publish
|
||||
"@myorg/types": "workspace:~"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Useful pnpm workspace commands
|
||||
|
||||
```bash
|
||||
# Install all packages across workspace
|
||||
pnpm install
|
||||
|
||||
# Run script in a specific package
|
||||
pnpm --filter @myorg/web dev
|
||||
|
||||
# Run script in all packages
|
||||
pnpm --filter "*" build
|
||||
|
||||
# Run script in a package and all its dependencies
|
||||
pnpm --filter @myorg/web... build
|
||||
|
||||
# Add a dependency to a specific package
|
||||
pnpm --filter @myorg/web add react
|
||||
|
||||
# Add a shared dev dependency to root
|
||||
pnpm add -D typescript -w
|
||||
|
||||
# List workspace packages
|
||||
pnpm ls --depth -1 -r
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cross-Package Impact Analysis
|
||||
|
||||
When a shared package changes, determine what's affected before you ship.
|
||||
|
||||
```bash
|
||||
# Using Turborepo — show affected packages
|
||||
turbo run build --filter=...[HEAD^1] --dry-run 2>&1 | grep "Tasks to run"
|
||||
|
||||
# Using Nx
|
||||
nx affected:apps --base=main --head=HEAD # which apps are affected
|
||||
nx affected:libs --base=main --head=HEAD # which libs are affected
|
||||
|
||||
# Manual analysis with pnpm
|
||||
# Find all packages that depend on @myorg/utils:
|
||||
grep -r '"@myorg/utils"' packages/*/package.json apps/*/package.json
|
||||
|
||||
# Using jq for structured output
|
||||
for pkg in packages/*/package.json apps/*/package.json; do
|
||||
name=$(jq -r '.name' "$pkg")
|
||||
if jq -e '.dependencies["@myorg/utils"] // .devDependencies["@myorg/utils"]' "$pkg" > /dev/null 2>&1; then
|
||||
echo "$name depends on @myorg/utils"
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Dependency Graph Visualization
|
||||
|
||||
Generate a Mermaid diagram from your workspace:
|
||||
|
||||
```bash
|
||||
# Generate dependency graph as Mermaid
|
||||
cat > scripts/gen-dep-graph.js << 'EOF'
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
|
||||
// Parse pnpm workspace packages
|
||||
const packages = JSON.parse(
|
||||
execSync('pnpm ls --depth -1 -r --json').toString()
|
||||
);
|
||||
|
||||
let mermaid = 'graph TD\n';
|
||||
packages.forEach(pkg => {
|
||||
const deps = Object.keys(pkg.dependencies || {})
|
||||
.filter(d => d.startsWith('@myorg/'));
|
||||
deps.forEach(dep => {
|
||||
const from = pkg.name.replace('@myorg/', '');
|
||||
const to = dep.replace('@myorg/', '');
|
||||
mermaid += ` ${from} --> ${to}\n`;
|
||||
});
|
||||
});
|
||||
|
||||
fs.writeFileSync('docs/dep-graph.md', '```mermaid\n' + mermaid + '```\n');
|
||||
console.log('Written to docs/dep-graph.md');
|
||||
EOF
|
||||
node scripts/gen-dep-graph.js
|
||||
```
|
||||
|
||||
**Example output:**
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
web --> ui
|
||||
web --> utils
|
||||
web --> types
|
||||
mobile --> ui
|
||||
mobile --> utils
|
||||
mobile --> types
|
||||
admin --> ui
|
||||
admin --> utils
|
||||
api --> types
|
||||
ui --> utils
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Claude Code Configuration (Workspace-Aware CLAUDE.md)
|
||||
|
||||
Place a root CLAUDE.md + per-package CLAUDE.md files:
|
||||
|
||||
```markdown
|
||||
# /CLAUDE.md — Root (applies to all packages)
|
||||
|
||||
## Monorepo Structure
|
||||
- apps/web — Next.js customer-facing app
|
||||
- apps/admin — Next.js internal admin
|
||||
- apps/api — Express REST API
|
||||
- packages/ui — Shared React component library
|
||||
- packages/utils — Shared utilities (pure functions only)
|
||||
- packages/types — Shared TypeScript types (no runtime code)
|
||||
|
||||
## Build System
|
||||
- pnpm workspaces + Turborepo
|
||||
- Always use `pnpm --filter <package>` to scope commands
|
||||
- Never run `npm install` or `yarn` — pnpm only
|
||||
- Run `turbo run build --filter=...[HEAD^1]` before committing
|
||||
|
||||
## Task Scoping Rules
|
||||
- When modifying packages/ui: also run tests for apps/web and apps/admin (they depend on it)
|
||||
- When modifying packages/types: run type-check across ALL packages
|
||||
- When modifying apps/api: only need to test apps/api
|
||||
|
||||
## Package Manager
|
||||
pnpm — version pinned in packageManager field of root package.json
|
||||
```
|
||||
|
||||
```markdown
|
||||
# /packages/ui/CLAUDE.md — Package-specific
|
||||
|
||||
## This Package
|
||||
Shared React component library. Zero business logic. Pure UI only.
|
||||
|
||||
## Rules
|
||||
- All components must be exported from src/index.ts
|
||||
- No direct API calls in components — accept data via props
|
||||
- Every component needs a Storybook story in src/stories/
|
||||
- Use Tailwind for styling — no CSS modules or styled-components
|
||||
|
||||
## Testing
|
||||
- Component tests: `pnpm --filter @myorg/ui test`
|
||||
- Visual regression: `pnpm --filter @myorg/ui test:storybook`
|
||||
|
||||
## Publishing
|
||||
- Version bumps via changesets only — never edit package.json version manually
|
||||
- Run `pnpm changeset` from repo root after changes
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Migration: Multi-Repo → Monorepo
|
||||
|
||||
```bash
|
||||
# Step 1: Create monorepo scaffold
|
||||
mkdir my-monorepo && cd my-monorepo
|
||||
pnpm init
|
||||
echo "packages:\n - 'apps/*'\n - 'packages/*'" > pnpm-workspace.yaml
|
||||
|
||||
# Step 2: Move repos with git history preserved
|
||||
mkdir -p apps packages
|
||||
|
||||
# For each existing repo:
|
||||
git clone https://github.com/myorg/web-app
|
||||
cd web-app
|
||||
git filter-repo --to-subdirectory-filter apps/web # rewrites history into subdir
|
||||
cd ..
|
||||
git remote add web-app ./web-app
|
||||
git fetch web-app --tags
|
||||
git merge web-app/main --allow-unrelated-histories
|
||||
|
||||
# Step 3: Update package names to scoped
|
||||
# In each package.json, change "name": "web" to "name": "@myorg/web"
|
||||
|
||||
# Step 4: Replace cross-repo npm deps with workspace:*
|
||||
# apps/web/package.json: "@myorg/ui": "1.2.3" → "@myorg/ui": "workspace:*"
|
||||
|
||||
# Step 5: Add shared configs to root
|
||||
cp apps/web/.eslintrc.js .eslintrc.base.js
|
||||
# Update each package's config to extend root:
|
||||
# { "extends": ["../../.eslintrc.base.js"] }
|
||||
|
||||
# Step 6: Add Turborepo
|
||||
pnpm add -D turbo -w
|
||||
# Create turbo.json (see above)
|
||||
|
||||
# Step 7: Unified CI (see CI section below)
|
||||
# Step 8: Test everything
|
||||
turbo run build test lint
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## CI Patterns
|
||||
|
||||
### GitHub Actions — Affected Only
|
||||
|
||||
```yaml
|
||||
# .github/workflows/ci.yml
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
affected:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # full history needed for affected detection
|
||||
|
||||
- uses: pnpm/action-setup@v3
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: pnpm
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
|
||||
# Turborepo remote cache
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: .turbo
|
||||
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
||||
restore-keys: ${{ runner.os }}-turbo-
|
||||
|
||||
# Only test/build affected packages
|
||||
- name: Build affected
|
||||
run: turbo run build --filter=...[origin/main]
|
||||
env:
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
||||
|
||||
- name: Test affected
|
||||
run: turbo run test --filter=...[origin/main]
|
||||
|
||||
- name: Lint affected
|
||||
run: turbo run lint --filter=...[origin/main]
|
||||
```
|
||||
|
||||
### GitLab CI — Parallel Stages
|
||||
|
||||
```yaml
|
||||
# .gitlab-ci.yml
|
||||
stages: [install, build, test, publish]
|
||||
|
||||
variables:
|
||||
PNPM_CACHE_FOLDER: .pnpm-store
|
||||
|
||||
cache:
|
||||
key: pnpm-$CI_COMMIT_REF_SLUG
|
||||
paths: [.pnpm-store/, .turbo/]
|
||||
|
||||
install:
|
||||
stage: install
|
||||
script:
|
||||
- pnpm install --frozen-lockfile
|
||||
artifacts:
|
||||
paths: [node_modules/, packages/*/node_modules/, apps/*/node_modules/]
|
||||
expire_in: 1h
|
||||
|
||||
build:affected:
|
||||
stage: build
|
||||
needs: [install]
|
||||
script:
|
||||
- turbo run build --filter=...[origin/main]
|
||||
artifacts:
|
||||
paths: [apps/*/dist/, apps/*/.next/, packages/*/dist/]
|
||||
|
||||
test:affected:
|
||||
stage: test
|
||||
needs: [build:affected]
|
||||
script:
|
||||
- turbo run test --filter=...[origin/main]
|
||||
coverage: '/Statements\s*:\s*(\d+\.?\d*)%/'
|
||||
artifacts:
|
||||
reports:
|
||||
coverage_report:
|
||||
coverage_format: cobertura
|
||||
path: "**/coverage/cobertura-coverage.xml"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Publishing with Changesets
|
||||
|
||||
```bash
|
||||
# Install changesets
|
||||
pnpm add -D @changesets/cli -w
|
||||
pnpm changeset init
|
||||
|
||||
# After making changes, create a changeset
|
||||
pnpm changeset
|
||||
# Interactive: select packages, choose semver bump, write changelog entry
|
||||
|
||||
# In CI — version packages + update changelogs
|
||||
pnpm changeset version
|
||||
|
||||
# Publish all changed packages
|
||||
pnpm changeset publish
|
||||
|
||||
# Pre-release channel (for alpha/beta)
|
||||
pnpm changeset pre enter beta
|
||||
pnpm changeset
|
||||
pnpm changeset version # produces 1.2.0-beta.0
|
||||
pnpm changeset publish --tag beta
|
||||
pnpm changeset pre exit # back to stable releases
|
||||
```
|
||||
|
||||
### Automated publish workflow (GitHub Actions)
|
||||
|
||||
```yaml
|
||||
# .github/workflows/release.yml
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: pnpm/action-setup@v3
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
registry-url: https://registry.npmjs.org
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Create Release PR or Publish
|
||||
uses: changesets/action@v1
|
||||
with:
|
||||
publish: pnpm changeset publish
|
||||
version: pnpm changeset version
|
||||
commit: "chore: release packages"
|
||||
title: "chore: release packages"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Common Pitfalls
|
||||
|
||||
| Pitfall | Fix |
|
||||
|---|---|
|
||||
| Running `turbo run build` without `--filter` on every PR | Always use `--filter=...[origin/main]` in CI |
|
||||
| `workspace:*` refs cause publish failures | Use `pnpm changeset publish` — it replaces `workspace:*` with real versions automatically |
|
||||
| All packages rebuild when unrelated file changes | Tune `inputs` in turbo.json to exclude docs, config files from cache keys |
|
||||
| Shared tsconfig causes one package to break all type-checks | Use `extends` properly — each package extends root but overrides `rootDir` / `outDir` |
|
||||
| git history lost during migration | Use `git filter-repo --to-subdirectory-filter` before merging — never move files manually |
|
||||
| Remote cache not working in CI | Check TURBO_TOKEN and TURBO_TEAM env vars; verify with `turbo run build --summarize` |
|
||||
| CLAUDE.md too generic — Claude modifies wrong package | Add explicit "When working on X, only touch files in apps/X" rules per package CLAUDE.md |
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Root CLAUDE.md defines the map** — document every package, its purpose, and dependency rules
|
||||
2. **Per-package CLAUDE.md defines the rules** — what's allowed, what's forbidden, testing commands
|
||||
3. **Always scope commands with --filter** — running everything on every change defeats the purpose
|
||||
4. **Remote cache is not optional** — without it, monorepo CI is slower than multi-repo CI
|
||||
5. **Changesets over manual versioning** — never hand-edit package.json versions in a monorepo
|
||||
6. **Shared configs in root, extended in packages** — tsconfig.base.json, .eslintrc.base.js, jest.base.config.js
|
||||
7. **Impact analysis before merging shared package changes** — run affected check, communicate blast radius
|
||||
8. **Keep packages/types as pure TypeScript** — no runtime code, no dependencies, fast to build and type-check
|
||||
274
docs/skills/engineering/observability-designer.md
Normal file
274
docs/skills/engineering/observability-designer.md
Normal file
@@ -0,0 +1,274 @@
|
||||
---
|
||||
title: "Observability Designer (POWERFUL)"
|
||||
description: "Observability Designer (POWERFUL) - Claude Code skill from the Engineering - POWERFUL domain."
|
||||
---
|
||||
|
||||
# Observability Designer (POWERFUL)
|
||||
|
||||
**Domain:** Engineering - POWERFUL | **Skill:** `observability-designer` | **Source:** [`engineering/observability-designer/SKILL.md`](https://github.com/alirezarezvani/claude-skills/tree/main/engineering/observability-designer/SKILL.md)
|
||||
|
||||
---
|
||||
|
||||
|
||||
**Category:** Engineering
|
||||
**Tier:** POWERFUL
|
||||
**Description:** Design comprehensive observability strategies for production systems including SLI/SLO frameworks, alerting optimization, and dashboard generation.
|
||||
|
||||
## Overview
|
||||
|
||||
Observability Designer enables you to create production-ready observability strategies that provide deep insights into system behavior, performance, and reliability. This skill combines the three pillars of observability (metrics, logs, traces) with proven frameworks like SLI/SLO design, golden signals monitoring, and alert optimization to create comprehensive observability solutions.
|
||||
|
||||
## Core Competencies
|
||||
|
||||
### SLI/SLO/SLA Framework Design
|
||||
- **Service Level Indicators (SLI):** Define measurable signals that indicate service health
|
||||
- **Service Level Objectives (SLO):** Set reliability targets based on user experience
|
||||
- **Service Level Agreements (SLA):** Establish customer-facing commitments with consequences
|
||||
- **Error Budget Management:** Calculate and track error budget consumption
|
||||
- **Burn Rate Alerting:** Multi-window burn rate alerts for proactive SLO protection
|
||||
|
||||
### Three Pillars of Observability
|
||||
|
||||
#### Metrics
|
||||
- **Golden Signals:** Latency, traffic, errors, and saturation monitoring
|
||||
- **RED Method:** Rate, Errors, and Duration for request-driven services
|
||||
- **USE Method:** Utilization, Saturation, and Errors for resource monitoring
|
||||
- **Business Metrics:** Revenue, user engagement, and feature adoption tracking
|
||||
- **Infrastructure Metrics:** CPU, memory, disk, network, and custom resource metrics
|
||||
|
||||
#### Logs
|
||||
- **Structured Logging:** JSON-based log formats with consistent fields
|
||||
- **Log Aggregation:** Centralized log collection and indexing strategies
|
||||
- **Log Levels:** Appropriate use of DEBUG, INFO, WARN, ERROR, FATAL levels
|
||||
- **Correlation IDs:** Request tracing through distributed systems
|
||||
- **Log Sampling:** Volume management for high-throughput systems
|
||||
|
||||
#### Traces
|
||||
- **Distributed Tracing:** End-to-end request flow visualization
|
||||
- **Span Design:** Meaningful span boundaries and metadata
|
||||
- **Trace Sampling:** Intelligent sampling strategies for performance and cost
|
||||
- **Service Maps:** Automatic dependency discovery through traces
|
||||
- **Root Cause Analysis:** Trace-driven debugging workflows
|
||||
|
||||
### Dashboard Design Principles
|
||||
|
||||
#### Information Architecture
|
||||
- **Hierarchy:** Overview → Service → Component → Instance drill-down paths
|
||||
- **Golden Ratio:** 80% operational metrics, 20% exploratory metrics
|
||||
- **Cognitive Load:** Maximum 7±2 panels per dashboard screen
|
||||
- **User Journey:** Role-based dashboard personas (SRE, Developer, Executive)
|
||||
|
||||
#### Visualization Best Practices
|
||||
- **Chart Selection:** Time series for trends, heatmaps for distributions, gauges for status
|
||||
- **Color Theory:** Red for critical, amber for warning, green for healthy states
|
||||
- **Reference Lines:** SLO targets, capacity thresholds, and historical baselines
|
||||
- **Time Ranges:** Default to meaningful windows (4h for incidents, 7d for trends)
|
||||
|
||||
#### Panel Design
|
||||
- **Metric Queries:** Efficient Prometheus/InfluxDB queries with proper aggregation
|
||||
- **Alerting Integration:** Visual alert state indicators on relevant panels
|
||||
- **Interactive Elements:** Template variables, drill-down links, and annotation overlays
|
||||
- **Performance:** Sub-second render times through query optimization
|
||||
|
||||
### Alert Design and Optimization
|
||||
|
||||
#### Alert Classification
|
||||
- **Severity Levels:**
|
||||
- **Critical:** Service down, SLO burn rate high
|
||||
- **Warning:** Approaching thresholds, non-user-facing issues
|
||||
- **Info:** Deployment notifications, capacity planning alerts
|
||||
- **Actionability:** Every alert must have a clear response action
|
||||
- **Alert Routing:** Escalation policies based on severity and team ownership
|
||||
|
||||
#### Alert Fatigue Prevention
|
||||
- **Signal vs Noise:** High precision (few false positives) over high recall
|
||||
- **Hysteresis:** Different thresholds for firing and resolving alerts
|
||||
- **Suppression:** Dependent alert suppression during known outages
|
||||
- **Grouping:** Related alerts grouped into single notifications
|
||||
|
||||
#### Alert Rule Design
|
||||
- **Threshold Selection:** Statistical methods for threshold determination
|
||||
- **Window Functions:** Appropriate averaging windows and percentile calculations
|
||||
- **Alert Lifecycle:** Clear firing conditions and automatic resolution criteria
|
||||
- **Testing:** Alert rule validation against historical data
|
||||
|
||||
### Runbook Generation and Incident Response
|
||||
|
||||
#### Runbook Structure
|
||||
- **Alert Context:** What the alert means and why it fired
|
||||
- **Impact Assessment:** User-facing vs internal impact evaluation
|
||||
- **Investigation Steps:** Ordered troubleshooting procedures with time estimates
|
||||
- **Resolution Actions:** Common fixes and escalation procedures
|
||||
- **Post-Incident:** Follow-up tasks and prevention measures
|
||||
|
||||
#### Incident Detection Patterns
|
||||
- **Anomaly Detection:** Statistical methods for detecting unusual patterns
|
||||
- **Composite Alerts:** Multi-signal alerts for complex failure modes
|
||||
- **Predictive Alerts:** Capacity and trend-based forward-looking alerts
|
||||
- **Canary Monitoring:** Early detection through progressive deployment monitoring
|
||||
|
||||
### Golden Signals Framework
|
||||
|
||||
#### Latency Monitoring
|
||||
- **Request Latency:** P50, P95, P99 response time tracking
|
||||
- **Queue Latency:** Time spent waiting in processing queues
|
||||
- **Network Latency:** Inter-service communication delays
|
||||
- **Database Latency:** Query execution and connection pool metrics
|
||||
|
||||
#### Traffic Monitoring
|
||||
- **Request Rate:** Requests per second with burst detection
|
||||
- **Bandwidth Usage:** Network throughput and capacity utilization
|
||||
- **User Sessions:** Active user tracking and session duration
|
||||
- **Feature Usage:** API endpoint and feature adoption metrics
|
||||
|
||||
#### Error Monitoring
|
||||
- **Error Rate:** 4xx and 5xx HTTP response code tracking
|
||||
- **Error Budget:** SLO-based error rate targets and consumption
|
||||
- **Error Distribution:** Error type classification and trending
|
||||
- **Silent Failures:** Detection of processing failures without HTTP errors
|
||||
|
||||
#### Saturation Monitoring
|
||||
- **Resource Utilization:** CPU, memory, disk, and network usage
|
||||
- **Queue Depth:** Processing queue length and wait times
|
||||
- **Connection Pools:** Database and service connection saturation
|
||||
- **Rate Limiting:** API throttling and quota exhaustion tracking
|
||||
|
||||
### Distributed Tracing Strategies
|
||||
|
||||
#### Trace Architecture
|
||||
- **Sampling Strategy:** Head-based, tail-based, and adaptive sampling
|
||||
- **Trace Propagation:** Context propagation across service boundaries
|
||||
- **Span Correlation:** Parent-child relationship modeling
|
||||
- **Trace Storage:** Retention policies and storage optimization
|
||||
|
||||
#### Service Instrumentation
|
||||
- **Auto-Instrumentation:** Framework-based automatic trace generation
|
||||
- **Manual Instrumentation:** Custom span creation for business logic
|
||||
- **Baggage Handling:** Cross-cutting concern propagation
|
||||
- **Performance Impact:** Instrumentation overhead measurement and optimization
|
||||
|
||||
### Log Aggregation Patterns
|
||||
|
||||
#### Collection Architecture
|
||||
- **Agent Deployment:** Log shipping agent strategies (push vs pull)
|
||||
- **Log Routing:** Topic-based routing and filtering
|
||||
- **Parsing Strategies:** Structured vs unstructured log handling
|
||||
- **Schema Evolution:** Log format versioning and migration
|
||||
|
||||
#### Storage and Indexing
|
||||
- **Index Design:** Optimized field indexing for common query patterns
|
||||
- **Retention Policies:** Time and volume-based log retention
|
||||
- **Compression:** Log data compression and archival strategies
|
||||
- **Search Performance:** Query optimization and result caching
|
||||
|
||||
### Cost Optimization for Observability
|
||||
|
||||
#### Data Management
|
||||
- **Metric Retention:** Tiered retention based on metric importance
|
||||
- **Log Sampling:** Intelligent sampling to reduce ingestion costs
|
||||
- **Trace Sampling:** Cost-effective trace collection strategies
|
||||
- **Data Archival:** Cold storage for historical observability data
|
||||
|
||||
#### Resource Optimization
|
||||
- **Query Efficiency:** Optimized metric and log queries
|
||||
- **Storage Costs:** Appropriate storage tiers for different data types
|
||||
- **Ingestion Rate Limiting:** Controlled data ingestion to manage costs
|
||||
- **Cardinality Management:** High-cardinality metric detection and mitigation
|
||||
|
||||
## Scripts Overview
|
||||
|
||||
This skill includes three powerful Python scripts for comprehensive observability design:
|
||||
|
||||
### 1. SLO Designer (`slo_designer.py`)
|
||||
Generates complete SLI/SLO frameworks based on service characteristics:
|
||||
- **Input:** Service description JSON (type, criticality, dependencies)
|
||||
- **Output:** SLI definitions, SLO targets, error budgets, burn rate alerts, SLA recommendations
|
||||
- **Features:** Multi-window burn rate calculations, error budget policies, alert rule generation
|
||||
|
||||
### 2. Alert Optimizer (`alert_optimizer.py`)
|
||||
Analyzes and optimizes existing alert configurations:
|
||||
- **Input:** Alert configuration JSON with rules, thresholds, and routing
|
||||
- **Output:** Optimization report and improved alert configuration
|
||||
- **Features:** Noise detection, coverage gaps, duplicate identification, threshold optimization
|
||||
|
||||
### 3. Dashboard Generator (`dashboard_generator.py`)
|
||||
Creates comprehensive dashboard specifications:
|
||||
- **Input:** Service/system description JSON
|
||||
- **Output:** Grafana-compatible dashboard JSON and documentation
|
||||
- **Features:** Golden signals coverage, RED/USE methods, drill-down paths, role-based views
|
||||
|
||||
## Integration Patterns
|
||||
|
||||
### Monitoring Stack Integration
|
||||
- **Prometheus:** Metric collection and alerting rule generation
|
||||
- **Grafana:** Dashboard creation and visualization configuration
|
||||
- **Elasticsearch/Kibana:** Log analysis and dashboard integration
|
||||
- **Jaeger/Zipkin:** Distributed tracing configuration and analysis
|
||||
|
||||
### CI/CD Integration
|
||||
- **Pipeline Monitoring:** Build, test, and deployment observability
|
||||
- **Deployment Correlation:** Release impact tracking and rollback triggers
|
||||
- **Feature Flag Monitoring:** A/B test and feature rollout observability
|
||||
- **Performance Regression:** Automated performance monitoring in pipelines
|
||||
|
||||
### Incident Management Integration
|
||||
- **PagerDuty/VictorOps:** Alert routing and escalation policies
|
||||
- **Slack/Teams:** Notification and collaboration integration
|
||||
- **JIRA/ServiceNow:** Incident tracking and resolution workflows
|
||||
- **Post-Mortem:** Automated incident analysis and improvement tracking
|
||||
|
||||
## Advanced Patterns
|
||||
|
||||
### Multi-Cloud Observability
|
||||
- **Cross-Cloud Metrics:** Unified metrics across AWS, GCP, Azure
|
||||
- **Network Observability:** Inter-cloud connectivity monitoring
|
||||
- **Cost Attribution:** Cloud resource cost tracking and optimization
|
||||
- **Compliance Monitoring:** Security and compliance posture tracking
|
||||
|
||||
### Microservices Observability
|
||||
- **Service Mesh Integration:** Istio/Linkerd observability configuration
|
||||
- **API Gateway Monitoring:** Request routing and rate limiting observability
|
||||
- **Container Orchestration:** Kubernetes cluster and workload monitoring
|
||||
- **Service Discovery:** Dynamic service monitoring and health checks
|
||||
|
||||
### Machine Learning Observability
|
||||
- **Model Performance:** Accuracy, drift, and bias monitoring
|
||||
- **Feature Store Monitoring:** Feature quality and freshness tracking
|
||||
- **Pipeline Observability:** ML pipeline execution and performance monitoring
|
||||
- **A/B Test Analysis:** Statistical significance and business impact measurement
|
||||
|
||||
## Best Practices
|
||||
|
||||
### Organizational Alignment
|
||||
- **SLO Setting:** Collaborative target setting between product and engineering
|
||||
- **Alert Ownership:** Clear escalation paths and team responsibilities
|
||||
- **Dashboard Governance:** Centralized dashboard management and standards
|
||||
- **Training Programs:** Team education on observability tools and practices
|
||||
|
||||
### Technical Excellence
|
||||
- **Infrastructure as Code:** Observability configuration version control
|
||||
- **Testing Strategy:** Alert rule testing and dashboard validation
|
||||
- **Performance Monitoring:** Observability system performance tracking
|
||||
- **Security Considerations:** Access control and data privacy in observability
|
||||
|
||||
### Continuous Improvement
|
||||
- **Metrics Review:** Regular SLI/SLO effectiveness assessment
|
||||
- **Alert Tuning:** Ongoing alert threshold and routing optimization
|
||||
- **Dashboard Evolution:** User feedback-driven dashboard improvements
|
||||
- **Tool Evaluation:** Regular assessment of observability tool effectiveness
|
||||
|
||||
## Success Metrics
|
||||
|
||||
### Operational Metrics
|
||||
- **Mean Time to Detection (MTTD):** How quickly issues are identified
|
||||
- **Mean Time to Resolution (MTTR):** Time from detection to resolution
|
||||
- **Alert Precision:** Percentage of actionable alerts
|
||||
- **SLO Achievement:** Percentage of SLO targets met consistently
|
||||
|
||||
### Business Metrics
|
||||
- **System Reliability:** Overall uptime and user experience quality
|
||||
- **Engineering Velocity:** Development team productivity and deployment frequency
|
||||
- **Cost Efficiency:** Observability cost as percentage of infrastructure spend
|
||||
- **Customer Satisfaction:** User-reported reliability and performance satisfaction
|
||||
|
||||
This comprehensive observability design skill enables organizations to build robust, scalable monitoring and alerting systems that provide actionable insights while maintaining cost efficiency and operational excellence.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user