finalize-and-commit

Finalize code changes for production readiness by removing duplicate logic, auditing hardcoded values, verifying build integrity, and structuring clean commits with Conventional Commits format.

25 stars

Best use case

finalize-and-commit is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Finalize code changes for production readiness by removing duplicate logic, auditing hardcoded values, verifying build integrity, and structuring clean commits with Conventional Commits format.

Teams using finalize-and-commit should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/finalize-and-commit/SKILL.md --create-dirs "https://raw.githubusercontent.com/ComeOnOliver/skillshub/main/skills/comsky/remy-skill-recipes/finalize-and-commit/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/finalize-and-commit/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How finalize-and-commit Compares

Feature / Agentfinalize-and-commitStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Finalize code changes for production readiness by removing duplicate logic, auditing hardcoded values, verifying build integrity, and structuring clean commits with Conventional Commits format.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Skill: Finalize Changes and Commit (Cleanup, Deduplication, Hardcoded Audit)

**Type:** Execution

## Purpose

Finalize current changes for production readiness.

Tasks:

- Remove duplicate logic
- Eliminate unnecessary code
- Audit and resolve hardcoded values
- Ensure consistency and build integrity
- Prepare structured commits

---

## When to Use

- Before committing finalized work to a shared branch
- Before submitting a pull request for review
- After completing a refactoring session that touched multiple files
- When preparing a clean commit history from messy working changes

---

## When NOT to Use

- Work-in-progress code that is still actively being developed
- Trivial single-line fixes (typo, formatting) that need no audit
- Initial prototyping or exploratory coding phases
- Changes already reviewed and approved through another skill

---

## Inputs Required

Do not run this skill without:

- [ ] Working tree with uncommitted or staged changes
- [ ] Access to project build, lint, and test commands
- [ ] Knowledge of project commit conventions (if any)

Optional but recommended:

- [ ] Target branch context (e.g., main, release)
- [ ] List of intended change scope (files or modules)

---

## Output Format

1. Issues Found
2. Actions Taken
3. Verification Results
4. Commit Plan
5. Final Commit Messages

---

## Procedure

### Gate 0 – Working Set Validation

> **CRITICAL:** The working tree may contain changes from other agent sessions
> or manual edits. This gate must isolate *only* the current session's changes
> without disturbing anything else.

**Step 0-1: Identify current session scope**

- Review the conversation history and edit history of this session.
- Build an explicit list of files that were created, modified, or deleted
  *by this session*.
- If the user provided a scope list (files or modules), use that as the
  authoritative source.

**Step 0-2: Inspect full working tree state**

- Run `git status` and `git diff --name-only` to enumerate all uncommitted
  changes in the working tree.

**Step 0-3: Classify changes**

- **In-scope:** Files that appear in both the session scope (Step 0-1)
  and the working tree (Step 0-2).
- **Out-of-scope:** Files that appear in the working tree but were NOT
  modified by this session. These may belong to other agent sessions,
  manual edits, or background tooling.

**Step 0-4: Protect out-of-scope changes**

- **NEVER** revert, restore, checkout, stash, or discard out-of-scope changes.
- Out-of-scope files must be left exactly as they are in the working tree.
- The only correct action is to *exclude* them from staging (`git add`).

**Step 0-5: Confirm with the user**

- Present a summary to the user:
  - Files to be committed (in-scope)
  - Files left untouched (out-of-scope), if any
- Proceed only after the user confirms the commit target set.
- Validate that new/deleted in-scope files do not break entrypoints.

---

### Gate 1 – Duplicate & Dead Code Detection

> **SCOPING RULE:** Focus analysis on **in-scope files only** (from
> Gate 0). When checking for duplicates, search for similar patterns
> in the immediate module/directory first, then expand to adjacent
> modules only if duplication signals are found.

- Identify repeated logic blocks
  - If repeated ≥ 3 times → extract helper
  - Avoid over-abstraction
- Remove:
  - Unused variables
  - Dead branches
  - Debug prints
  - Stale TODOs without references

---

### Gate 2 – Hardcoded Value Audit

> **SCOPE ADJUSTMENT:** If all in-scope changes are limited to test
> files, documentation, or type definitions, perform a quick scan
> (search for numeric literals and string constants in the diff)
> instead of a full classification audit. The full audit is required
> when production logic files are in scope.

Classify hardcoded values into:

A) Algorithmic constants → Extract to named constant + documentation  
B) Operational policies → Move to config/env + default fallback  
C) Test-only values → Restrict to test scope

Ensure:

- No hidden policy decisions remain hardcoded
- Retry limits, timeouts, thresholds are explicit

---

### Gate 3 – Consistency & Quality Review

Verify:

- Error handling patterns consistent
- Logging structure aligned with project conventions
- No PII/secrets exposed
- Public interface compatibility preserved
- No accidental performance regression

---

### Gate 4 – Verification Proof

Run relevant project checks:

- Tests
- Lint
- Typecheck
- Build

If failures occur:

- Fix root cause
- Do not silence or bypass checks

---

### Gate 5 – Commit Structuring

**Staging rule:** Stage only in-scope files confirmed in Gate 0.
Use `git add <specific-file>` for each file individually.
Never use `git add .`, `git add -A`, or `git add --all`.

Separate commits logically:

1. Refactor (no behavior change)
2. Functional change
3. Tests / documentation

Use Conventional Commits:

- fix(scope):
- feat(scope):
- refactor(scope):
- test(scope):
- docs(scope):
- chore(scope):

Each commit must explain:

- What changed
- Why it changed
- Risk considerations (if any)
- Test proof

---

## Guardrails

- Do not silence or bypass failing checks.
- Do not combine unrelated changes in a single commit.
- Do not over-abstract when extracting helpers (repeated ≥ 3 times threshold).
- Explicitly state assumptions when classifying hardcoded values.
- If context is insufficient to determine intent, ask for clarification.
- Do not remove code without verifying it is truly unused.
- Respect existing project conventions for commit messages and structure.
- **NEVER** use `git checkout -- <file>`, `git restore`, `git stash`, `git reset --hard`,
  or any other command that discards or reverts uncommitted changes to files
  outside the current session's scope. Other sessions or agents may own those changes.
- **NEVER** use `git add .`, `git add -A`, or `git add --all`. Always stage files
  individually with `git add <specific-file>` to avoid accidentally including
  out-of-scope changes.
- Working tree changes from other sessions, agents, or manual edits must be
  left completely untouched.

---

## Failure Patterns

Common bad outputs:

- Lumping all changes into a single large commit without logical separation
- Skipping build/lint/test verification before committing
- Ignoring hardcoded values because they "look fine"
- Over-extracting helpers for code repeated only once or twice
- Removing code that appears dead but is used via reflection or dynamic imports
- Producing commit messages that describe "what" but not "why"
- Reverting or discarding uncommitted changes that belong to other sessions or agents
- Using `git add .` or `git add -A` which accidentally stages out-of-scope changes
- Treating "ensure no unintended changes" as "revert unrelated files" instead of "exclude from staging"

---

## Example 1 (Minimal Context)

**Input:**

3 files changed: a utility function was refactored, an unused import was found, and a debug `console.log` was left in.

**Output:**

1. Issues Found: unused import in `utils/parse.ts`, debug log in `api/handler.ts`
2. Actions Taken: removed unused import, removed debug log
3. Verification Results: lint pass, tests pass, build pass
4. Commit Plan: single refactor commit (scope is small)
5. Final Commit Messages: `refactor(utils): clean up unused import and debug log`

---

## Example 2 (Realistic Scenario)

**Input:**

12 files changed across 3 modules. Includes a retry timeout hardcoded as `3000`, duplicated validation logic in 4 handlers, and a new API endpoint.

**Output:**

1. Issues Found: hardcoded retry timeout (3000ms) in `services/retry.ts`, duplicated input validation in 4 route handlers, unused helper `formatLegacy` in `utils/format.ts`
2. Actions Taken: extracted retry timeout to config (`RETRY_TIMEOUT_MS`), created shared `validateInput()` helper, removed `formatLegacy`
3. Verification Results: all tests pass, lint pass, typecheck pass, build pass
4. Commit Plan: 3 commits — (a) refactor: extract shared validation, (b) refactor: move retry timeout to config, (c) feat: add new API endpoint
5. Final Commit Messages:
   - `refactor(validation): extract shared validateInput helper from route handlers`
   - `refactor(retry): move hardcoded timeout to config as RETRY_TIMEOUT_MS`
   - `feat(api): add POST /items endpoint with input validation`

---

## Notes

**FAST MODE** (only if explicitly requested):

- Skip deep hardcoded classification
- Allow single commit only if scope is small

Related Skills

pre-commit-hook-setup

25
from ComeOnOliver/skillshub

Pre Commit Hook Setup - Auto-activating skill for DevOps Basics. Triggers on: pre commit hook setup, pre commit hook setup Part of the DevOps Basics skill category.

generating-smart-commits

25
from ComeOnOliver/skillshub

This skill generates conventional commit messages using AI analysis of staged Git changes. It automatically determines the commit type (feat, fix, docs, etc.), identifies breaking changes, and formats the message according to conventional commit standards. Use this when asked to create a commit message, write a Git commit, or when the user uses the `/commit-smart` or `/gc` command. It is especially useful after changes have been staged with `git add`.

generating-conventional-commits

25
from ComeOnOliver/skillshub

Execute generates conventional commit messages using AI. It analyzes code changes and suggests a commit message adhering to the conventional commits specification. Use this skill when you need help writing clear, standardized commit messages, especially a... Use when managing version control. Trigger with phrases like 'commit', 'branch', or 'git'.

commit-message-formatter

25
from ComeOnOliver/skillshub

Commit Message Formatter - Auto-activating skill for DevOps Basics. Triggers on: commit message formatter, commit message formatter Part of the DevOps Basics skill category.

conventional-commit

25
from ComeOnOliver/skillshub

Prompt and workflow for generating conventional commit messages using a structured XML format. Guides users to create standardized, descriptive commit messages in line with the Conventional Commits specification, including instructions, examples, and validation.

github-commit-recovery

25
from ComeOnOliver/skillshub

Recover deleted commits from GitHub using REST API, web interface, and git fetch. Use when you have commit SHAs and need to retrieve actual commit content, diffs, or patches. Includes techniques for accessing "deleted" commits that remain on GitHub servers.

docs-finalize-and-commit

25
from ComeOnOliver/skillshub

Finalize documentation changes for production readiness by discovering existing conventions, verifying code-doc alignment, reviewing format/terminology/tone consistency, and structuring clean commits. Counterpart of finalize-and-commit for documentation projects.

commit-work

25
from ComeOnOliver/skillshub

Create high-quality git commits: review/stage intended changes, split into logical commits, and write clear commit messages (including Conventional Commits). Use when the user asks to commit, craft a commit message, stage changes, or split work into multiple commits.

backend-atomic-commit

25
from ComeOnOliver/skillshub

Pedantic backend pre-commit and atomic commit Skill for Django/Optimo-style repos. Enforces local AGENTS.md / CLAUDE.md, pre-commit hooks, .security/* helpers, and Monty’s backend engineering taste – with no AI signatures in commit messages.

commit-message-generator

25
from ComeOnOliver/skillshub

Generate appropriate commit messages based on Git diffs

making-commits

25
from ComeOnOliver/skillshub

Guidelines on makign git commits

pre-commit-check

25
from ComeOnOliver/skillshub

コミット前品質チェックスキル(Lint、テスト、ビルドの高速検証)