Analyzes recently modified code and creates pull requests with simplifications that improve clarity, consistency, and maintainability while preserving functionality
npx skills add https://github.com/Azure/azqr --skill code-simplifier
Expert guidance for analyzing and simplifying recently modified code to improve clarity, consistency, and maintainability while preserving exact functionality.
This skill enables agents to:
Use this skill when:
Avoid over-simplification that could:
Identify files modified in the last 24 hours from all sources:
Option A: Local File Changes (filesystem-based)
# Find files modified in the last 24 hours (includes uncommitted changes)
find . -type f -mtime -1 -not -path './.git/*' -not -path './node_modules/*' -not -path './vendor/*'
# Or using git to find modified files (staged and unstaged)
git status --porcelain
# Find recently modified tracked files
git diff --name-only HEAD~10 # Adjust based on commit frequency
Option B: Git History (committed changes)
# Get yesterday's date in ISO format
YESTERDAY=$(date -d '1 day ago' '+%Y-%m-%d' 2>/dev/null || date -v-1d '+%Y-%m-%d')
# List recent commits
git log --since="24 hours ago" --pretty=format:"%H %s" --no-merges
# List files changed in recent commits
git log --since="24 hours ago" --name-only --pretty=format:"" | sort -u
Option C: GitHub PRs and Commits (remote changes)
Use GitHub tools to:
Combine all sources to get a comprehensive list of recently modified files.
From all identified sources (local changes, commits, PRs):
.go, .js, .ts, .tsx, .jsx, .py, .rb, .java, .cs, .php, .cpp, .c, .rs, etc.)# Example: Combine filesystem and git changes, filter source files
{
find . -type f -mtime -1 -not -path './.git/*' 2>/dev/null
git log --since="24 hours ago" --name-only --pretty=format:"" 2>/dev/null
git diff --name-only 2>/dev/null
} | sort -u | grep -E '\.(go|js|ts|tsx|jsx|py|rb|java|cs|php|cpp|c|rs)$'
If no files were changed in the last 24 hours (no local modifications, no commits, no merged PRs), exit gracefully:
✅ No code changes detected in the last 24 hours.
Code simplifier has nothing to process today.
If files were changed (from any source: local edits, commits, or PRs), proceed to Phase 2.
Before simplifying, review the project's coding standards:
STYLE.md, CONTRIBUTING.md, README.md)For each changed file:
Make surgical, focused changes that preserve all original behavior. Use targeted edits rather than full file rewrites.
After making simplifications, run the project's test suite:
# Common test commands (adapt to the project)
make test # If Makefile exists
npm test # For Node.js projects
pytest # For Python projects
./gradlew test # For Gradle projects
mvn test # For Maven projects
cargo test # For Rust projects
go test ./... # For Go projects
If tests fail:
Ensure code style is consistent:
# Common lint commands (adapt to the project)
make lint # If Makefile exists
npm run lint # For Node.js projects
pylint . || flake8 . # For Python projects
cargo clippy # For Rust projects
golangci-lint run # For Go projects
Fix any linting issues introduced by the simplifications.
Verify the project still builds successfully:
# Common build commands (adapt to the project)
make build # If Makefile exists
npm run build # For Node.js projects
./gradlew build # For Gradle projects
mvn package # For Maven projects
cargo build # For Rust projects
go build ./... # For Go projects
Only create a PR if:
If no improvements were made or changes broke tests, exit gracefully:
✅ Code analyzed from last 24 hours.
No simplifications needed - code already meets quality standards.
Use this structure for the PR:
## Code Simplification - [Date]
This PR simplifies recently modified code to improve clarity, consistency, and maintainability while preserving all functionality.
### Files Simplified
- `path/to/file1.ext` - [Brief description of improvements]
- `path/to/file2.ext` - [Brief description of improvements]
### Improvements Made
1. **Reduced Complexity**
- [Specific example]
2. **Enhanced Clarity**
- [Specific example]
3. **Applied Project Standards**
- [Specific example]
### Changes Based On
Recent changes from:
- #[PR_NUMBER] - [PR title]
- Commit [SHORT_SHA] - [Commit message]
### Testing
- ✅ All tests pass (or indicate if no tests exist)
- ✅ Linting passes (or indicate if no linter configured)
- ✅ Build succeeds (or indicate if no build step)
- ✅ No functional changes - behavior is identical
### Review Focus
Please verify:
- Functionality is preserved
- Simplifications improve code quality
- Changes align with project conventions
- No unintended side effects
---
*Automated by Code Simplifier Agent*
// Before
func process(data []Item) error {
if data != nil {
if len(data) > 0 {
for _, item := range data {
if item.Valid {
// process
}
}
}
}
return nil
}
// After
func process(data []Item) error {
if len(data) == 0 {
return nil
}
for _, item := range data {
if !item.Valid {
continue
}
// process
}
return nil
}
// Before
const status = isError ? 'error' : isLoading ? 'loading' : isSuccess ? 'success' : 'idle';
// After
let status;
if (isError) {
status = 'error';
} else if (isLoading) {
status = 'loading';
} else if (isSuccess) {
status = 'success';
} else {
status = 'idle';
}
# Before
def validate_user(user):
if user.name is None:
return False
if len(user.name) == 0:
return False
if user.email is None:
return False
if '@' not in user.email:
return False
return True
# After
def validate_user(user):
if not user.name:
return False
if not user.email or '@' not in user.email:
return False
return True
// Before
func calc(d []int) int {
t := 0
for _, v := range d {
t += v
}
return t
}
// After
func calculateSum(values []int) int {
total := 0
for _, value := range values {
total += value
}
return total
}
Exit gracefully without creating a PR if:
Before creating a PR, verify:
The agent MUST either:
Execute git commit with conventional commit message analysis, intelligent staging, and message generation. Use when user asks to commit changes, create a git commit, or mentions "/commit". Supports: (1) Auto-detecting type and scope from changes, (2) Generating conventional commit messages from diff, (3) Interactive commit with optional type/scope/description overrides, (4) Intelligent file staging for logical grouping
Comprehensive GitHub code review with AI-powered swarm coordination
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.
Comprehensive truth scoring, code quality verification, and automatic rollback system with 0.95 accuracy threshold for ensuring high-quality agent outputs and codebase reliability.
GitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, projects, releases, gists, codespaces, organizations, extensions, and all GitHub operations from the command line.
GitHub CLI - manage repositories, issues, pull requests, actions, releases, and more from the command line.
You are a code refactoring expert specializing in clean code principles, SOLID design patterns, and modern software engineering best practices. Analyze and refactor the provided code to improve its quality, maintainability, and performance.
You are a technical debt expert specializing in identifying, quantifying, and prioritizing technical debt in software projects. Analyze the codebase to uncover debt, assess its impact, and create acti
Take azure/code-simplifier from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.