mcpField
M
mktemp-d

mktemp-d

github.com/petr-korobeinikovDevelopment164 installsUpdated 2d ago
Repository

About mktemp-d

mktemp-d is a small agent skill that standardizes temporary-file handling in shell work. It directs workflows to create a private directory with `mktemp -d` instead of using fixed paths under `/tmp`.

Key features

  1. 01Creates private temporary directories
  2. 02Avoids hardcoded `/tmp` paths
  3. 03Provides shell substitutions for common operations

Use cases

  1. 01Choose safe locations for temporary files
  2. 02Extract archives into unique temporary directories

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/petr-korobeinikov/skills --skill mktemp-d

After installing, type/mktemp-din Claude Code to confirm it loaded.

Details

From the project README

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'tDo
mkdir /tmp/workwork=$(mktemp -d)
touch /tmp/out.logwork=$(mktemp -d); : > "$work/out.log"
cmd > /tmp/outputwork=$(mktemp -d); cmd > "$work/output"
tar xf x.tar -C /tmpwork=$(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.

Comments

Markdown supported