Commit

From nudgebee/nudgebee · View interactive version

Commit is an AI agent skill from the GitHub repository nudgebee/nudgebee. Smart commit — detect affected services, run validation, commit with proper format

How to use this skill

Skill file

Smart Commit

Create a validated commit with proper service-scoped message format. Optional argument: $ARGUMENTS (commit message override).

Step 1: Detect Changed Files

# Staged changes
git diff --cached --name-only

# Unstaged changes (for reference)
git diff --name-only

# Untracked files
git ls-files --others --exclude-standard

If nothing is staged, show the user what's unstaged/untracked and ask what to stage.

Step 2: Map Changes to Services

Map every changed file to its service:

| Path prefix | Service | Type | Validation | Working directory |

|---|---|---|---|---|

| api-server/services/ | api-server | Go | make validate | api-server/services/ |

| ticket-server/ | ticket-server | Go | make validate | ticket-server/ |

| collector-server/cloud-collector/ | cloud-collector | Go | make validate | collector-server/cloud-collector/ |

| collector-server/k8s-collector/relay-server/ | relay-server | Go | make validate | collector-server/k8s-collector/relay-server/ |

| collector-server/k8s-collector/app/ | k8s-collector-app | Python | make lint && make test | collector-server/k8s-collector/app/ |

| llm/code-analysis/ | code-analysis | Go | make check | llm/code-analysis/ |

| llm/llm-server/ | llm-server | Go | make validate | llm/llm-server/ |

| llm/rag-server/ | rag-server | Python | make lint && make test | llm/rag-server/ |

| llm/benchmark/ | benchmark | Python | poetry run pytest | llm/benchmark/ |

| ml-k8s-server/ | ml-k8s-server | Python | make lint && make test | ml-k8s-server/ |

| auto-pilot/ | auto-pilot | Python | poetry run black --check . && poetry run flake8 . | auto-pilot/ |

| auto-pilot/sidecar/ | auto-pilot-sidecar | Python | poetry run black --check . && poetry run flake8 . | auto-pilot/sidecar/ |

| notifications-server/ | notifications-server | Python | uv run black --check . && uv run flake8 . | notifications-server/ |

| app/ | frontend | TypeScript | npm run lint2 | app/ |

| deploy/ | infrastructure | — | — | — |

| .github/ | ci | — | — | — |

Step 3: Run Validation for Each Affected Service

For each affected service, run its validation command. Report results as a table:

| Service | Validation | Status |
|---------|-----------|--------|
| api-server | make validate | PASS/FAIL |

If any validation fails:

Step 4: Generate Commit Message

If $ARGUMENTS is provided, use it as the commit subject but still prepend the semantic type and scope.

Format: type(scope): subject (per .github/semantic.yml)

Allowed types:

| Type | Use when |

|---|---|

| feat | New feature or functionality |

| fix | Bug fix |

| docs | Documentation only |

| style | Formatting, whitespace, no code change |

| refactor | Code restructure, no behavior change |

| perf | Performance improvement |

| test | Adding or updating tests only |

| chore | Maintenance, deps, config |

| revert | Reverting a previous commit |

| ci | CI/CD workflow changes |

| infra | Infrastructure, Helm, K8s changes |

| release | Release-related changes |

Allowed scopes (required):

| Scope | Services / paths |

|---|---|

| ui | app/ (frontend) |

| autopilot | auto-pilot/, auto-pilot/sidecar/ |

| ml | ml-k8s-server/ |

| llm | ml-k8s-server/, llm/code-analysis/, llm/llm-server/, llm/rag-server/, llm/benchmark/ |

| workflow | workflow-server/ |

| notifications | notifications-server/ |

| tickets | ticket-server/ |

| relay | collector-server/k8s-collector/relay-server/ |

| collector | collector-server/cloud-collector/, collector-server/k8s-collector/app/ |

| deps | Dependency updates |

| NB-xxx | Ticket number — use for api-server/services/, api-server/migrations/, deploy/, .github/, or any cross-service change |

Rules:

If no $ARGUMENTS, analyze the diff to generate an appropriate message. Present the proposed message to the user for confirmation before committing.

Step 5: Stage and Commit

IMPORTANT — Single commit per PR policy (main branch only): PRs targeting main MUST have exactly one commit. This does NOT apply to branches targeting test or prod (cherry-picks / promotions) — those can have multiple commits.

NEVER use git add -A or git add . — always add specific files:

git add <specific files>

Then determine the base branch and commit count:

# Detect base branch (default: main)
BASE_BRANCH="main"
COMMIT_COUNT=$(git log origin/${BASE_BRANCH}..HEAD --oneline 2>/dev/null | wc -l | tr -d ' ')

For branches targeting main, enforce single commit:

if [ "$COMMIT_COUNT" -eq 0 ]; then
  # First commit on this branch
  git commit -m "type(scope): subject"
elif [ "$COMMIT_COUNT" -eq 1 ]; then
  # Amend the existing single commit
  git commit --amend --no-edit  # or with -m "..." to update the message
else
  # Multiple commits exist — squash all into one
  git reset --soft origin/${BASE_BRANCH}
  git commit -m "type(scope): subject"
fi

For branches targeting test or prod, just commit normally — no amend/squash.

Step 6: Output Summary

Committed: type(scope): subject
  {N} files changed, {A} insertions(+), {D} deletions(-)
  Services: {list}
  Validation: all passed
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.