petr-korobeinikov/skills

mktemp-d

>- Forbids creating temporary files or directories at hardcoded paths under `/tmp`. Always allocate a private directory with `mktemp -d` and place every temporary artifact inside it.

First seen May 7, 2026

Installation

$ npx skills add petr-korobeinikov/skills --skill mktemp-d

Also in this package

Other skills from petr-korobeinikov/skills · top by installs.

npx skills add petr-korobeinikov/skills

Browse all from petr-korobeinikov/skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 1
License LICENSE
Default branch main
Open issues 0
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 1,761 B
  • docs SUMMARY.md 195 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 45 installs

SKILL.md

mktemp-d

Never create a temporary file or directory at a hardcoded path under /tmp. Always allocate a private directory with mktemp -d and place all temporary artifacts inside it.

Why

mktemp -d returns a unique, private directory. A hardcoded path under /tmp does not — it collides with concurrent runs and any leftover state from prior runs.

Rule

One mktemp -d per logical scope, then build paths inside it:

tmpdir=$(mktemp -d)

cp something "$tmpdir/input"
do_work > "$tmpdir/output.log"

Direct substitutions

Don't Do
mkdir /tmp/work work=$(mktemp -d)
touch /tmp/out.log work=$(mktemp -d); : > "$work/out.log"
cmd > /tmp/output work=$(mktemp -d); cmd > "$work/output"
tar xf x.tar -C /tmp work=$(mktemp -d); tar xf x.tar -C "$work"

If you encounter a hardcoded /tmp/... path while editing a file, replace it with the mktemp -d idiom as part of the same edit.