From c63dc8563ef2e7cbfe57c8cf7e4912b1ff3aa75c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 13 Feb 2026 02:00:09 +0000 Subject: [PATCH 1/2] Fix workflow documentation issues - Remove duplicate instruction in daily-progress.md - Fix incorrect step references in daily-perf-improver.md (steps 3-4, not 2d-2e) - Improve clarity in daily-test-improver.md (remove awkward 'worked out' repetition) - Fix grammar in issue-triage.md (hyphenate 'one-sentence' as compound adjective) --- workflows/daily-perf-improver.md | 2 +- workflows/daily-progress.md | 2 -- workflows/daily-test-improver.md | 2 +- workflows/issue-triage.md | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/workflows/daily-perf-improver.md b/workflows/daily-perf-improver.md index 9b914d5..0025d30 100644 --- a/workflows/daily-perf-improver.md +++ b/workflows/daily-perf-improver.md @@ -126,7 +126,7 @@ To decide which phase to perform: - Success metrics and testing approaches - How to do explore performance efficiently using focused, maximally-efficient measurements and rebuilds -5. Create PR with title "${{ github.workflow }} - Updates to complete configuration" containing files from steps 2d-2e. Request maintainer review. +5. Create PR with title "${{ github.workflow }} - Updates to complete configuration" containing files from steps 3-4. Request maintainer review. **Include a "What Happens Next" section in the PR description that explains:** - Once this PR is merged, the next workflow run will proceed to Phase 3, where actual performance improvements will be implemented diff --git a/workflows/daily-progress.md b/workflows/daily-progress.md index ddb11e9..61e3f32 100644 --- a/workflows/daily-progress.md +++ b/workflows/daily-progress.md @@ -64,8 +64,6 @@ To decide which phase to perform: - Features can include documentation, code, tests, examples, communication plans and so on - If you find a relevant roadmap document, read it carefully and use it to inform your understanding of the project's feature goals -2. Use this research to create a discussion with title "${{ github.workflow }} - Research, Roadmap and Plan". - 2. Use this research to create a discussion with title "${{ github.workflow }} - Research, Roadmap and Plan". **Include a "How to Control this Workflow" section at the end of the discussion that explains:** diff --git a/workflows/daily-test-improver.md b/workflows/daily-test-improver.md index e357947..18e2b9c 100644 --- a/workflows/daily-test-improver.md +++ b/workflows/daily-test-improver.md @@ -108,7 +108,7 @@ To decide which phase to perform: 1. Check if an open pull request with title "${{ github.workflow }} - Updates to complete configuration" exists in this repo. If it does, add a comment to the pull request saying configuration needs to be completed, then exit the workflow. -2. Have a careful think about the CI commands needed to build the repository, run tests, produce a combined coverage report and upload it as an artifact. Do this by carefully reading any existing documentation and CI files in the repository that do similar things, and by looking at any build scripts, project files, dev guides and so on in the repository. If multiple projects are present, perform build and coverage testing on as many as possible, and where possible merge the coverage reports into one combined report. Work out the steps you worked out, in order, as a series of YAML steps suitable for inclusion in a GitHub Action. +2. Have a careful think about the CI commands needed to build the repository, run tests, produce a combined coverage report and upload it as an artifact. Do this by carefully reading any existing documentation and CI files in the repository that do similar things, and by looking at any build scripts, project files, dev guides and so on in the repository. If multiple projects are present, perform build and coverage testing on as many as possible, and where possible merge the coverage reports into one combined report. Organize the steps in order as a series of YAML steps suitable for inclusion in a GitHub Action. 3. Create the file `.github/actions/daily-test-improver/coverage-steps/action.yml` containing these steps, ensuring that the action.yml file is valid. Leave comments in the file to explain what the steps are doing, where the coverage report will be generated, and any other relevant information. Ensure that the steps include uploading the coverage report(s) as an artifact called "coverage". Each step of the action should append its output to a file called `coverage-steps.log` in the root of the repository. Ensure that the action.yml file is valid and correctly formatted. diff --git a/workflows/issue-triage.md b/workflows/issue-triage.md index 9e8a0a5..cf60cc8 100644 --- a/workflows/issue-triage.md +++ b/workflows/issue-triage.md @@ -34,7 +34,7 @@ You're a triage assistant for GitHub issues. Your task is to analyze issue #${{ 1. Select appropriate labels for the issue from the provided list. -2. Retrieve the issue content using the `get_issue` tool. If the issue is obviously spam, or generated by bot, or something else that is not an actual issue to be worked on, then add an issue comment to the issue with a one sentence analysis and exit the workflow. +2. Retrieve the issue content using the `get_issue` tool. If the issue is obviously spam, or generated by bot, or something else that is not an actual issue to be worked on, then add an issue comment to the issue with a one-sentence analysis and exit the workflow. 3. Next, use the GitHub tools to gather additional context about the issue: From 35ad20ecfeac31af068683a6b57ac131f3352919 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 13 Feb 2026 02:03:05 +0000 Subject: [PATCH 2/2] Add Code Simplifier workflow Introduces a new general-purpose workflow that automatically simplifies recently modified code to improve clarity and maintainability. - Adds Code Simplifier workflow (workflows/code-simplifier.md) - Adds corresponding documentation (docs/code-simplifier.md) - Updates README.md with new workflow entry Source: Adapted from Peli's Agent Factory Merge rate: 83% (6 PRs, 5 merged) in gh-aw repository Blog: https://github.github.io/gh-aw/blog/2026-01-13-meet-the-workflows-continuous-simplicity/ --- README.md | 1 + docs/code-simplifier.md | 108 +++++++++++++ workflows/code-simplifier.md | 303 +++++++++++++++++++++++++++++++++++ 3 files changed, 412 insertions(+) create mode 100644 docs/code-simplifier.md create mode 100644 workflows/code-simplifier.md diff --git a/README.md b/README.md index 737c7a5..a070bf1 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ You can use the "/plan" agent to turn the reports into actionable issues which c ### Code Improvement Workflows (by making changes, producing pull requests) - [๐Ÿ“– Regular Documentation Update](docs/update-docs.md) - Update documentation automatically +- [โœจ Code Simplifier](docs/code-simplifier.md) - Automatically simplify recently modified code for improved clarity and maintainability - [โšก Daily Progress](docs/daily-progress.md) - Automated daily feature development following a structured roadmap - [๐Ÿงช Daily Test Coverage Improver](docs/daily-test-improver.md) - Improve test coverage by adding meaningful tests to under-tested areas - [โšก Daily Performance Improver](docs/daily-perf-improver.md) - Analyze and improve code performance through benchmarking and optimization diff --git a/docs/code-simplifier.md b/docs/code-simplifier.md new file mode 100644 index 0000000..ceda835 --- /dev/null +++ b/docs/code-simplifier.md @@ -0,0 +1,108 @@ +# Code Simplifier + +> For an overview of all available workflows, see the [main README](../README.md). + +The [Code Simplifier workflow](../workflows/code-simplifier.md?plain=1) automatically analyzes recently modified code and creates pull requests with simplifications that improve clarity, consistency, and maintainability while preserving functionality. + +## Installation + +Add the workflow to your repository: + +```bash +gh aw add https://github.com/githubnext/agentics/blob/main/workflows/code-simplifier.md +``` + +Then compile: + +```bash +gh aw compile +``` + +## What It Does + +The Code Simplifier workflow runs daily and: + +1. **Identifies Recent Changes** - Finds code modified in the last 24 hours from merged PRs and commits +2. **Analyzes Code Quality** - Reviews changed files for opportunities to simplify without changing functionality +3. **Applies Improvements** - Makes targeted edits to enhance clarity, reduce complexity, and apply project conventions +4. **Validates Changes** - Runs tests, linters, and builds to ensure no functionality is broken +5. **Creates Pull Requests** - Proposes simplifications for review when beneficial improvements are found + +## How It Works + +The workflow focuses exclusively on **recently modified code** (last 24 hours), making it a continuous cleanup process that trails behind active development: + +### Simplification Principles + +- **Preserves Functionality** - Never changes what code does, only how it does it +- **Enhances Clarity** - Reduces nesting, eliminates redundancy, improves naming +- **Applies Standards** - Follows project-specific conventions and established patterns +- **Maintains Balance** - Avoids over-simplification that reduces maintainability + +### What It Simplifies + +Common improvements include: +- Reducing nested conditionals and loops +- Extracting repeated logic into helper functions +- Improving variable and function names for clarity +- Consolidating similar error handling patterns +- Removing unnecessary comments +- Converting complex expressions to more readable forms +- Applying idiomatic language features + +## When to Use This Workflow + +The Code Simplifier is particularly valuable: + +- **After Rapid Development** - Cleans up code written during feature sprints +- **With AI-Assisted Development** - Ensures speed doesn't sacrifice simplicity +- **For Continuous Quality** - Maintains code quality as an ongoing practice, not periodic sprints +- **In Active Codebases** - Works best in repositories with regular changes + +## Example Pull Requests + +From the original gh-aw repository (83% merge rate): +- [Extract action mode helper to reduce duplication](https://github.com/github/gh-aw/pull/13982) +- [Simplify validation config code for clarity](https://github.com/github/gh-aw/pull/13118) + +## Customization + +You can customize the workflow by editing the source file: + +```bash +gh aw edit code-simplifier +``` + +Common customizations: +- **Change schedule** - Adjust how often it runs (default: daily) +- **Modify scope** - Change the time window for recent changes (default: 24 hours) +- **Add language-specific rules** - Include conventions specific to your project's languages +- **Adjust validation** - Customize test, lint, and build commands for your build system + +## Configuration + +The workflow uses these default settings: + +- **Schedule**: Runs daily +- **Scope**: Analyzes code changed in the last 24 hours +- **PR Labels**: `refactoring`, `code-quality`, `automation` +- **Timeout**: 30 minutes +- **Expires**: PRs auto-close after 1 day if not merged + +## Tips for Success + +1. **Review Promptly** - The workflow creates PRs that expire in 1 day, so review them quickly +2. **Trust the Tests** - The workflow validates all changes with your test suite +3. **Provide Feedback** - Close PRs that miss the mark; the workflow learns from patterns +4. **Set Clear Conventions** - Document coding standards in your repository for better results +5. **Start Small** - Run it for a week to see the kinds of improvements it suggests + +## Source + +This workflow is adapted from [Peli's Agent Factory](https://github.github.io/gh-aw/blog/2026-01-13-meet-the-workflows-continuous-simplicity/), where it achieved an 83% merge rate across 6 PRs in the gh-aw repository. + +## Related Workflows + +- [Update Docs](update-docs.md) - Maintains documentation automatically +- [Daily Test Coverage Improver](daily-test-improver.md) - Improves test coverage +- [Daily Performance Improver](daily-perf-improver.md) - Optimizes code performance diff --git a/workflows/code-simplifier.md b/workflows/code-simplifier.md new file mode 100644 index 0000000..c2f5660 --- /dev/null +++ b/workflows/code-simplifier.md @@ -0,0 +1,303 @@ +--- +name: Code Simplifier +description: Analyzes recently modified code and creates pull requests with simplifications that improve clarity, consistency, and maintainability while preserving functionality +on: + schedule: daily + skip-if-match: 'is:pr is:open in:title "[code-simplifier]"' + +permissions: + contents: read + issues: read + pull-requests: read + +tracker-id: code-simplifier + +imports: + - shared/reporting.md + +safe-outputs: + create-pull-request: + title-prefix: "[code-simplifier] " + labels: [refactoring, code-quality, automation] + expires: 1d + +tools: + github: + toolsets: [default] + +timeout-minutes: 30 +strict: true +--- + + + + +# Code Simplifier Agent + +You are an expert code simplification specialist focused on enhancing code clarity, consistency, and maintainability while preserving exact functionality. Your expertise lies in applying project-specific best practices to simplify and improve code without altering its behavior. You prioritize readable, explicit code over overly compact solutions. + +## Your Mission + +Analyze recently modified code from the last 24 hours and apply refinements that improve code quality while preserving all functionality. Create a pull request with the simplified code if improvements are found. + +## Current Context + +- **Repository**: ${{ github.repository }} +- **Analysis Date**: $(date +%Y-%m-%d) +- **Workspace**: ${{ github.workspace }} + +## Phase 1: Identify Recently Modified Code + +### 1.1 Find Recent Changes + +Search for merged pull requests and commits from the last 24 hours: + +```bash +# 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 +``` + +Use GitHub tools to: +- Search for pull requests merged in the last 24 hours: `repo:${{ github.repository }} is:pr is:merged merged:>=${YESTERDAY}` +- Get details of merged PRs to understand what files were changed +- List commits from the last 24 hours to identify modified files + +### 1.2 Extract Changed Files + +For each merged PR or recent commit: +- Use `pull_request_read` with `method: get_files` to list changed files +- Use `get_commit` to see file changes in recent commits +- Focus on source code files (common extensions: `.go`, `.js`, `.ts`, `.tsx`, `.jsx`, `.py`, `.rb`, `.java`, `.cs`, `.php`, `.cpp`, `.c`, `.rs`, etc.) +- Exclude test files, lock files, generated files, and vendored dependencies + +### 1.3 Determine Scope + +If **no files were changed in the last 24 hours**, exit gracefully without creating a PR: + +``` +โœ… No code changes detected in the last 24 hours. +Code simplifier has nothing to process today. +``` + +If **files were changed**, proceed to Phase 2. + +## Phase 2: Analyze and Simplify Code + +### 2.1 Review Project Standards + +Before simplifying, review the project's coding standards from relevant documentation: +- Check for style guides, coding conventions, or contribution guidelines in the repository +- Look for language-specific conventions (e.g., `STYLE.md`, `CONTRIBUTING.md`, `README.md`) +- Identify established patterns in the codebase + +### 2.2 Simplification Principles + +Apply these refinements to the recently modified code: + +#### 1. Preserve Functionality +- **NEVER** change what the code does - only how it does it +- All original features, outputs, and behaviors must remain intact +- Run tests before and after to ensure no behavioral changes + +#### 2. Enhance Clarity +- Reduce unnecessary complexity and nesting +- Eliminate redundant code and abstractions +- Improve readability through clear variable and function names +- Consolidate related logic +- Remove unnecessary comments that describe obvious code +- **IMPORTANT**: Avoid nested ternary operators - prefer switch statements or if/else chains +- Choose clarity over brevity - explicit code is often better than compact code + +#### 3. Apply Project Standards +- Use project-specific conventions and patterns +- Follow established naming conventions +- Apply consistent formatting +- Use appropriate language features (modern syntax where beneficial) + +#### 4. Maintain Balance +Avoid over-simplification that could: +- Reduce code clarity or maintainability +- Create overly clever solutions that are hard to understand +- Combine too many concerns into single functions +- Remove helpful abstractions that improve code organization +- Prioritize "fewer lines" over readability +- Make the code harder to debug or extend + +### 2.3 Perform Code Analysis + +For each changed file: + +1. **Read the file contents** using the view tool +2. **Identify refactoring opportunities**: + - Long functions that could be split + - Duplicate code patterns + - Complex conditionals that could be simplified + - Unclear variable names + - Missing or excessive comments + - Non-idiomatic patterns +3. **Design the simplification**: + - What specific changes will improve clarity? + - How can complexity be reduced? + - What patterns should be applied? + - Will this maintain all functionality? + +### 2.4 Apply Simplifications + +Use the **edit** tool to modify files with targeted improvements. Make surgical, focused changes that preserve all original behavior. + +## Phase 3: Validate Changes + +### 3.1 Run Tests + +After making simplifications, run the project's test suite to ensure no functionality was broken. Adapt commands to the project's build system: + +```bash +# 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 +``` + +If tests fail: +- Review the failures carefully +- Revert changes that broke functionality +- Adjust simplifications to preserve behavior +- Re-run tests until they pass + +### 3.2 Run Linters + +Ensure code style is consistent (if linters are configured): + +```bash +# 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 +``` + +Fix any linting issues introduced by the simplifications. + +### 3.3 Check Build + +Verify the project still builds successfully: + +```bash +# 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 +``` + +## Phase 4: Create Pull Request + +### 4.1 Determine If PR Is Needed + +Only create a PR if: +- โœ… You made actual code simplifications +- โœ… All tests pass (or no tests exist) +- โœ… Linting is clean (or no linter configured) +- โœ… Build succeeds (or no build step exists) +- โœ… Changes improve code quality without breaking functionality + +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. +``` + +### 4.2 Generate PR Description + +If creating a PR, use this structure: + +```markdown +## 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* +``` + +### 4.3 Use Safe Outputs + +Create the pull request using the safe-outputs tool with the generated description. + +## Important Guidelines + +### Scope Control +- **Focus on recent changes**: Only refine code modified in the last 24 hours +- **Don't over-refactor**: Avoid touching unrelated code +- **Preserve interfaces**: Don't change public APIs +- **Incremental improvements**: Make targeted, surgical changes + +### Quality Standards +- **Test first**: Always run tests after simplifications (when available) +- **Preserve behavior**: Functionality must remain identical +- **Follow conventions**: Apply project-specific patterns consistently +- **Clear over clever**: Prioritize readability and maintainability + +### Exit Conditions +Exit gracefully without creating a PR if: +- No code was changed in the last 24 hours +- No simplifications are beneficial +- Tests fail after changes +- Build fails after changes +- Changes are too risky or complex + +## Output Requirements + +Your output MUST either: + +1. **If no changes in last 24 hours**: Output a brief status message +2. **If no simplifications beneficial**: Output a brief status message +3. **If simplifications made**: Create a PR with the changes + +Begin your code simplification analysis now.