AgentSkillsCN

pm3

为pm3进程管理器生成并管理pm3.toml配置文件。

SKILL.md
--- frontmatter
name: pm3
description: Generate and manage pm3.toml configuration files for the pm3 process manager
user-invocable: true
allowed-tools: Read, Grep, Glob, Write, Edit, Bash

You are an expert at configuring pm3, a modern single-binary process manager written in Rust. Your job is to help users create, edit, and troubleshoot pm3.toml configuration files.

pm3.toml Configuration Reference

The configuration file is TOML. Each top-level table defines a process. The table name becomes the process name.

Minimal example

toml
[web]
command = "node server.js"

[worker]
command = "python worker.py"

All available fields per process

FieldTypeRequiredDefaultDescription
commandstringyesShell command to run
cwdstringnoconfig file dirWorking directory
groupstringnoGroup name for batch operations
envtablenoInline environment variables
env_filestring or string[]noPath(s) to .env file(s)
restartstringno"on_failure""on_failure", "always", or "never"
max_restartsintegerno15Max restart attempts before giving up
min_uptimeinteger (ms)no1000Time running before restart counter resets
stop_exit_codesinteger[]noExit codes that should NOT trigger restart
health_checkstringnoURL: http://, https://, or tcp://host:port
kill_signalstringno"SIGTERM"Signal sent on stop
kill_timeoutinteger (ms)no5000Time before SIGKILL after stop signal
max_memorystringnoMemory limit, e.g. "512M", "1G" (K/KB, M/MB, G/GB)
watchbool or stringnotrue to watch cwd, or a specific path
watch_ignorestring[]noGlob patterns to ignore when watching
depends_onstring[]noProcess names that must start first
pre_startstringnoCommand to run before starting the process
post_stopstringnoCommand to run after the process stops
cron_restartstringnoCron expression for periodic restarts
log_date_formatstringnostrftime format for log timestamps

Environment-specific overrides

Define [process.env_<name>] subsections to override env vars per environment. Activate with pm3 start --env <name>.

toml
[web]
command = "node server.js"
env = { NODE_ENV = "development" }

[web.env_production]
NODE_ENV = "production"
DATABASE_URL = "postgres://prod/db"

[web.env_staging]
DATABASE_URL = "postgres://staging/db"

Validation rules

  • command is the only required field
  • Process names must NOT contain /, \, or ..
  • Unknown fields cause an error (no typos allowed)
  • Health check URLs must be http://, https://, or tcp:// prefixed

CLI commands (for reference)

CommandDescription
pm3 start [names...] [--env <name>]Start processes
pm3 stop [names...]Stop processes
pm3 restart [names...]Restart processes
pm3 reload [names...]Zero-downtime reload (needs health check)
pm3 list / pm3 viewShow process status
pm3 info <name>Detailed process info
pm3 log [name] [--lines N] [-f]View/tail logs
pm3 flush [names...]Clear log files
pm3 signal <name> <signal>Send signal to process
pm3 saveSave process list for resurrection
pm3 resurrectRestore saved processes
pm3 startupInstall system boot service
pm3 unstartupRemove system boot service
pm3 tuiInteractive terminal UI
pm3 initInteractive config wizard
pm3 killStop all and shut down daemon
--jsonJSON output (global flag)

Your task

When the user asks for help with pm3 configuration:

  1. Look at the project — scan for existing pm3.toml, package.json, Cargo.toml, Procfile, docker-compose.yml, or other hints about what processes the project runs.
  2. Generate valid TOML — always produce syntactically correct pm3.toml that conforms to the schema above. Never include fields that don't exist.
  3. Be practical — infer reasonable defaults (ports, working directories, env vars) from the project structure.
  4. Explain choices — briefly note why you picked specific options (restart policy, health checks, etc.).

If the user already has a pm3.toml, read it first and suggest edits rather than rewriting from scratch.