terminal-debugger
Skill0 starsChanged 25 days agoMITView on GitHub
Use when a shell command fails or behaves differently across machines: command not found, permission denied, quoting and argument errors, path and encoding problems, pipe failures, environment differences, CRLF scripts, or Windows Git Bash versus Linux behavior. Provides a systematic diagnosis instead of retry loops.
In this repository18 other files it gives its agents.
- docs/agents.mdAGENTS.md
- agent-skill-authorSkill
- api-contract-reviewSkill
- codex-cli-workflowsSkill
- codex-plugin-authorSkill
- context-budgetSkill
- dependency-auditSkill
- docs-writerSkill
- git-recoverySkill
- incident-postmortemSkill
- mcp-server-builderSkill
- performance-profileSkill
- pr-reviewerSkill
- release-engineerSkill
- repo-onboardingSkill
- skill-security-reviewSkill
- sql-migration-reviewSkill
- test-first-fixSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 8 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Use this skill when:
- Distinctive: line 51
Do not summarize the error.
- Very specific: line 137
Use #!/usr/bin/env bash rather than a hard-coded interpreter path when the script must run on multiple systems.
- Distinctive: line 169
Check whether the consumer exits early and the producer receives SIGPIPE.
- Distinctive: line 173
Run the command outside the script.
- Very specific: line 174
Run the script with bash -x script.sh.
- Very specific: line 175
Run with a minimal environment: env -i PATH="$PATH" HOME="$HOME" bash script.sh.
- Distinctive: line 176
Run as a different user or in a container.
- Distinctive: line 233
Do not run a failing destructive command repeatedly to "see if it works".
- Very specific: line 234
Do not add sudo to bypass a permission error before understanding it.
- Very specific: line 235
Do not disable set -e or error checks to silence a failure.
- Distinctive: line 236
Do not paste environment dumps that may contain tokens.
- Very specific: line 237
Do not rewrite a script with sed -i on a file you have not backed up.
- Distinctive: line 238
Do not assume Linux behavior in Git Bash.
- Very specific: line 239
Do not use eval to "fix" quoting.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Terminal Debugger
Shell failures are usually one of six things: the command is not the one you think, the argument is not the string you think, the path is not the file you think, the user lacks permission, the environment differs, or the failure is earlier in the pipeline than it appears.
Diagnose in that order. Do not rerun the same command and hope.
When to use
Use this skill when:
command not foundappears for a tool that is installed.- A command works in one terminal and fails in another or in CI.
- Arguments with spaces, quotes,
*,$, or non-ASCII characters misbehave. - A script fails with
bad interpreter,syntax error near unexpected token, or\r. - A pipeline exits 0 while producing wrong output.
- Permissions, ownership, or file mode cause failures.
- Windows Git Bash, WSL, PowerShell, and Linux disagree.
Workflow
1. Capture the exact failure
set -x
<command>
set +xRecord:
- The exact command as typed.
- The full error, including the first line.
- Exit code:
echo $?. - Shell:
echo "$SHELL",bash --version. - Working directory:
pwd. - User:
idorwhoami.
Do not summarize the error. The first line names the failure.
2. Confirm which command runs
type -a <command>
command -v <command>
which -a <command>type -a shows aliases, functions, builtins, and all PATH matches. A stale alias or a shim earlier in PATH is a common cause.
alias
echo "$PATH" | tr ':' '\n'On Windows, also check:
where <command>A Windows where may find a .cmd shim that Git Bash cannot execute the way you expect.
3. Check the arguments byte by byte
printf '<%s>\n' "$@"
printf '%q\n' "$@"Quoting rules:
"$var"preserves spaces and empty values.$varsplits on whitespace and globs.'single'prevents expansion.- Backslashes behave differently inside double quotes.
- A filename beginning with
-needs--before it.
rm -- "-weird-name"Windows paths in Git Bash:
C:\dir\fileis interpreted as escapes. UseC:/dir/fileor quote it.- MSYS rewrites some arguments that look like paths.
MSYS_NO_PATHCONV=1disables that for one command. - A Windows program receives Windows paths; a POSIX program receives POSIX paths.
4. Check the path and permissions
ls -la -- "<path>"
stat -- "<path>" # GNU; macOS: stat -f '%Sp %Su %Sg %N'
realpath -- "<path>" # macOS: realpath or python3 -cCommon causes:
- Case mismatch on a case-sensitive filesystem.
- Symlink pointing at a missing target.
- File exists but the directory lacks execute permission.
- The script lacks the execute bit:
chmod +x script.sh. - The mount is read-only.
- The file is owned by another user.
5. Check the interpreter and line endings
head -1 script.sh | od -c | head -3
file script.shbad interpreter: /usr/bin/env bash^M means CRLF line endings. Fix:
sed -i 's/\r$//' script.shOr configure Git:
git config --global core.autocrlf inputUse #!/usr/bin/env bash rather than a hard-coded interpreter path when the script must run on multiple systems.
6. Check the environment
env | cut -d= -f1 | sortCompare the failing environment with a working one. Common differences:
PATHand tool versions.HOME,TMPDIR,XDG_*.LANGandLC_*, which affect sorting and encoding.- Proxy variables.
- Shell startup files:
.bashrc,.bash_profile,.zshrc, PowerShell$PROFILE. - CI secrets that are present in one environment only.
Print names only. Do not dump values that may be secrets.
7. Check pipeline semantics
set -o pipefailWithout pipefail, the exit status is the last command's status. grep finding nothing can make a pipeline look successful while an earlier command failed.
<producer> | <consumer>
echo "${PIPESTATUS[@]}" # bashCheck whether the consumer exits early and the producer receives SIGPIPE. That can look like a random failure on large inputs.
8. Isolate
- Run the command outside the script.
- Run the script with
bash -x script.sh. - Run with a minimal environment:
env -i PATH="$PATH" HOME="$HOME" bash script.sh. - Run as a different user or in a container.
- Replace the network call with a local file.
- Replace the variable with a literal.
Bisect the script by commenting out halves until the failure moves.
Examples
Error:
./deploy.sh: /usr/bin/env: bad interpreter: No such file or directoryDiagnosis:
head -1 deploy.sh | od -c | head -2
# 0000000 # ! / u s r / b i n / e n v b a s h \r \nFix:
sed -i 's/\r$//' deploy.shError:
find: 'C:\Users\me': No such file or directoryDiagnosis: backslashes were consumed by the shell. Fix:
find "C:/Users/me" -maxdepth 1Error:
Permission deniedDiagnosis:
ls -ld . script.sh
id
mount | grep "$(df --output=target . | tail -1)"The directory may lack execute permission, the mount may be noexec, or the file may be owned by root.
Guardrails
- Do not run a failing destructive command repeatedly to "see if it works".
- Do not add
sudoto bypass a permission error before understanding it. - Do not disable
set -eor error checks to silence a failure. - Do not paste environment dumps that may contain tokens.
- Do not rewrite a script with
sed -ion a file you have not backed up. - Do not assume Linux behavior in Git Bash. Check the platform explicitly.
- Do not use
evalto "fix" quoting. Fix the quoting.
Verification checklist
- Exact command, error, exit code, shell, and directory recorded.
- Resolved command path checked with
type -a. - Arguments inspected with
printf '%q'. - Path, permissions, and mount options checked.
- Interpreter and line endings checked.
- Environment differences compared by name.
pipefailandPIPESTATUSchecked for pipelines.- Failure reproduced in isolation.
- Fix verified on the original command, not only a simplified one.
- Prevention added: script check, CI step, or documented requirement.
References
references/shell-failures.mdcontains a symptom-to-cause table and platform notes.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

