| name | description | compatibility | allowed-tools |
|---|---|---|---|
git-clone |
Clones a git repository into a structured directory tree (Host/User/Repo) following git conventions. Handles URL parsing and idempotency (skips if exists) purely via instruction. |
Requires 'git' installed in the environment. |
Bash |
This skill enables you to clone git repositories into a canonical directory structure: ~/Code/<Host>/<User>/<Repo>.
You must enforce the following path construction logic based on the repository URL:
- Base Path: Defaults to
~/Code(unless user specifies otherwise). - Host: The domain of the git provider (e.g.,
github.com,gitlab.com). - User: The organization or username.
- Repo: The repository name (without
.gitsuffix).
| Input URL | Host | User | Repo | Target Path |
|---|---|---|---|---|
https://github.com/viko16/gitcd.plugin.zsh |
github.com |
viko16 |
gitcd.plugin.zsh |
~/Code/github.com/viko16/gitcd.plugin.zsh |
git@gitlab.com:my-org/backend.git |
gitlab.com |
my-org |
backend |
~/Code/gitlab.com/my-org/backend |
viko16/gitcd.plugin.zsh (Shorthand) |
github.com |
viko16 |
gitcd.plugin.zsh |
~/Code/github.com/viko16/gitcd.plugin.zsh |
When the user asks to clone or download a repo:
- Parse the URL: Identify the Host, User, and Repo components based on the table above. If shorthand (
user/repo) is provided, assumegithub.comand HTTPS. - Construct the Command: Generate a single-line Bash command that performs an idempotent check before cloning.
Do not run a simple git clone. You MUST use the following logic to prevent errors if the folder exists:
# Template (Replace placeholders)
TARGET_DIR="~/Code/<Host>/<User>/<Repo>"
if [ ! -d "$TARGET_DIR" ]; then
echo "Cloning into structured path..."
git clone "<URL>" "$TARGET_DIR"
else
echo "Repository already exists at $TARGET_DIR"
fi
- Execute: Run the generated command using your Bash tool.
- Report: Inform the user of the absolute path where the code is located.
User: "Clone this repo https://github.com/viko16/gitcd.plugin.zsh"
Model Reasoning:
- URL inferred:
https://github.com/viko16/gitcd.plugin.zsh - Host:
github.com, User:viko16, Repo:gitcd.plugin.zsh - Target:
~/Code/github.com/viko16/gitcd.plugin.zsh
Action (Bash):
target="~/Code/https://github.com/viko16/gitcd.plugin.zsh"
if [ ! -d "$target" ]; then
git clone https://github.com/viko16/gitcd.plugin.zsh.git "$target"
else
echo "Repo exists at $target"
fi