vcs-detect

trmcnvn's avatarfrom trmcnvn

Detect whether the current project uses jj (Jujutsu) or git for version control. Run this BEFORE any VCS command to use the correct tool.

⭐1stars🔀0forks📁View on GitHub🕐Updated Jan 10, 2026

When & Why to Use This Skill

The VCS Detection skill is a specialized utility designed to automatically identify whether a project uses Git or Jujutsu (jj) for version control. By performing an environment check before executing any Version Control System (VCS) commands, it ensures that AI agents and automated workflows use the correct CLI tool, preventing command errors and maintaining repository integrity in complex or colocated environments.

Use Cases

  • Automated CLI Routing: Automatically switches between 'git' and 'jj' command sets based on the detected repository type, ensuring seamless interaction with the codebase.
  • Colocated Repo Management: Safely handles 'colocated' repositories containing both .git and .jj directories by prioritizing Jujutsu commands to preserve the intended workflow.
  • Error Prevention: Acts as a pre-flight check to prevent running incompatible VCS commands in directories that are either not version-controlled or use a different system.
  • Agentic Workflow Optimization: Enables AI agents to autonomously explore and manage repositories without requiring the user to specify the version control system in advance.
namevcs-detect
descriptionDetect whether the current project uses jj (Jujutsu) or git for version control. Run this BEFORE any VCS command to use the correct tool.

VCS Detection Skill

Detect the version control system in use before running any VCS commands.

Why This Matters

  • jj (Jujutsu) and git have different CLIs and workflows
  • Running git commands in a jj repo (or vice versa) causes errors
  • Some repos use jj with git colocated (both .jj/ and .git/ exist)

Detection Logic

Priority order (check in sequence):

  1. Check for .jj/ directory - If exists, use jj
  2. Check for .git/ directory - If exists, use git
  3. Neither found - Not a VCS-managed directory
if .jj/ exists -> use jj
else if .git/ exists -> use git
else -> no VCS detected

Detection Command

Run this single command to detect VCS:

if [ -d ".jj" ]; then echo "jj"; elif [ -d ".git" ]; then echo "git"; else echo "none"; fi

Command Mappings

Operation git jj
Status git status jj status
Log git log jj log
Diff git diff jj diff
Commit git commit jj commit / jj describe
Branch list git branch jj bookmark list
New branch git checkout -b <name> jj bookmark create <name>
Push git push jj git push
Pull/Fetch git pull / git fetch jj git fetch
Rebase git rebase jj rebase

Usage

Before any VCS operation:

  1. Run detection command
  2. Use appropriate CLI based on result
  3. If none, warn user directory is not version controlled

Example Integration

User: Show me the git log
Agent: [Runs detection] -> Result: jj
Agent: [Runs `jj log` instead of `git log`]

Colocated Repos

When both .jj/ and .git/ exist, the repo is "colocated":

  • jj manages the working copy
  • git is available for compatibility (GitHub, etc.)
  • Always prefer jj commands in colocated repos