.claude/skills/sagerstack-local-testing/SKILL.md
Testing infrastructure, local environment simulation, and deployment scripts. Use when setting up pytest fixtures, Docker Compose, LocalStack, mocking external services, or creating local deployment scripts. Focuses on HOW to test and run locally, not coding principles (TDD is in software-engineering).
npx skillsauth add sagerstack/agentic-sdlc sagerstack:local-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
<essential_principles>
These principles ALWAYS apply when setting up testing and local execution environments.
The app MUST be able to completely execute locally using Docker and container images that simulate third-party services and production infrastructure.
# docker-compose.yml - Everything runs locally
services:
localstack:
image: localstack/localstack:3.7.2
ports:
- "4566:4566"
environment:
- SERVICES=s3,sns,sqs,secretsmanager,lambda
postgres:
image: postgres:16-alpine
ports:
- "5432:5432"
redis:
image: redis:7-alpine
ports:
- "6379:6379"
When third-party integrations are involved, ALWAYS clarify with the user:
Never assume. Ask explicitly before implementing.
| File | Purpose | Source Control |
|------|---------|----------------|
| .env.example | Template with all required vars (no secrets) | Committed |
| .env.local | Local development configuration | Gitignored |
| tests/.env.test | Test configuration | Gitignored |
Critical rules:
tests/.env.test.env.local.env.example is checked into source control# tests/conftest.py
from pathlib import Path
from dotenv import load_dotenv
# Load test environment at the START of test collection
testEnvPath = Path(__file__).parent / ".env.test"
load_dotenv(testEnvPath)
All local deployment scripts live under scripts/local/:
| Script | Purpose |
|--------|---------|
| deploy-infrastructure.sh | Spin up Docker containers (LocalStack, DBs, etc.) |
| deploy-config.sh | Load configuration, create secrets in LocalStack |
| deploy-app.sh | Build and deploy the application locally |
Production-grade requirement: These scripts should be written so that creating production versions requires MINIMAL changes. Same structure, same approach - just different targets.
scripts/
├── local/
│ ├── deploy-infrastructure.sh # Start containers
│ ├── deploy-config.sh # Load secrets/configs
│ └── deploy-app.sh # Deploy application
└── aws/
├── deploy-infrastructure.sh # Terraform apply
├── deploy-config.sh # Load secrets to AWS
└── deploy-app.sh # Deploy to AWS
tests/
├── .env.test # Test configuration
├── conftest.py # Shared fixtures
├── unit/ # Fast, isolated tests
│ └── {slice}/
│ ├── testOrder.py
│ └── testPlaceOrder.py
├── integration/ # Tests with real dependencies
│ └── {slice}/
│ └── testSqlalchemyRepo.py
└── e2e/ # Full workflow tests
└── testOrderWorkflow.py
[tool.poetry.group.dev.dependencies]
pytest = "^8.0"
pytest-cov = "^4.0"
pytest-asyncio = "^0.23"
pytest-mock = "^3.12"
ruff = "^0.1"
mypy = "^1.8"
docker = "^7.0"
localstack = "^3.0"
python-dotenv = "^1.0"
Commands:
poetry run pytest # Run tests
poetry run pytest --cov # With coverage
poetry run pytest -m "not slow" # Skip slow tests
poetry run pytest tests/unit/ # Only unit tests
# Test files
tests/unit/orders/testOrder.py
# Test functions
def testPlaceOrderWithEmptyCart():
pass
def testCannotPlaceEmptyOrder():
pass
# Test classes
class TestOrderService:
def testCalculateTotal(self):
pass
</essential_principles>
<intake> **What would you like to do?**Wait for response, then read the matching workflow. </intake>
<routing> | Response | Workflow | |----------|----------| | 1, "docker", "localstack", "compose", "containers" | `workflows/setup-localstack.md` | | 2, "scripts", "deploy", "local scripts" | `workflows/create-deployment-scripts.md` | | 3, "fixtures", "conftest", "setup" | `workflows/setup-test-fixtures.md` | | 4, "env", ".env", "environment", "config" | `workflows/configure-env-files.md` | | 5, "mock", "external", "api", "third-party" | `workflows/mock-external-services.md` | | 6, "debug", "failing", "issue", "problem" | `workflows/debug-local-environment.md` | | 7, other | Clarify, then select workflow or references | </routing><reference_index>
All in references/:
Testing Infrastructure:
Local Execution:
Configuration:
Deployment Scripts:
<workflows_index>
All in workflows/:
| File | Purpose | |------|---------| | setup-localstack.md | Docker Compose + LocalStack setup | | create-deployment-scripts.md | Create scripts/local/ structure | | setup-test-fixtures.md | Configure conftest and fixtures | | configure-env-files.md | Set up .env.* file structure | | mock-external-services.md | Mock third-party APIs | | debug-local-environment.md | Troubleshoot local dev issues | </workflows_index>
<verification> ## After Local Environment Setup# 1. Docker containers running
docker-compose ps
# 2. LocalStack healthy
curl http://localhost:4566/_localstack/health
# 3. Environment files in sync
diff <(grep -v '^#' .env.example | sort) <(grep -v '^#' .env.local | cut -d= -f1 | sort)
# 4. Tests use correct environment
poetry run pytest tests/ -v --collect-only | head -20
# 5. All scripts executable and pass shellcheck
shellcheck scripts/local/*.sh
Checklist:
development
Interactive UAT verification skill. Walks the user through acceptance criteria one at a time, records pass/fail/skip results, generates UAT report, and routes remediation gaps to /sagerstack:builder. Solo skill (no agent team).
development
Python code architecture with Vertical Slice + DDD and Clean Architecture. Use when designing Python projects, structuring code, creating domain models, defining bounded contexts, or reviewing architecture. Enforces strict domain purity, CamelCase naming, and proper layer separation.
data-ai
SDLC planning skill that spawns a 4-member agent team to plan one epic at a time from project-context.md. Produces epics, user stories with FR/TR/AC, implementation plans, and critical analyses. Use when planning an epic for full SDLC execution with agent teams.
testing
AWS infrastructure deployment with Terraform. Use when deploying to AWS, writing Terraform configurations, setting up CI/CD with GitHub Actions, or managing AWS resources (EKS, Lambda, S3, SNS, SQS, Secrets Manager).