Skip to content
justfile-advanced-patterns logo

Advanced Patterns (Level 3)

justfile-advanced-patterns

Level 3 patterns - test-smart, deploy, migrate, logs, status (production systems)

SKILL.md

Full skill instructions

Advanced Patterns (Level 3)

Production systems. Git-aware testing, deployment integration, migrations, observability.

Commands

test-smart

Git-aware test execution. Conditional expensive tests based on changed files.

# Smart test execution (conditional component tests based on git changes)
test-smart mode="default":
    @scripts/​test-smart.sh {{mode}}

Implementation (scripts/​test-smart.sh):

#!/​usr/​bin/​env bash
set -euo pipefail

MODE="${1:-default}"

# Always run fast unit tests
echo "🧪 Unit tests (always)..."
pnpm vitest run --project unit --reporter=verbose

# Determine if component tests needed
NEED_COMPONENT=false

case "$MODE" in
  staged)   CHANGED=$(git diff --cached --name-only --diff-filter=ACMR || echo "") ;;
  push)     CHANGED=$(git diff --name-only origin/​main...HEAD || echo "") ;;
  *)        CHANGED=$(git diff --name-only HEAD || echo "")
            CHANGED+=$'\n'$(git diff --cached --name-only --diff-filter=ACMR || echo "") ;;
esac

# Check if component-related files changed
if echo "$CHANGED" | grep -qE "src/(components|design-system|pages)/​.*\.tsx?$"; then
  NEED_COMPONENT=true
fi

# Run component tests if needed
if [ "$NEED_COMPONENT" = true ]; then
  echo "🎨 Component changes detected..."
  pnpm vitest run --project component --reporter=verbose
else
  echo "⏭️  No component changes"
fi

Usage:

just test-smart         # Default (working + staged)
just test-smart staged  # Pre-commit hook
just test-smart push    # Pre-push hook

deploy

Deploy to environment. Cloud provider integration.

# Deploy to environment (default: dev)
deploy environment="dev":
    @scripts/​deploy/​check-auth.sh {{environment}}
    @scripts/​deploy/​full.sh {{environment}}

Auth check (scripts/​deploy/​check-auth.sh):

#!/​usr/​bin/​env bash
set -euo pipefail

ENV="${1:-dev}"

# Check gcloud auth
if ! gcloud auth list --filter=status:ACTIVE >/​dev/​null 2>&1; then
  echo "❌ Not authenticated"
  exit 1
fi

# Check project
EXPECTED="myproject-$ENV"
CURRENT=$(gcloud config get-value project 2>/​dev/​null)

if [ "$CURRENT" != "$EXPECTED" ]; then
  echo "❌ Wrong project"
  echo "   Expected: $EXPECTED"
  echo "   Current:  $CURRENT"
  exit 1
fi

echo "✅ Authenticated: $(gcloud auth list --filter=status:ACTIVE --format='value(account)')"

Partial deploys:

deploy-api environment="dev":
    @scripts/​deploy/​api.sh {{environment}}

deploy-web environment="dev":
    @scripts/​deploy/​web.sh {{environment}}

migrate

Database migrations. Apply, rollback, create, history.

# Apply database migrations
migrate:
    <apply all pending migrations>

# Rollback last migration
migrate-down:
    <rollback one migration>

# Create new migration
migrate-create message:
    <generate migration with description>

# View migration history
migrate-history:
    <show applied migrations timeline>

Python (Alembic):

migrate:
    uv run alembic upgrade head

migrate-down:
    uv run alembic downgrade -1

migrate-create message:
    uv run alembic revision --autogenerate -m "{{message}}"

migrate-history:
    uv run alembic history --verbose

Migration testing:

test-migration:
    uv run pytest -v -m "migration" --durations=10

logs

Service logs. Tail cloud logs.

# View service logs
logs service="api" environment="dev":
    @scripts/​gcp/​logs.sh {{service}} {{environment}}

Implementation:

#!/​usr/​bin/​env bash
SERVICE="${1:-api}"
ENV="${2:-dev}"

gcloud logging tail \
  "resource.type=cloud_run_revision AND resource.labels.service_name=$ENV-$SERVICE" \
  --project="myproject-$ENV" \
  --format="table(timestamp, textPayload)"

status

Deployment health check.

# Check deployment status
status environment="dev":
    @scripts/​gcp/​status.sh {{environment}}

Implementation:

#!/​usr/​bin/​env bash
ENV="${1:-dev}"

echo "Services:"
gcloud run services list \
  --project="myproject-$ENV" \
  --format="table(SERVICE,URL,LAST_DEPLOYED)"

Pattern: Git-Aware Testing

Problem: Full test suite slow (unit 3s, component 18s). Running all tests every commit slows development.

Solution: Conditionally run expensive tests based on git diff.

Modes:

  • default: Working directory + staged
  • staged: Staged files only (pre-commit)
  • push: Commits since origin/​main (pre-push)

Benefits:

  • Fast feedback (3s typical)
  • Comprehensive when needed (21s UI changes)
  • Safe (always runs unit tests)

Pattern: Deployment Integration

Deployment as first-class justfile command. No context switching to console/​scripts.

Commands:

  • deploy - Full deployment
  • deploy-api, deploy-web - Partial (fast iteration)
  • logs - Debugging
  • status - Health check

Safety:

  • Auth checking before deploy
  • Default to dev environment
  • Explicit production deploys
  • Tag images with git SHA

Pattern: Migration Management

Migrations alongside tests/​builds. First-class development operation.

Workflow:

  1. Create migration: just migrate-create "add users table"
  2. Apply locally: just migrate
  3. Test: just test-migration
  4. Deploy with migrations: deployment script runs migrate

Testing:

@pytest.mark.migration
def test_upgrade_downgrade_cycle():
    downgrade(config, "base")
    upgrade(config, "head")
    downgrade(config, "-1")
    upgrade(config, "head")

When to Add Level 3

Add when:

  • Deploying to production
  • Database-backed application
  • Slow test suites (need optimization)
  • Cloud-native systems

Skip when:

  • No deployment workflows
  • No database
  • Fast test suites already
  • Static sites/​libraries

Cloud Provider Examples

GCP (Cloud Run): Examples above

AWS (ECS):

deploy environment="dev":
    aws ecs update-service --cluster {{environment}} --service api --force-new-deployment

Azure (Container Apps):

deploy environment="dev":
    az containerapp update --name api --resource-group {{environment}} --image {{image}}

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View