Catalogue / secure-commit-grouping
secure-commit-grouping
Older skill: source not recordedSignedAudits the actual Git index for secrets and oversized blobs, groups working-tree and staged changes into cohesive Conventional Commits, and executes them with explicit staging and push scope. Use when the user says "commit these changes", "split my work into commits", "check nothing sensitive is sta…--- name: secure-commit-grouping description: >- Audits the actual Git index for secrets and oversized blobs, groups working-tree and staged changes into cohesive Conventional Commits, and executes them with explicit staging and push scope. Use when the user says "commit these changes", "split my work into commits", "check nothing sensitive is staged", "write conventional commit messages", or "commit and push this branch". Not for rewriting history, bypassing hooks, or treating "save" as consent to publish. ---
Commit the reviewed intent, not an accidental staging bundle
Analyze changes and security before proposing ordered commits.
- Preserve the user's existing staging decisions, unrelated work and history.
- A commit request may already authorize the exact local commit scope.
- It never authorizes unrelated file edits, a push to an unspecified remote, or
a destructive repair.
Confirmation
- Read local status, diffs, manifests and the index within the request.
- Explicit user instructions authorize their exact action and scope, including a
specifically requested local commit or push.
- Confirm before: additional staging/unstaging, grouping that changes the
requested scope, ignore-file edits, branch creation, commits, hooks with external effects, remote fetch/push, or history changes — unless already authorized for those exact paths, branch and remote.
- Do not ask again for unchanged authorized actions.
- If "save changes" is ambiguous, prepare the plan without guessing that it
means publish.
- Never delete files as an automatic fix.
Inspect repository state and actual content
Use bounded read-only status and diff inspection:
- Cover staged versus unstaged hunks, untracked candidates, deletions, renames
and submodules.
- Prefer machine-readable NUL-delimited output (
git status --porcelain=v1 -z):
a path can contain spaces, newlines or begin with a dash. Never parse human display columns naively.
- Detect merge/rebase conflicts, detached HEAD, unborn branches and existing
hooks. Stop mutating work until conflict resolution is explicitly scoped.
- Compare the local branch with already-available tracking refs if relevant;
stale refs do not prove remote status.
- Fetch/pull is a distinct network action. A behind branch does not justify an
automatic pull/rebase.
Read the actual diffs to understand behavior, not just filenames:
- Classify new, modified, added, deleted and renamed paths, plus staged and
working-tree divergence.
- Audit index blobs rather than on-disk files: a clean working copy can conceal
a secret already staged, and a secret in the working copy may not be in the planned commit.
- Untracked files need a separate candidate scan before approved staging.
- Do not silently reset or overwrite existing partial staging.
Complete index audit helper
This Python standard-library helper performs read-only Git queries. It prints only path/rule metadata, never secret matches.
- It does not stage, edit ignore files, commit, contact remotes or run hooks.
- Save and run it only within an authorized local audit scope.
python index_audit.py --repository PATHexits 0 for no findings, 1 for
warnings, 2 for critical findings or audit failure; --strict raises warnings to blocking.
- Size limits are explicit configurable policy inputs, not hosting-provider
assertions; the defaults are an illustrative repository policy.
import argparse
import json
import pathlib
import re
import subprocess
import sys
RULES = {
'private-key': re.compile(rb'-----BEGIN (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----'),
'cloud-access-key': re.compile(rb'AKIA[A-Z0-9]{16}'),
'provider-token': re.compile(rb'sk-(?:ant-)?[A-Za-z0-9_-]{24,}'),
'credential-assignment': re.compile(rb"(?i)(?:api[_-]?key|api[_-]?secret|password|passwd|auth[_-]?token|access[_-]?token|secret)\s*[:=]\s*['\"][^'\"]{12,}['\"]"),
'credential-uri': re.compile(rb'(?i)(?:postgres(?:ql)?|mysql|mongodb(?:\+srv)?|redis)://[^/\s:@]+:[^/\s@]+@'),
'long-literal': re.compile(rb"['\"][A-Za-z0-9+/=_-]{64,}['\"]"),
}
SENSITIVE = {'.pem', '.key', '.p12', '.pfx', '.jks', '.keystore', '.credentials', '.secret', '.htpasswd'}
def audit_blob(path, blob, warning_bytes, strong_bytes, blocking_bytes):
findings = []
def add(level, rule): findings.append({'level': level, 'path': path, 'rule': rule})
name = pathlib.PurePosixPath(path).name.lower()
suffix = pathlib.PurePosixPath(path).suffix.lower()
if suffix in SENSITIVE or name in {'id_rsa', 'id_ed25519'} or (name.startswith('.env') and name != '.env.example'):
add('critical', 'sensitive-path')
if len(blob) > blocking_bytes: add('critical', 'size-policy')
elif len(blob) > strong_bytes: add('warning', 'large-artifact')
elif len(blob) > warning_bytes: add('warning', 'size-review')
for rule, pattern in RULES.items():
if pattern.search(blob): add('warning' if rule == 'long-literal' else 'critical', rule)
if suffix == '.sql' and re.search(rb'(?im)^\s*(?:INSERT\s+INTO|COPY\s+\S+.*FROM\s+stdin)', blob):
add('critical', 'possible-data-dump')
if b'\x00' in blob and suffix not in {'.png', '.jpg', '.jpeg', '.gif', '.ico', '.woff', '.woff2', '.ttf'}:
add('warning', 'unexpected-binary')
if re.search(rb'(?i)(?:TODO|FIXME|HACK)[^\n]{0,160}(?:password|secret|auth|token|credential)', blob):
add('warning', 'security-todo')
if re.search(rb'(?i)(?:verify\s*=\s*False|SSL_VERIFY[^\n]{0,40}false|insecure[^\n]{0,20}true|disable[^\n]{0,20}auth)', blob):
add('warning', 'security-disabled-review')
if re.search(rb'https?://localhost:\d+', blob): add('warning', 'local-endpoint-review')
if name in {'.npmrc', '.pypirc', '.htaccess'}: add('warning', 'authentication-config-review')
return findings
def git(repository, *arguments, stdin=None):
completed = subprocess.run(['git', '-C', str(repository), *arguments], input=stdin,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
if completed.returncode != 0: raise RuntimeError('Read-only Git query failed')
return completed.stdout
def inspect(repository, warning_bytes, strong_bytes, blocking_bytes):
if not (0 < warning_bytes < strong_bytes < blocking_bytes):
raise ValueError('Ordered positive size policy required')
git(repository, 'rev-parse', '--show-toplevel')
paths = git(repository, 'diff', '--cached', '--name-only', '-z', '--diff-filter=ACMR').split(b'\0')
changed = {p for p in paths if p}
entries = {}
conflict = False
for entry in git(repository, 'ls-files', '--stage', '-z').split(b'\0'):
if not entry: continue
metadata, raw_path = entry.split(b'\t', 1)
mode, object_id, stage = metadata.split()
if stage != b'0': conflict = True
else: entries[raw_path] = (mode, object_id)
findings = []
if conflict: findings.append({'level': 'critical', 'path': None, 'rule': 'unresolved-index'})
for raw_path in sorted(changed):
display = raw_path.decode('utf-8', errors='backslashreplace')
if raw_path not in entries:
findings.append({'level':'critical','path':display,'rule':'index-entry-missing'}); continue
mode, object_id = entries[raw_path]
if mode == b'160000':
findings.append({'level':'warning','path':display,'rule':'submodule-pointer-review'}); continue
size = int(git(repository, 'cat-file', '-s', object_id.decode('ascii')).strip())
if size > blocking_bytes:
findings.append({'level':'critical','path':display,'rule':'size-policy'}); continue
blob = git(repository, 'cat-file', 'blob', object_id.decode('ascii'))
findings.extend(audit_blob(display, blob, warning_bytes, strong_bytes, blocking_bytes))
if mode == b'120000': findings.append({'level':'warning','path':display,'rule':'symlink-target-review'})
probes = ['.env', 'probe-private.pem', 'probe-private.key', 'node_modules/probe', '__pycache__/probe.pyc', '.DS_Store']
# check-ignore returns 1 when nothing is ignored: this is a valid query outcome.
completed = subprocess.run(['git','-C',str(repository),'check-ignore','--no-index','--stdin','-z'],
input=('\0'.join(probes)+'\0').encode(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if completed.returncode not in {0,1}: raise RuntimeError('Ignore query failed')
ignored = {p.decode() for p in completed.stdout.split(b'\0') if p}
for path in probes:
if path not in ignored: findings.append({'level':'warning','path':path,'rule':'ignore-policy-review'})
return {'stagedPathCount':len(changed),'findings':findings,
'limitations':['Regex scans are incomplete and may flag fixtures','Only added/modified/renamed index blobs scanned',
'Deleted paths and untracked/unstaged candidates need separate scope review','No commit or remote operation performed']}
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--repository', type=pathlib.Path, default=pathlib.Path('.'))
parser.add_argument('--warning-mib', type=int, default=16)
parser.add_argument('--strong-mib', type=int, default=64)
parser.add_argument('--blocking-mib', type=int, default=128)
parser.add_argument('--strict', action='store_true')
args = parser.parse_args()
try:
report = inspect(args.repository, *(v * 1048576 for v in [args.warning_mib,args.strong_mib,args.blocking_mib]))
print(json.dumps(report, indent=2))
levels = {f['level'] for f in report['findings']}
return 2 if 'critical' in levels or (args.strict and 'warning' in levels) else 1 if levels else 0
except (OSError, RuntimeError, ValueError) as error:
print(json.dumps({'error':type(error).__name__,'message':'Index audit could not complete'}), file=sys.stderr)
return 2
if __name__ == '__main__': raise SystemExit(main())Reading the findings honestly:
- The long-literal rule is a warning because hashes and fixtures can look
secret-like; a sensitive-path hit needs human review of actual meaning. A public certificate or placeholder example can be legitimate — a real key cannot.
- Never display matched content while investigating.
- A SQL file's length alone does not establish a data dump.
- A regex-clean scan does not prove the index safe. Use approved installed
scanners and manual review for higher assurance, without sending private blobs to external services.
- Audit expected binary assets for size and rights as well as extension; a
permitted image extension is not blanket approval.
Group changes by a coherent reviewable intent
Detect the actual stack from manifests and source boundaries — never assume a framework:
- Node manifests may indicate Next/React/Vue/Svelte/Angular or Express/Fastify.
- Python manifests may identify Django/Flask/FastAPI.
- Go, Rust, Java, Ruby, PHP, Elixir and Dart each have different module boundaries.
- Monorepo workspace/package configuration is stronger evidence than the mere
existence of a packages/ directory.
Use categories as aids, not mandatory commit splits:
| Concern | Typical inputs | |---|---| | Configuration/build | Manifest plus lockfile, compiler/linter settings, ignore policy, build scripts | | Types/schema | Interfaces/models, GraphQL/protobuf, migrations with their model changes | | Shared logic | Library/util/helper/common code plus consumers needed for compatibility | | Feature behavior | Routes/controllers/components/services and directly relevant tests/styles | | Styles/assets | Theme rules, approved images/fonts/static content and references | | Tests/docs | Behavior tests/fixtures, documentation/changelog and related implementation evidence | | Infrastructure/CI | Docker/Terraform/deployment/workflows and application compatibility |
Stack-specific groupings:
Preview shortened. The full SKILL.md is in the pack.
| File | Size | SHA-256 |
|---|---|---|
| SKILL.md | 18.5 kB | eb271136693d |
| examples.json | 1.9 kB | b183ceaa91fa |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 1.0.0 Current | Not recorded | 2 Oct 2026 |
Locking a skill to one version needs Pro.