AgentSkillsCN

Dev Script

开发脚本

SKILL.md

name: dev-script description: Generate a dev.sh script that uses tmux to manage development services (dev server, database, etc.) with flags for clean, restart, down, and db-only modes. argument-hint: "[project-name]" disable-model-invocation: true

Dev Script Generator

Generate a dev.sh bash script for the current project. The script uses tmux to manage development services in named sessions with split panes.

When to Use

Use this skill when the user needs to:

  • Set up a tmux-based development environment with multiple services
  • Generate a script for managing dev server, database, and other services
  • Create a standardized dev.sh script with common flags (--clean, --db, --restart, --down)
  • Automate development workflow with tmux sessions and split panes

Steps

  1. Gather Required Information Ask the user for the following if not provided via $ARGUMENTS or context:

    • Session/project name — used as the tmux session name (e.g., myapp)
    • Services to run — what commands run in each pane (e.g., bun dev, docker compose up, cargo watch)
    • Package manager — for the --clean flag reinstall step (e.g., bun, npm, pnpm)
    • Files to remove on clean — lock files and dependency dirs to delete (e.g., node_modules bun.lockb)
  2. Generate the dev.sh Script

    The generated dev.sh must follow this exact pattern:

    Argument parsing

    Support these flags via a for arg in "$@" loop with case:

    FlagVariablePurpose
    --cleanCLEANFull teardown: stop services, delete deps, reinstall, then start
    --dbDB_ONLYStart only the database/infrastructure service
    --restartRESTARTKill existing session and recreate
    --downDOWNShut everything down and exit

    All default to false.

    Session existence check

    bash
    SESSION_EXISTS=false
    if tmux has-session -t <name> 2>/dev/null; then
        SESSION_EXISTS=true
    fi
    

    Mode handlers (in this order)

    • --down: Kill tmux session if exists, stop infrastructure (e.g., docker compose down), then exit 0.
    • --clean: Kill session, stop infrastructure with -v, remove dependency files, reinstall, sleep 1, set SESSION_EXISTS=false. Does NOT exit — falls through to start.
    • --db: Kill existing session, create new session with only the infrastructure service, attach, exit 0.
    • --restart / session exists: Kill existing session, fall through to creation.

    Session creation

    • Create a detached tmux session with the first service in the first pane
    • Split the window vertically for each additional service
    • Select the first pane after setup
    • Print what was created

    Attach

    bash
    tmux attach -t <name>
    
  3. Output the Script Write the script to dev.sh in the project root and make it executable with chmod +x dev.sh.