Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Strace Ltrace

ASecurity

Use when a binary misbehaves without crashing and the question is which file, socket, syscall, or library call fails: strace for syscalls, ltrace for library calls. Not for stepping: use gdb.

54 stars
0 votes
0 copies
0 views
Added 9/20/2026
ai-agentsgoshellbash

Security Analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned 9/20/2026

$npx -y skills add OutlineDriven/outline-driven-development --skill strace-ltrace --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Strace Ltrace?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Strace Ltrace
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/outlinedriven-strace-ltrace-outline-driven-development/badge)](https://www.skillsdirectory.com/skills/outlinedriven-strace-ltrace-outline-driven-development)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: strace-ltrace
description: 'Use when a binary misbehaves without crashing and the question is which file, socket, syscall, or library call fails: strace for syscalls, ltrace for library calls. Not for stepping: use gdb.'
---

# strace and ltrace

`strace` (6.19 on the grounding host) prints every system call a process makes with its arguments, return value, and errno. `ltrace` (0.7.91) does the same for calls that go through PLT slots into shared libraries. Together they answer "what did the program ask the system for, and what did it get back" without a debugger or a rebuild, which is the fastest route to a missing file, a refused connection, or a permission error.

## Contract

| Field | Bound contract |
|---|---|
| Trigger | A program exits wrong, hangs, cannot find a file, cannot connect, is killed by a policy, or starts slowly, and the user wants to see its syscalls or library calls. |
| Authority | Reversible local: writes only trace output files named with `-o` in the working directory; rollback is deleting them. Attaching to a running process needs ptrace permission and is proposed, not forced. No remote mutation. |
| Side effect | The traced program runs slower: every traced syscall stops the process twice. `ltrace` costs more than `strace` because it breakpoints PLT entries. |
| Done | The failing call is named with its arguments, return value, and errno, and the report states the cause (missing path, wrong permission, closed descriptor, refused address) and the fix. |

## Inputs

- The command line to trace, or the PID of a running process for `-p`.
- The symptom, which picks the filter: file not found (`%file`), network (`%network`), process spawn (`%process`), memory (`%memory`), signals (`%signal`), descriptors (`%desc`), or everything (`all`).
- ptrace permission: attaching to another user's process or a process in a container needs `CAP_SYS_PTRACE` (containers: `--cap-add=SYS_PTRACE`); `/proc/sys/kernel/yama/ptrace_scope` at `1` restricts attaching to descendants.

## Procedure

1. Trace the whole run to a file first: `strace -f -o trace.txt ./myapp args`. `-f` follows forks and clones and prefixes lines with the PID; `-o` keeps the trace out of the program's own stderr. Attach to a live process with `strace -p <pid> -o trace.txt`. Done when: `trace.txt` ends with `+++ exited with N +++` or the attach is confirmed.
2. Filter to the syscall class the symptom points at. The class names take a `%` prefix (`file` without the prefix still works but is deprecated):

   ```bash
   strace -e trace=%file ./myapp          # open, openat, stat, access, unlink, rename
   strace -e trace=%network ./myapp       # socket, connect, bind, accept, sendto, recvfrom
   strace -e trace=%process ./myapp       # fork, clone, execve, wait4, exit_group
   strace -e trace=%memory ./myapp        # mmap, munmap, mprotect, brk
   strace -e trace=%signal ./myapp        # kill, rt_sigaction, rt_sigprocmask
   strace -e trace=%desc ./myapp          # close, dup, poll, epoll_wait
   strace -e trace=openat,read,write ./myapp
   ```

   Done when: the trace holds only the class under suspicion.
3. Show only failures. `strace -Z` prints only syscalls that returned an error (`-z` prints only successes); combine with a class: `strace -Z -e trace=%file ./myapp`. Each failing line has the form `openat(AT_FDCWD, "/etc/myapp.conf", O_RDONLY) = -1 ENOENT (No such file or directory)`, which names the path the program expected. Done when: the first failing call relevant to the symptom is identified.
4. Read the errno:

   | errno | Meaning | Usual cause |
   |---|---|---|
   | `ENOENT` | No such file or directory | Wrong path, missing config, missing shared library |
   | `EACCES` | Permission denied | File mode, ownership, SELinux or AppArmor label |
   | `EPERM` | Operation not permitted | Missing capability, seccomp, needs setuid |
   | `EADDRINUSE` | Address already in use | Port still bound by another process |
   | `ECONNREFUSED` | Connection refused | Nothing listening on the target port |
   | `ETIMEDOUT` | Connection timed out | Route or firewall drops the packets |
   | `EAGAIN` | Resource temporarily unavailable | Non-blocking descriptor; a retry is expected |
   | `EBADF` | Bad file descriptor | Descriptor closed or never opened |
   | `ENOMEM` | Out of memory | Allocation or mmap refused |
   | `ENOEXEC` | Exec format error | Binary for another architecture or a bad interpreter line |

   Done when: the errno is mapped to a cause in the program's own terms.
5. Add detail where the default output hides it. `-s 256` raises the string cutoff from 32 bytes; `-y` appends the path behind each descriptor (`3</etc/ld.so.cache>`); `-t`, `-tt`, `-ttt` add wall-clock timestamps at increasing precision; `-r` prints relative timestamps; `-T` prints the time spent inside each call; `-k` prints a stack trace per syscall so the caller in the program is visible without gdb; `-e verbose=all` expands structures; `-i` prints the instruction pointer. Done when: the failing call carries the detail the diagnosis needs.
6. Profile with the summary when the symptom is slowness: `strace -c ./myapp` prints one row per syscall with `% time`, `seconds`, `usecs/call`, `calls`, and `errors`. A high `usecs/call` marks a blocking call; a non-zero `errors` column marks retries; a high call count on `read` or `write` with small sizes marks missing buffering. Done when: the top syscall by time and the top by error count are named.
7. Trace library calls with `ltrace` when the failure is in user space above the syscall layer. Filters use `+` between symbols and glob patterns: `ltrace -e malloc+free+fopen ./myapp`, `ltrace -e 'pthread_*' ./myapp`, `ltrace -e 'dlopen+dlsym+dlclose' ./myapp`. `-l libfoo.so*` traces every call into one library; `-S` adds syscalls; `-n 2` indents nested calls; `-c` prints a call-count summary; `-p <pid>` attaches; `-s 256` widens strings. Each line reads `malloc(1024) = 0x55a1b2c3d000`. `ltrace` sees only PLT calls, so a statically linked or LTO-inlined call does not appear. Done when: the library call and its return value are named.
8. Verify the diagnosis by fixing the cause (create the file, open the port, grant the permission) and rerunning the same filtered trace. Done when: the failing line no longer appears and the program behaves.

Recipes for the common cases live in `references/strace-patterns.md`.

## Failure and recovery

| Failure | Cause | Fix |
|---|---|---|
| `strace: attach: ptrace(PTRACE_SEIZE, N): Operation not permitted` | Yama scope or missing capability | Run as the process owner from a parent shell, propose `CAP_SYS_PTRACE`, or in containers `--cap-add=SYS_PTRACE` |
| Trace is empty or stops early | Program is a shell script or forks the real work | Add `-f`; check the `execve` line for the interpreter |
| Program killed by `SIGSYS` | seccomp policy denied a syscall | The last line before `+++ killed by SIGSYS +++` names the syscall; add it to the policy or avoid it |
| Strings truncated at 32 bytes | Default `-s` | `-s 256` or larger |
| `ltrace` shows nothing for a call | Not through a PLT slot (static, inlined, or `-fno-plt`) | Use `strace` for the syscall underneath, or `gdb` with a breakpoint |
| Timing changes hide a race | Tracing slows the process | Narrow with `-e trace=`, or reproduce under `perf trace` where available |

## Output

A diagnosis naming the failing syscall or library call with its full line from the trace, the errno and its cause in the program's terms, the fix applied or proposed, and the confirming rerun; plus the trace file paths.

Attribution

OutlineDrivenOutlineDriven
View sourceSee grades on GitHubMore from OutlineDriven →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698461 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →