AGENT SKILL

devcontainer-lifecycle

This skill should be used when the user asks about "devcontainer lifecycle events", "postStartCommand", "postCreateCommand", "onCreateCommand", "lifecycle execution order", "parallel named commands", "waitFor property", "command failure semantics", "prebuild commands", "container startup hooks", or needs to understand when and how devcontainer lifecycle events execute.

License 许可
MIT
最近更新
2026-08-03
Stars
★ 1
Forks
0

01 前言 Front Matter

name
devcontainer-lifecycle
description
This skill should be used when the user asks about "devcontainer lifecycle events", "postStartCommand", "postCreateCommand", "onCreateCommand", "lifecycle execution order", "parallel named commands", "waitFor property", "command failure semantics", "prebuild commands", "container startup hooks", or needs to understand when and how devcontainer lifecycle events execute.

02 资源文件 2

03 SKILL.md 正文

Dev Container Lifecycle Events

Overview

The devcontainer specification defines 6 lifecycle events that execute in strict order during container creation, startup, and editor attachment. Understanding execution order, scope, and failure semantics is essential for reliable dev environment initialization.

Execution Order (Strict)

HOST:       initializeCommand
CONTAINER:  onCreateCommand → updateContentCommand → postCreateCommand
ON START:   postStartCommand
ON ATTACH:  postAttachCommand

Event Reference Table

Event Scope When Parallel Re-runs on restart
initializeCommand HOST Before container creation No No
onCreateCommand Container Container exists, not initialized YES (object) No
updateContentCommand Container After onCreate No No
postCreateCommand Container After full initialization YES (object) No
postStartCommand Container Every start/resume YES (object) YES
postAttachCommand Container Editor attaches YES (object) YES

Key Insight: postStartCommand for Sidecar Services

postStartCommand runs on EVERY container start, including restarts. This makes it the correct event for starting sidecar compose services that need to be running whenever the dev environment is active.

Command Syntax Formats

Three formats are supported (availability varies by event):

String (shell execution)

"postCreateCommand": "npm install && npm run build"

Runs in /bin/sh. Supports pipes, &&, ||, redirects. Use for complex shell logic.

Array (direct execution)

"postCreateCommand": ["npm", "run", "build"]

Runs directly without shell. More secure (no injection). Use for simple commands.

Object (parallel named commands)

"postCreateCommand": {
  "build": "npm run build",
  "watch": "npm run watch:css",
  "db-seed": ["npm", "run", "db:seed"]
}

All commands run in parallel with independent exit codes and logging. Supported by: onCreateCommand, postCreateCommand, postStartCommand, postAttachCommand.

Failure Semantics

  • If any creation command fails (onCreateCommand through postCreateCommand), ALL subsequent commands are SKIPPED
  • postStartCommand and postAttachCommand only run if creation succeeded
  • Each parallel named command has independent exit status
  • No explicit timeout mechanism in the spec — use backgrounding wisely

waitFor Property

Controls which lifecycle event blocks container readiness:

  • Values: "initializeCommand" | "onCreateCommand" | "updateContentCommand" | "postCreateCommand"
  • Default: "postCreateCommand" (blocks until full setup complete)
  • Use case: Define prebuild cutoff point for CI optimization

Common Patterns

Fast startup with parallel initialization

{
  "onCreateCommand": {
    "deps": "apt-get update && apt-get install -y build-essential",
    "db": "npm run db:setup"
  },
  "postStartCommand": {
    "dev-server": "npm run dev",
    "otel": "docker compose -f docker/otel/compose.yaml up -d"
  }
}

Prebuild optimization

{
  "waitFor": "updateContentCommand",
  "onCreateCommand": "apt-get update && apt-get install -y nodejs",
  "updateContentCommand": "npm ci",
  "postCreateCommand": "npm run build"
}

Additional Resources

Reference Files

For the complete lifecycle specification with all properties and edge cases:

  • references/lifecycle-events-full.md — Complete event documentation with all syntax examples
  • references/execution-guarantees.md — Timing, blocking, and failure behavior details

Related Skills

  • devcontainer-compose — Docker Compose integration patterns using lifecycle events
  • devcontainer-setup — Generate devcontainer.json with correct lifecycle pipeline

04 同仓库更多 Skills

ray-manaloto
ray-manaloto/macos-development-environment

next-workflow-step

Use this skill when the user wants to transition to the next workflow step, wrap up a session cleanly, prepare a handoff, or says things like "next step", "continue the workflow", "wrap up", "hand off", "move to the next phase", "what's next in embrace", or "prepare for /clear". Also triggers when the current octo:embrace phase appears complete and no explicit next action is set.

Skill与智能体开发
★ 1
ray-manaloto
ray-manaloto/macos-development-environment

source-discovery

This skill should be used when the user asks to "find sources", "discover URLs", "catalog a source", "classify a URL", "search for libraries", "check what exists", or mentions source discovery, URL cataloging, source classification, or research source management.

★ 1
ray-manaloto
ray-manaloto/macos-development-environment

review-synthesis

This skill should be used when the user asks to "summarize review findings", "prioritize fixes", "rank review issues", "combine reviewer feedback", "create action items from review", or mentions review synthesis, finding prioritization, severity ranking, or review result summarization.

★ 1
ray-manaloto
ray-manaloto/macos-development-environment

research-scoring

This skill should be used when the user asks to "score research", "check research quality", "evaluate coverage", "measure improvement", "assess research completeness", or mentions research scoring, quality metrics, coverage gaps, improvement baseline, or research pipeline status.

资料检索与研究
★ 1
ray-manaloto
ray-manaloto/macos-development-environment

notebooklm-integration

This skill should be used when the user asks to "ingest into NotebookLM", "query NotebookLM", "add sources to notebook", "cross-source synthesis", "check stale sources", or mentions NotebookLM, notebook integration, source ingestion, or knowledge consolidation.

★ 1
ray-manaloto
ray-manaloto/macos-development-environment

evidence-synthesis

This skill should be used when the user asks to "synthesize findings", "combine research", "cross-reference sources", "summarize evidence", "write a deep review", or mentions evidence synthesis, finding consolidation, cross-source analysis, or research summarization.

资料检索与研究
★ 1