preguito-skill

📁 jacodoisdois/preguito-skill 📅 10 days ago
2
总安装量
2
周安装量
#66860
全站排名
安装命令
npx skills add https://github.com/jacodoisdois/preguito-skill --skill preguito-skill

Agent 安装分布

opencode 2
claude-code 2
github-copilot 2
codex 2
kimi-cli 2
gemini-cli 2

Skill 文档

Preguito Skill

preguito (CLI name: guito) is a lazy Git CLI with commit templates and shortcode expansion. When working in a preguito project, always prefer guito commands over raw git equivalents.

Detecting a Preguito Project

A project uses preguito if any of these files exist:

  • .preguitorc (project root)
  • .preguitorc.json (project root)
  • ~/.config/preguito/config.json (global user config)

Before crafting a commit, read the config to discover the template and shortcodes:

cat .preguitorc 2>/dev/null || cat .preguitorc.json 2>/dev/null

Config Schema

{
  "template": "{{type}}: <message>",
  "features": {
    "cardId": false,
    "type": true,
    "environment": false
  },
  "types": [
    { "key": "f", "label": "feat" },
    { "key": "x", "label": "fix" },
    { "key": "c", "label": "chore" },
    { "key": "t", "label": "test" },
    { "key": "r", "label": "refactor" },
    { "key": "o", "label": "docs" }
  ],
  "environments": [],
  "defaults": {}
}

Key fields:

  • template — Mustache-style; {{var}} variables + <message> placeholder
  • features.cardId — If true, first positional arg to guito c is the card/ticket ID
  • features.type — If true, shortcodes arg must include exactly one type letter
  • features.environment — If true, shortcodes arg may include one environment letter
  • defaults — Merged into template context automatically (e.g. { "prefix": "PROJ" })

Template Rendering Rules

Variables use {{varname}} syntax. The <message> placeholder is replaced by the commit message. Optional variables that resolve to empty string trigger cleanup:

  • () → removed entirely
  • [] → removed entirely
  • {} → removed entirely
  • Multiple spaces → single space
  • Space before colon → removed: feat : msg → feat: msg

Common generated templates (from generateTemplate()):

Features enabled Template
type only {{type}}: <message>
cardId + type [{{card_id}}] {{type}}: <message>
cardId + prefix + type [{{prefix}}-{{card_id}}] {{type}}: <message>
type + environment {{type}}({{environment}}): <message>
cardId + type + environment [{{card_id}}] {{type}}({{environment}}): <message>
environment only ({{environment}}): <message>

Command Syntax: guito c

guito c [card_id] [shortcodes] <message...> [flags]

Positional argument order is strict and depends on enabled features:

  1. card_id — first arg, only if features.cardId is true (any string: "42", "PROJ-42")
  2. shortcodes — concatenated single string, only if features.type or features.environment is true
  3. message — everything remaining, joined with spaces (no quotes required for multiple words)

Flags

Flag Long Description
-p --push Push after committing
-f --force Push with --force-with-lease after committing
-d --dry-run Print generated message without executing
-S --no-stage Skip auto-staging (git add -A). By default, all changes are staged automatically

Shortcode Resolution

Each character in the shortcodes string is independently resolved:

  • Matches a types key → sets type in context
  • Matches an environments key → sets environment in context
  • Exactly one type shortcode required if features.type is true
  • At most one environment shortcode; environment is always optional
  • Character matching both type and env → ambiguity error
  • Character matching neither → unknown shortcode error

Default Type Shortcodes

Key Label When to use
f feat New feature or capability
x fix Bug fix
c chore Maintenance, deps, config
t test Adding or modifying tests
r refactor Code restructuring, no behavior change
o docs Documentation
l lint Linting fixes
y style Code style / formatting
e perf Performance improvement
b build Build system / scripts

Default Environment Shortcodes

Key Label
p prd
u uat
h homolog
d dev
s staging

Complete Examples by Feature Combination

Config: type only (default config)

guito c f "add user authentication"
# → feat: add user authentication

guito c x "fix null pointer in login" -p
# → fix: fix null pointer in login  (then pushes)

guito c r "extract service layer" -d
# dry-run → prints: refactor: extract service layer

Config: cardId + type

guito c 42 f "add user authentication"
# → [42] feat: add user authentication

guito c PROJ-123 r "extract service layer"
# → [PROJ-123] refactor: extract service layer

guito c 99 c "update dependencies" -p
# → [99] chore: update dependencies  (then pushes)

Config: cardId + type + environment

guito c 42 fp "deploy payment gateway"
# → [42] feat(prd): deploy payment gateway

guito c 77 xd "fix timeout bug" -p
# → [77] fix(dev): fix timeout bug  (then pushes)

guito c 10 fu "release to uat"
# → [10] feat(uat): release to uat

Config: type + environment (no cardId)

guito c fp "deploy login service"
# → feat(prd): deploy login service

guito c xs "fix staging crash"
# → fix(staging): fix staging crash

Config: cardId + prefix in defaults

{ "defaults": { "prefix": "TASK" }, "template": "[{{prefix}}-{{card_id}}] {{type}}: <message>" }
guito c 55 f "add export endpoint"
# → [TASK-55] feat: add export endpoint

All Other Commands

# Push
guito p                        # git push
guito pu                       # git push --set-upstream origin <branch>

# Rebase
guito r <branch>               # checkout branch → pull → rebase current onto it
guito ri <count>               # interactive rebase for last N commits
guito re <hash>                # edit rebase at specific commit hash

# Amend
guito ap                       # amend last commit + force push
guito apl                      # amend last commit + force-with-lease push

# Undo
guito u [count]                # soft reset last N commits, keep changes staged (default 1)

# Fixup
guito cf <hash>                # create fixup commit targeting hash [-p] [-f]

# Branch
guito sw <branch>              # switch to existing branch
guito sw -n <branch>           # create and switch to new branch

# Stash
guito st [-m "msg"]            # stash changes
guito stp                      # stash pop
guito stl                      # stash list

# Status / Diff
guito s                        # git status --short
guito d                        # diff [-s staged] [--stat] [-n name-only]

# Log / Search
guito l [count]                # compact oneline log (default 10)
guito f <keyword>              # search commits by message [-n number]
guito t <tag>                  # commits since tag [-a all reachable]

# Config / Init
guito cfg                      # show current config [--path] [--template]
guito i                        # interactive setup wizard
guito i --default              # write default config without prompts

How to Help Users Craft Commits

  1. Check if .preguitorc or .preguitorc.json exists
  2. Parse template and features from the config
  3. Determine what positional args are needed (cardId → shortcodes → message)
  4. Map the user’s description to the appropriate type shortcode
  5. Build the guito c invocation
  6. Always show dry-run first: guito c ... -d
  7. Execute when the user confirms

Common Mistakes to Avoid

  • NEVER use git commit -m "..." in preguito projects — always use guito c
  • NEVER use git push — use guito p
  • NEVER invent shortcodes — read from the config’s types array
  • NEVER separate shortcodes with spaces — f p is wrong, fp is correct
  • NEVER chain multiple types — fx means feat+fix which is invalid; one type only
  • Shortcodes arg is one concatenated string: fp not f p
  • Auto-staging is ON by default — no need to git add before guito c unless using -S