---
schema_version: 1
revision: "22ce5d34dbcb5a78"
id: "codex-shell-environment-practice"
title: "Reliable non-interactive shell environments: practice drills"
---

# Reliable non-interactive shell environments: practice drills

These exercises practice diagnosing agent shell visibility without turning the session into a full dotfiles audit.

## Exercise 1: Write A Missing Tool Prompt

Write a prompt that asks an agent to diagnose one missing tool.

Template:

```text
Codex cannot find `<tool>`, but it works in my terminal.

Inspect the non-interactive zsh startup path. Check `zsh -lc`, `ZDOTDIR`,
the agent-safe bootstrap, PATH order, and where the tool is installed. Do not
print secrets or full environment output. Tell me which file should change and
how to confirm it worked.
```

## Exercise 2: Agent Env Snapshot

Run the confirmation shape for your machine:

```bash
zsh -lc 'echo CODEX_AGENT_ENV_SOURCED=$CODEX_AGENT_ENV_SOURCED; echo ZDOTDIR=$ZDOTDIR; command -v codex bun pnpm cargo packx || true'
```

Write:

```markdown
# Agent Env Snapshot

- shell shape:
- ZDOTDIR:
- marker:
- tools found:
- tools missing:
- next action:
```

## Exercise 3: Number PATH

```bash
zsh -lc 'print -l ${(s/:/)PATH} | nl -ba | sed -n "1,30p"'
```

Write:

```markdown
# PATH Notes

- first project/toolchain path:
- package manager path:
- language runtime path:
- Homebrew path:
- suspicious entries:
- what should move:
```

## Exercise 4: Clean-Shell Check

```bash
env -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'
```

Answer:

```markdown
# Clean-Shell Check

- Did the marker become set again?
- Did required tools resolve?
- What changed compared to the normal check?
- What does that imply?
```

## Exercise 5: Place The Fix

For each case, choose the right home:

| Case | File Or Form |
| --- | --- |
| persistent PATH assembly for all shells | |
| machine-local private path | |
| prompt theme | |
| keybinding | |
| reusable command needed outside zsh | |
| rich helper function for interactive work | |
| safe agent bootstrap | |

Options:

```text
~/.config/zsh/conf.d/00-path.zsh
~/.config/zsh/local.zsh
~/.config/zsh/codex-env.zsh
~/.config/zsh/.zshrc
executable wrapper on PATH
Section 3 zsh DSL
```

## Exercise 6: Function Or Executable

Run:

```bash
zsh -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'
```

Classify:

```markdown
# Function Versus Executable

| name | executable / function / missing | Section 2 or Section 3? | why |
| --- | --- | --- | --- |
| bun | | | |
| packx | | | |
| funclist | | | |
| fix | | | |
| agent_chain | | | |
| xfl | | | |
```

## Related resources

- [Companion reference](https://lapis-fossil-vsbc.here.now/downloads/codex-power-user-workshop-2026-06-27.bundle)
- [Resource directory and portable download](/topics/codex-resources/)

## Original references

- [Portable Codex workflow resources](https://lapis-fossil-vsbc.here.now/downloads/codex-power-user-workshop-2026-06-27.bundle)
