A Sequential Multi-Agent Pipeline that scans, refactors, and documents your code — automatically.
Developers ship unoptimized or insecure code (SQL injection, bad practices) under time pressure. Manual code review is slow, and small but critical bugs slip through human error.
Instead of relying on a single general-purpose prompt, AI Code Guardian runs a team of specialized agents sequentially, each with one job, so the output is consistent and auditable at every stage:
┌────────────┐ ┌─────────────┐ ┌────────────┐
│ Scanner │ ───▶ │ Refactor │ ───▶ │ Docs │
│ Agent │ │ Agent │ │ Agent │
└────────────┘ └─────────────┘ └────────────┘
Audit Report Clean Code README +
Docstrings
- Automated Scanning & Refactoring — detects bugs, security issues
(SQL injection, unsafe
eval/exec, etc.) and bad practices, then rewrites the code to PEP8 standards. - Auto-Documentation — generates docstrings and a ready-to-ship
README.mdfor the cleaned code. - Real-Time UI Tracking — a Streamlit front-end shows exactly which agent is running, live.
- Fail-safe pipeline — if any agent errors out, the graph short-circuits instead of burning further API calls on broken input.
| Layer | Tool |
|---|---|
| Orchestration | LangGraph (StateGraph, conditional edges) |
| LLM Framework | LangChain |
| Model | Google Gemini (gemini-3.6-flash) |
| UI | Streamlit (custom glass red/black theme) |
| Deterministic formatting | autopep8 |
| State management | TypedDict (PipelineState) |
ai-code-guardian/
├── agents/
│ ├── state.py # shared TypedDict state
│ ├── scanner_agent.py # Agent 1 — audit
│ ├── refactor_agent.py # Agent 2 — clean code
│ └── docs_agent.py # Agent 3 — docstrings + README
├── sample_code/
│ └── example_buggy.py # demo input with intentional issues
├── graph_pipeline.py # LangGraph wiring
├── app.py # Streamlit UI
├── requirements.txt
└── .env
git clone https://github.com/HamzaAli2002/ai-code-guardian.git
cd ai-code-guardian
python -m venv venv && source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# add your GOOGLE_API_KEY to .env (get one at aistudio.google.com/app/apikey)
streamlit run app.pyPaste code (or try sample_code/example_buggy.py) into the UI and hit Run Pipeline.
- Scanner Agent reads the raw code and returns a structured Markdown audit (security, bugs, style, performance) — it never modifies code.
- Refactor Agent runs
autopep8for deterministic formatting, then asks Gemini to fix everything flagged in the audit report. - Docs Agent adds docstrings/comments to the clean code and writes a
project-ready
README.md.
State flows between agents through a single PipelineState(TypedDict), so
each node only reads/writes the keys it owns.
- Multi-file / repo-level scanning
- Pluggable linters (Bandit, Ruff) as a pre-pass before the LLM
- Diff view (before/after) in the UI
- Export audit report as PDF
MIT — see LICENSE.
Built as an Agentic AI coursework project — Saylani Mass IT Training SMIT.