Skip to content

Instantly share code, notes, and snippets.

@rohjay
Created January 17, 2026 19:50
Show Gist options
  • Select an option

  • Save rohjay/0f62d7c71206747acabe83cde9631be8 to your computer and use it in GitHub Desktop.

Select an option

Save rohjay/0f62d7c71206747acabe83cde9631be8 to your computer and use it in GitHub Desktop.
Agents.md Dropper
#!/usr/bin/env bash
set -e
AGENTS_DIR="$HOME/agents"
TARGET_FILE="agents.md"
if [[ -z "$1" ]]; then
echo "❌ Usage: agents <template-name>"
echo " Example: agents wordpress"
exit 1
fi
TEMPLATE="$1"
SOURCE_FILE="$AGENTS_DIR/$TEMPLATE.md"
if [[ ! -d "$AGENTS_DIR" ]]; then
echo "❌ Agents directory not found: $AGENTS_DIR"
exit 1
fi
if [[ ! -f "$SOURCE_FILE" ]]; then
echo "❌ Template not found: $SOURCE_FILE"
echo "Available templates:"
ls "$AGENTS_DIR" | sed 's/\.md$//' | sed 's/^/ - /'
exit 1
fi
if [[ -f "$TARGET_FILE" ]]; then
echo "⚠️ $TARGET_FILE already exists in this directory."
echo "Aborting to avoid clobbering it."
exit 1
fi
cp "$SOURCE_FILE" "$TARGET_FILE"
echo "✅ Created $TARGET_FILE from '$TEMPLATE' template"
echo "📁 Location: $(pwd)/$TARGET_FILE"
@rohjay
Copy link
Author

rohjay commented Jan 17, 2026

This allows you to create a list of different agents.md files (for different projects: a WordPress project, Laravel, Javascript, etc) and drops a copy of your agents.md into your current folder.

Drop your project specific agents.md files in a folder inside ~/agents/ specific to your project type. For instance, if I'm working on a WordPress site, I'll have a file called ~/agents/wordpress.md. Now when I'm in my project folder, I can type agents wordpress and it'll drop my wordpress.md into my current folder as agents.md

You can also add autocomplete support to your bash profile like this:

# Agents autocomplete ;)
_agents_complete() {
  local cur prev templates
  cur="${COMP_WORDS[COMP_CWORD]}"
  prev="${COMP_WORDS[COMP_CWORD-1]}"

  # If we're completing the first argument only
  if [[ $COMP_CWORD -eq 1 ]]; then
    templates=$(ls "$HOME/agents" 2>/dev/null | sed 's/\.md$//')

    # If the word is already complete and matches a template, stop
    if echo "$templates" | grep -qx "$cur"; then
      COMPREPLY=()
      return
    fi

    COMPREPLY=($(compgen -W "$templates" -- "$cur"))
  fi
}
complete -F _agents_complete agents

Adjust to taste 😉

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