Skip to content

Instantly share code, notes, and snippets.

@malikbenkirane
Created April 16, 2026 08:41
Show Gist options
  • Select an option

  • Save malikbenkirane/4e875ec510599e3e90ae2c955cf241e7 to your computer and use it in GitHub Desktop.

Select an option

Save malikbenkirane/4e875ec510599e3e90ae2c955cf241e7 to your computer and use it in GitHub Desktop.
core-commands
name core-commands
description Core command guidelines - prohibited commands and temp file patterns. ALWAYS load this skill at session start.

Core Commands

This skill defines prohibited commands and the temp file pattern for multi-line content.

Before Running Any Command

Check if the command starts with a prohibited prefix:

  1. Does it start with git? → Find jj equivalent in table below
  2. Does it start with jj log? → Use jj status instead
  3. Does it start with jj op? → Not allowed, ask user
  4. Does it start with jj abandon? → Use jj new instead
  5. Does it start with jj edit? → Not allowed, use jj new instead
  6. Does it start with jj prev or jj next? → Ask user first
  7. Does it have -i flag? → Not allowed (interactive)
  8. Does jj new have any arguments? → Not allowed, use plain jj new only

Prohibited Commands

NEVER use git commands. This repo uses jj exclusively.

Prohibition is prefix-based: Commands matching the start of a prohibited pattern are forbidden (e.g., jj log -r 'all()' matches jj log*).

Prohibited jj Commands (Prefix Patterns)

  • jj abandon* - Do not abandon changes
  • jj describe before changes are ready and reviewed
  • jj edit* - Moves working copy unexpectedly, use jj new instead
  • jj git push without explicit user confirmation
  • jj log* - Produces incoherent output
  • jj new with any arguments - Only plain jj new allowed
  • jj op* - Operations commands not allowed
  • jj prev* / jj next* - Navigation requires user confirmation
  • jj rebase* - Can break change dependencies
  • jj squash* - Violates atomic commit history
  • jj split* - Breaks atomicity
  • Interactive commands with -i flag

Prohibited Actions

  • Update git config
  • Run destructive commands without explicit request
  • Skip hooks without explicit request
  • Commit without explicit request
  • Push without explicit confirmation
  • Commit secrets or credentials
  • Expose or log secrets

Command Alternatives

Prohibited Pattern Why Use Instead
jj log* Incoherent output jj status or jj op log
jj op* Not allowed jj status or ask user
jj abandon* Destructive Create new change with jj new
jj prev* / jj next* Needs confirmation Ask user first
git status Wrong VCS jj status
git branch* Wrong VCS jj bookmark list
git checkout* Wrong VCS jj new
git commit* Wrong VCS jj describe
git push* Wrong VCS jj git push (with confirmation)
git pull* Wrong VCS jj git fetch
git merge* Wrong VCS jj merge or rebase approach
git rebase* Wrong VCS Use jj's automatic rebasing

Temp File Pattern for Multi-Line Content

NEVER use heredocs (cat <<'EOF') or echo for multi-line content. These patterns have escaping issues and produce unreliable output.

ALWAYS use the mktemp + Write tool pattern:

Each Bash tool invocation runs in an independent shell environment. Variables set in one command do NOT persist to subsequent commands. Therefore:

  1. Get temp file path - Run mktemp -p "$PWD" without variable assignment:

    mktemp -p "$PWD"

    The tool returns a path like /path/to/repo/tmp.XXXXXX.

  2. Write content - Use the Write tool with the path from step 1 as a literal string.

  3. Pass file to command - Use the same path as a literal string:

    <command> --option "/path/to/repo/tmp.XXXXXX"
  4. Clean up - Remove the file when done:

    rm "/path/to/repo/tmp.XXXXXX"

Key insight: The temp file path must be captured from the tool output and used as a literal string in all subsequent commands. Do NOT use shell variables.

Examples

Creating GitHub issue:

mktemp -p "$PWD"
# Tool returns: /path/to/repo/tmp.XXXXXX
# Use Write tool to write issue description to /path/to/repo/tmp.XXXXXX
gh issue new -t 'Issue title' -F "/path/to/repo/tmp.XXXXXX"
rm "/path/to/repo/tmp.XXXXXX"

Describing commit with complex message:

mktemp -p "$PWD"
# Tool returns: /path/to/repo/tmp.XXXXXX
# Use Write tool to write commit message to /path/to/repo/tmp.XXXXXX
jj describe --stdin < "/path/to/repo/tmp.XXXXXX"
rm "/path/to/repo/tmp.XXXXXX"

Creating PR:

mktemp -p "$PWD"
# Tool returns: /path/to/repo/tmp.XXXXXX
# Use Write tool to write PR description to /path/to/repo/tmp.XXXXXX
gh pr create --draft --base main --head username/issue-123 --title "PR title" -F "/path/to/repo/tmp.XXXXXX"
rm "/path/to/repo/tmp.XXXXXX"

Why This Matters

  • Heredocs fail when content contains special characters, variables, or nested quotes
  • echo fails with backslashes and special characters
  • Write tool handles all escaping correctly and consistently
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment