commit-codelisted
Install: claude install-skill abdullahkhawer/devops-skills
# Commit Code Skill
Run this skill when asked to commit code changes, create a commit message, or push changes to a new branch.
## Step 1 — Collect input
Ask the user the following question:
```
Kindly let me know:
1. Branch Name: What should I name the new branch? (name of the branch)
```
If the user has already provided the answer upfront, skip the question and use the provided value.
---
## Step 2 — Create a new branch
```bash
git checkout -b <BRANCH_NAME>
```
---
## Step 3 — Run pre-commit checks (if .pre-commit-config.yaml exists)
```bash
pre-commit run -a
```
If the command fails, try again only one more time. If it fails again, report the output to the user and stop. Do not continue until the user resolves any failures.
---
## Step 4 — Run Terraform formatting (if Terraform files exist)
```bash
terraform fmt -recursive
```
---
## Step 5 — Stage all changes, analyze them and commit
```bash
git add .
```
Before proceeding, list the staged files and check for potentially sensitive files (e.g. `.env`, `*.pem`, `*.key`, `*credentials*`, `*secret*`, `*token*`, `*password*`):
```bash
git diff --cached --name-only
```
If any staged file matches a sensitive pattern, pause and ask the user to confirm whether it should be included in the commit. Do not proceed until confirmed.
And then analyze the code changes in each staged file with the following command:
```bash
git diff --cached -- <FILE_PATH>
```
Then based on all the code changes, determine the appr