Skip to content

Cheat Sheets

Common commands and queries that you'll need often.

AWS CLI

# Confirm you're authenticated and as which user
aws sts get-caller-identity

# List ECS services in the cluster
aws ecs list-services --cluster platform-prod

# Get a shell on a running container
aws ecs execute-command \
  --cluster platform-prod \
  --task <task-arn> \
  --container api \
  --interactive \
  --command "/bin/sh"

# Tail ECS logs
aws logs tail /ecs/platform-api --follow

Terraform

# Initialise after pulling
terraform init

# Show what will change
terraform plan

# Apply (after review)
terraform apply

# Show current state of one resource
terraform state show module.rds.aws_db_instance.this

# Import an existing resource into state
terraform import <address> <id>

PostgreSQL

-- List all tenant schemas
SELECT schema_name FROM information_schema.schemata
WHERE schema_name NOT IN ('public', 'pg_catalog', 'information_schema');

-- Switch to a tenant's schema for the session
SET search_path TO acme;

-- Find slow queries
SELECT query, mean_exec_time, calls
FROM pg_stat_statements
ORDER BY mean_exec_time DESC LIMIT 20;

-- Find missing indexes (large tables with sequential scans)
SELECT schemaname, tablename, seq_scan, seq_tup_read
FROM pg_stat_user_tables
WHERE seq_scan > 1000
ORDER BY seq_tup_read DESC;

Git

# Create a feature branch
git checkout -b feature/eng-123-description

# Amend the last commit
git commit --amend

# Interactive rebase to clean up commits before PR
git rebase -i main

# Pull with rebase (preferred over merge)
git pull --rebase

# See what's changed in a file across commits
git log --oneline --follow -- path/to/file

Docker

# Tail logs of all compose services
docker compose logs -f

# Reset everything (destroys local data)
docker compose down -v && docker compose up -d

# Shell into a running container
docker compose exec postgres bash

Python (uv)

# Install dependencies
uv pip install -e ".[dev]"

# Add a new dependency
# Edit pyproject.toml first, then:
uv pip install -e .

# Run tests
pytest

# Run tests with coverage
pytest --cov=src

# Run a specific test
pytest tests/modules/test_projects.py::test_create_project

Node / npm

# Install
npm install

# Run dev server
npm run dev

# Regenerate API types from running backend
npm run generate-types

# Run tests
npm test

# Run E2E tests
npm run test:e2e