Skip to content

Pritiks23/refactor-code-GraphRAG

Repository files navigation

Screen Shot 2025-09-16 at 7 57 20 PM

🤖 Refactor Code Bot: Autonomous Code Maintenance Agent

Refactor Bot is an agentic AI-powered solution designed to autonomously maintain and optimize software repositories. Built entirely on GitHub Actions, it functions as a self-directed collaborator that formats code, cleans up unused logic, injects license headers, visualizes architecture, and tracks dependencies — all without human intervention.

This project was created for a hackathon focused on Agentic AI, where solutions must demonstrate autonomous decision-making and task execution. Refactor Bot embodies this vision by acting as a digital steward of codebases, continuously improving them with minimal human input.


🔨 What It Builds

Refactor Bot is a fully functional prototype of an AI agent that:

  • 🧠 Thinks: Analyzes code structure, dependencies, and history
  • 🧹 Acts: Executes formatting, cleanup, and documentation tasks
  • 📈 Improves: Enhances readability, maintainability, and transparency
  • 🔁 Decides: Chooses what to fix, when to commit, and how to document

⚙️ Autonomous Workflows

Each workflow is a self-contained agentic task that runs on a schedule or manually. Together, they form a maintenance ecosystem:

Workflow Description
cleanup-unused.yml Removes unused imports and variables using Ruff and Autoflake
license-header.yml Injects missing license headers into source files
auto-format.yml Formats code with Black, Ruff, and Prettier
dependency-manifest.yml Generates a dependency tree using pipdeptree and commits it
code-graph.yml Creates module and call graph diagrams using AST and Graphviz
changelog.yml Parses git history and updates CHANGELOG.md using Conventional Commits

Each workflow commits directly to main, making decisions and executing tasks without requiring pull requests or approvals.


🧠 Agentic Intelligence

Refactor Bot is not just automation — it's autonomy. It:

  • Identifies dead code and removes it
  • Detects missing documentation and fills it in
  • Visualizes architecture to aid human understanding
  • Tracks dependencies to surface complexity
  • Summarizes history to create living documentation

These behaviors reflect real-world agentic collaboration, where AI acts as a proactive teammate rather than a passive tool.


🌍 Real-World Relevance

Refactor Bot addresses challenges faced by every developer:

  • Code rot from unused logic and inconsistent formatting
  • Missing documentation that slows onboarding
  • Opaque architecture that hinders collaboration
  • Untracked dependencies that introduce risk

By autonomously solving these problems, Refactor Bot becomes a digital maintainer — ideal for open-source projects, internal tools, and educational codebases.


🚀 Getting Started

  1. Fork this repo or copy the .github/workflows/ and scripts/ folders into your own
  2. Enable GitHub Actions
  3. Watch Refactor Bot go to work — no setup, no tokens, no approvals

Screen Shot 2025-09-16 at 8 02 03 PM

Demo of the Workflows changelog and code-graph: 📊 Code Graph: code_graph_modules.svg

The diagram generated by the code-graph.yml workflow provides a high-level module graph of your project — specifically visualizing the relationships between your Python scripts. image

Each rounded rectangle in the graph represents a script, and their placement or connections (if any) help illustrate how your codebase is structured.

🧱 Design Insights

  • Modular Design
    Each script is self-contained and serves a distinct purpose, promoting clarity and separation of concerns.

  • Agentic Behavior
    These modules act independently, yet contribute to a shared goal — maintaining and documenting your codebase autonomously.

  • No Tight Coupling
    The absence of arrows or edges (if present) suggests that these scripts don’t directly import or depend on each other, which enhances autonomy and maintainability.

This graph serves as visual proof of your agentic architecture — showcasing how your AI-powered workflows are modular, autonomous, and purpose-driven.


🕒 Demo of Changelog

🧹 Chores

These are non-functional improvements — tasks that clean, organize, or maintain the codebase without changing its behavior.

  • Update code graphs
  • Update dependency manifest
  • Add missing license headers

📦 Other

This section includes miscellaneous changes that don’t fit neatly into categories like feat, fix, or chore. Screen Shot 2025-09-16 at 8 45 19 PM


This changelog reflects the autonomous actions taken by Refactor Bot — documenting its decisions and contributions without human prompting.

🧪 Tech Stack

  • GitHub Actions — agentic execution engine
  • Black, Ruff, Prettier — formatting and linting
  • Autoflake — cleanup
  • Graphviz + AST — code visualization
  • pipdeptree — dependency analysis
  • Python — orchestration and scripting

🏁 Hackathon Alignment

Refactor Bot is a prototype of an Agentic AI-powered solution that:

  • ✅ Performs autonomous decision-making and task execution
  • ✅ Demonstrates workflow automation with minimal human input
  • ✅ Solves real-world software maintenance challenges
  • ✅ Acts as a collaborative agent in developer ecosystems

📄 License

MIT — free to use, fork, and extend.


🙌 Built With Love

Exploring the future of Agentic AI.
Refactor Bot is your repo’s silent partner — always watching, always improving.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages