Skip to content

mktemp: no flag form is both non-deprecated and portable, and the bare form writes into the repo #1709

Description

@kyle-sexton

Context

Skills across this marketplace instruct agents to create ephemeral files with mktemp, and the flag forms in use are either deprecated or not portable to macOS. There is currently no single documented form that is both.

Verified empirically in this environment (Git Bash on Windows, GNU coreutils 8.32):

$ mktemp --help | grep -A1 '^  -t'
  -t                  interpret TEMPLATE as a single file name component,
                        relative to a directory: $TMPDIR, if set; else the

GNU's own help text marks -t [deprecated]. Meanwhile --tmpdir is a GNU long option that BSD mktemp does not implement, so it is unavailable on macOS — which several of these skills explicitly claim to support, since they emit open <path> for macOS in the very same instruction block.

So today a skill author picks between a deprecated flag and a non-portable one.

Why this matters more than it looks

A bare mktemp with a relative template is actively dangerous, which is what pushes authors toward these flags in the first place:

$ cd <a repo worktree>
$ mktemp -u fc-test-XXXXXX
fc-test-tdvDNS            # relative — creates the file IN THE REPO
$ mktemp -u -t fc-test-XXXXXX
/tmp/fc-test-s5WOPv       # correct
$ mktemp -u
/tmp/tmp.wU8JAOjsg6       # correct

GNU's implicit --tmpdir applies only when no template is given. A producer supplying a relative template to preserve a readable filename — mktemp clarify-XXXXXX.html, the natural thing to write — creates the file in the current working directory. For a skill running inside a consumer's repository, that violates the topic-docs ephemeral tier's own "Never in the repo" rule and leaves an untracked file in their tree.

So the flag is not optional decoration; it is what keeps the file out of the repo. Which makes "there is no correct flag" a real gap rather than a style nit.

Scope

The flag choice originates in plugins/architecture/skills/improve/actions/deepening.md and has since been copied into other skills, including the five touched by PR #1708. It is a marketplace-wide inheritance, not a defect introduced by any one PR.

A sweep for mktemp across plugins/** will find the full set; every call site needs the same answer, so this wants one decision recorded in an owner doc rather than five independent judgements.

Proposed work

  • Determine a mktemp form that is non-deprecated and portable across GNU coreutils and BSD/macOS, verified by actually running it on both rather than by reading man pages. A candidate worth testing first is setting the directory explicitly and passing an absolute template:

    tmpdir="${TMPDIR:-/tmp}"; mktemp "$tmpdir/name-XXXXXX.html"
    

    which sidesteps both -t and --tmpdir. Confirm the .html suffix survives on BSD — GNU auto-implies --suffix when the template does not end in X, and BSD's behavior here needs checking, not assuming.

  • Record the chosen form in the topic-docs ephemeral tier as the normative instruction, so rule 1 names a specific portable invocation instead of "the platform's temp primitive".

  • Migrate every existing call site to that form.

  • State plainly what happens where no portable form exists, if that turns out to be the case — an honest per-platform branch beats a form that silently misbehaves on one of them.

Acceptance criteria

  • A portable, non-deprecated mktemp form is identified and verified by execution on both GNU and BSD, with the outputs recorded.
  • The topic-docs ephemeral tier names that exact form.
  • Every mktemp call site under plugins/** uses it; a sweep confirms no bare-relative-template invocations remain.
  • If no single portable form exists, the per-platform branch is documented explicitly rather than left to the author.

References

  • docs/conventions/topic-docs/README.md — the ephemeral tier and its "Never in the repo" rule
  • plugins/architecture/skills/improve/actions/deepening.md — origin of the current flag choice
  • PR fix(plugins): bring five ephemeral-file producers onto the tier contract #1708 — spreads the current form to four more skills; its description carries the same limitation note
  • GNU coreutils mktemp --help (-t marked deprecated); BSD mktemp(1) has no --tmpdir

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-humanHuman-in-the-loop required; autonomous sessions must not resolve items carrying this.priority: mediumReal value, no hard deadline; normal backlog flow.status: needs-decisionAwaiting a human or maintainer judgment call.work-class: scopedA briefed fix or small feature; blast radius bounded by the brief, tests exist.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions