{
  "schemaVersion": "1",
  "revision": "22ce5d34dbcb5a78",
  "id": "codex-shell-environment-practice",
  "slug": "shell-environment-practice",
  "title": "Reliable non-interactive shell environments: practice drills",
  "summary": "Six exercises diagnose missing tools through non-interactive zsh startup, environment markers, PATH ordering, a bootstrap recheck, configuration placement, and function-versus-executable classification.",
  "category": "Tools",
  "tags": [
    "zsh",
    "environment",
    "path",
    "practice"
  ],
  "sources": [
    {
      "label": "Portable Codex workflow resources",
      "url": "https://lapis-fossil-vsbc.here.now/downloads/codex-power-user-workshop-2026-06-27.bundle"
    }
  ],
  "sourceUnits": [
    "downloads/codex-power-user-workshop-2026-06-27.bundle!/exercises/02-loading-zsh-env-into-codex.md",
    "downloads/codex-power-user-workshop-2026-06-27.bundle!/exercises/02-loading-zsh-env-into-codex.md#Exercises: 02. Loading ZSH Env Into Codex",
    "downloads/codex-power-user-workshop-2026-06-27.bundle!/exercises/02-loading-zsh-env-into-codex.md#Exercises: 02. Loading ZSH Env Into Codex/Exercise 1: Write A Missing Tool Prompt",
    "downloads/codex-power-user-workshop-2026-06-27.bundle!/exercises/02-loading-zsh-env-into-codex.md#Exercises: 02. Loading ZSH Env Into Codex/Exercise 2: Agent Env Snapshot",
    "downloads/codex-power-user-workshop-2026-06-27.bundle!/exercises/02-loading-zsh-env-into-codex.md#Exercises: 02. Loading ZSH Env Into Codex/Exercise 3: Number PATH",
    "downloads/codex-power-user-workshop-2026-06-27.bundle!/exercises/02-loading-zsh-env-into-codex.md#Exercises: 02. Loading ZSH Env Into Codex/Exercise 4: Clean-Shell Check",
    "downloads/codex-power-user-workshop-2026-06-27.bundle!/exercises/02-loading-zsh-env-into-codex.md#Exercises: 02. Loading ZSH Env Into Codex/Exercise 5: Place The Fix",
    "downloads/codex-power-user-workshop-2026-06-27.bundle!/exercises/02-loading-zsh-env-into-codex.md#Exercises: 02. Loading ZSH Env Into Codex/Exercise 6: Function Or Executable",
    "downloads/codex-power-user-workshop-2026-06-27.bundle"
  ],
  "collection": "codex",
  "categoryId": "tools",
  "wordCount": 464,
  "url": "/topics/codex-shell-environment-practice/",
  "markdownUrl": "/markdown/codex-shell-environment-practice.md?raw=1&v=22ce5d34dbcb5a78",
  "jsonUrl": "/api/v1/documents/codex-shell-environment-practice.json",
  "headings": [
    {
      "id": "exercise-1-write-a-missing-tool-prompt",
      "text": "Exercise 1: Write A Missing Tool Prompt",
      "level": 2
    },
    {
      "id": "exercise-2-agent-env-snapshot",
      "text": "Exercise 2: Agent Env Snapshot",
      "level": 2
    },
    {
      "id": "exercise-3-number-path",
      "text": "Exercise 3: Number PATH",
      "level": 2
    },
    {
      "id": "exercise-4-clean-shell-check",
      "text": "Exercise 4: Clean-Shell Check",
      "level": 2
    },
    {
      "id": "exercise-5-place-the-fix",
      "text": "Exercise 5: Place The Fix",
      "level": 2
    },
    {
      "id": "exercise-6-function-or-executable",
      "text": "Exercise 6: Function Or Executable",
      "level": 2
    },
    {
      "id": "related-resources",
      "text": "Related resources",
      "level": 2
    }
  ],
  "markdown": "# Reliable non-interactive shell environments: practice drills\n\nThese exercises practice diagnosing agent shell visibility without turning the session into a full dotfiles audit.\n\n## Exercise 1: Write A Missing Tool Prompt\n\nWrite a prompt that asks an agent to diagnose one missing tool.\n\nTemplate:\n\n```text\nCodex cannot find `<tool>`, but it works in my terminal.\n\nInspect the non-interactive zsh startup path. Check `zsh -lc`, `ZDOTDIR`,\nthe agent-safe bootstrap, PATH order, and where the tool is installed. Do not\nprint secrets or full environment output. Tell me which file should change and\nhow to confirm it worked.\n```\n\n## Exercise 2: Agent Env Snapshot\n\nRun the confirmation shape for your machine:\n\n```bash\nzsh -lc 'echo CODEX_AGENT_ENV_SOURCED=$CODEX_AGENT_ENV_SOURCED; echo ZDOTDIR=$ZDOTDIR; command -v codex bun pnpm cargo packx || true'\n```\n\nWrite:\n\n```markdown\n# Agent Env Snapshot\n\n- shell shape:\n- ZDOTDIR:\n- marker:\n- tools found:\n- tools missing:\n- next action:\n```\n\n## Exercise 3: Number PATH\n\n```bash\nzsh -lc 'print -l ${(s/:/)PATH} | nl -ba | sed -n \"1,30p\"'\n```\n\nWrite:\n\n```markdown\n# PATH Notes\n\n- first project/toolchain path:\n- package manager path:\n- language runtime path:\n- Homebrew path:\n- suspicious entries:\n- what should move:\n```\n\n## Exercise 4: Clean-Shell Check\n\n```bash\nenv -u CODEX_AGENT_ENV_SOURCED zsh -lc 'echo CODEX_AGENT_ENV_SOURCED=${CODEX_AGENT_ENV_SOURCED:-}; echo ZDOTDIR=$ZDOTDIR; command -v codex bun pnpm cargo packx || true'\n```\n\nAnswer:\n\n```markdown\n# Clean-Shell Check\n\n- Did the marker become set again?\n- Did required tools resolve?\n- What changed compared to the normal check?\n- What does that imply?\n```\n\n## Exercise 5: Place The Fix\n\nFor each case, choose the right home:\n\n| Case | File Or Form |\n| --- | --- |\n| persistent PATH assembly for all shells | |\n| machine-local private path | |\n| prompt theme | |\n| keybinding | |\n| reusable command needed outside zsh | |\n| rich helper function for interactive work | |\n| safe agent bootstrap | |\n\nOptions:\n\n```text\n~/.config/zsh/conf.d/00-path.zsh\n~/.config/zsh/local.zsh\n~/.config/zsh/codex-env.zsh\n~/.config/zsh/.zshrc\nexecutable wrapper on PATH\nSection 3 zsh DSL\n```\n\n## Exercise 6: Function Or Executable\n\nRun:\n\n```bash\nzsh -lc 'for name in bun packx funclist fix agent_chain xfl; do echo \"--- $name ---\"; command -v \"$name\" 2>/dev/null || echo \"command -v: missing\"; whence -w \"$name\" 2>/dev/null || echo \"whence: missing\"; done'\n```\n\nClassify:\n\n```markdown\n# Function Versus Executable\n\n| name | executable / function / missing | Section 2 or Section 3? | why |\n| --- | --- | --- | --- |\n| bun | | | |\n| packx | | | |\n| funclist | | | |\n| fix | | | |\n| agent_chain | | | |\n| xfl | | | |\n```\n\n## Related resources\n\n- [Companion reference](https://lapis-fossil-vsbc.here.now/downloads/codex-power-user-workshop-2026-06-27.bundle)\n- [Resource directory and portable download](/topics/codex-resources/)"
}
