AWS Builder Center
 Ghost Repo Janitor

Ghost Repo Janitor

As developers, we accumulate technical debt in our repositories without even realizing it. Branches that were meant to be temporary become permanent fixtures. Issues lose momentum when no one follows up. Pull requests sit unreviewed for weeks. Manually tracking all of this across multiple repos is tedious and often forgotten.

Weekend Agent Challenge: Ghost Repo Janitor

Tag: #agents



Vision & What the Agent Does

Have you ever woken up to a messy GitHub workspace — stale branches piling up, issues going cold, and pull requests waiting in limbo? Ghost Repo Janitor is an AI-powered autonomous agent that cleans up your GitHub repositories while you sleep.

The Problem

As developers, we accumulate technical debt in our repositories without even realizing it. Branches that were meant to be temporary become permanent fixtures. Issues lose momentum when no one follows up. Pull requests sit unreviewed for weeks. Manually tracking all of this across multiple repos is tedious and often forgotten.

What It Does

Ghost Repo Janitor runs every night at 12:30 AM IST (19:00 UTC) — completely autonomously, with no human intervention. Here's what happens while you sleep:
  1. Scans your top 10 most recently updated GitHub repositories
  1. Detects stale branches — any branch inactive for 30+ days (excluding main/master)
  1. Identifies inactive issues — open issues with no activity for 14+ days
  1. Lists pending PRs — pull requests awaiting review with days-open count
  1. Auto-labels stale issues with a  needs-attention  tag so they're visually flagged
  1. Generates an AI-powered summary using Amazon Bedrock Nova that prioritizes what needs your attention
  1. Delivers a morning report via email/SMS through Amazon SNS
By the time you wake up and check your inbox, you have a clean, actionable report telling you exactly what needs attention — no manual repo-hopping required.

How It Triggers

The agent is triggered by Amazon EventBridge Scheduler using a cron expression ( cron(30 19 * * ? *) ). This fires the Lambda function every single day at the scheduled time. There is no button to click, no UI to open — it just runs.

How It Reports Back

The AI-generated summary arrives in your inbox as an email (via Amazon SNS). The report is structured with emojis and clear sections — immediate attention items, stale branches, inactive issues, pending PRs, and top 3 recommended actions for the day.



How I Built It

Development Process

I started by identifying the core pain point: repository hygiene is important but boring. Nobody wants to manually audit branches and issues every day. The solution had to be fully autonomous — fire-and-forget.
My development process followed these steps:
  1. Designed the architecture — mapped out which AWS services would handle each responsibility
  1. Built the GitHub scanning logic — used GitHub REST API to fetch repos, branches, issues, and PRs
  1. Added intelligence — integrated Amazon Bedrock Nova Micro to transform raw data into actionable insights
  1. Set up notifications — configured SNS for reliable email delivery
  1. Automated the trigger — created an EventBridge schedule for nightly execution
  1. Tested end-to-end — ran the Lambda function manually to verify the full pipeline

Key Decisions

  • Python 3.12 on Lambda — lightweight, fast cold starts, and native  urllib  means zero external dependencies
  • Nova Micro model — cost-effective for summary generation, fast inference, and stays within free tier
  • Top 10 repos limit — prevents timeout issues while covering the most active repositories
  • Auto-labeling — the agent doesn't just report, it takes action by tagging stale issues

Challenges & Solutions

Challenge
Solution
Lambda 3-second default timeout
Increased to 120 seconds for API-heavy scanning
GitHub API rate limiting
Limited to 10 repos per scan, with error handling
Bedrock model access
Had to explicitly request Nova Micro access in ap-southeast-2 region
Token security
Used AWS Secrets Manager instead of environment variables



AWS Services Used / Architecture Overview

Architecture Diagram

┌─────────────────────────────────────────────────────────┐
│ GHOST REPO JANITOR │
├─────────────────────────────────────────────────────────┤
│ │
│ EventBridge Scheduler (Daily 12:30 AM IST / 19:00 UTC) │
│ │ │
│ ▼ │
│ AWS Lambda (Python 3.12) │
│ │ │
│ ┌────────────┼────────────┐ │
│ ▼ ▼ ▼ │
│ GitHub API Bedrock Nova SNS │
│ (Scan Repos) (AI Summary) (Send Report) │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ - Stale Branches Morning Email/SMS │
│ - Dead Issues Report to Developer │
│ - Pending PRs Generated │
│ - Auto-Label │
│ │
└─────────────────────────────────────────────────────────┘

Services Breakdown

AWS Service
Role in Architecture
Why This Service
Amazon EventBridge Scheduler
Triggers the agent on a nightly cron schedule
Serverless, precise scheduling, no infrastructure to manage
AWS Lambda
Executes the scanning logic, API calls, and orchestration
Pay-per-use, scales to zero, perfect for periodic tasks
Amazon Bedrock (Nova Micro)
Generates intelligent, prioritized cleanup summaries
Managed AI inference, no model hosting needed, free tier eligible
Amazon SNS
Delivers the morning report via email/SMS
Reliable pub/sub messaging, multi-protocol support
AWS Secrets Manager
Securely stores the GitHub Personal Access Token
Encrypted at rest, no secrets in code
Amazon CloudWatch
Logs execution details for debugging and monitoring
Automatic with Lambda, searchable logs

How the Agent is Triggered

The agent uses EventBridge Scheduler with a cron expression:  cron(30 19 * * ? *) . This translates to 19:00 UTC every day, which is 12:30 AM IST. EventBridge directly invokes the Lambda function with no intermediary — making it a true "set it and forget it" automation.



What I Learned

New Skills Discovered

  1. Amazon Bedrock Integration — First time using Bedrock's  invoke_model  API. The Nova Micro model is surprisingly capable for structured summarization tasks, and the inference config (temperature, max tokens) gives fine control over output quality.
  1. EventBridge Scheduler vs. CloudWatch Events — Learned that EventBridge Scheduler is the newer, more flexible option for cron-based triggers. It supports one-time and recurring schedules with timezone awareness.
  1. Serverless Architecture Thinking — Building an agent that runs without any server taught me to think in terms of triggers, handlers, and outputs rather than long-running processes.
  1. GitHub API Patterns — Discovered efficient patterns for scanning repositories — sorting by update time, filtering PRs from issues, and batch-processing branches.
  1. AI Prompt Engineering for Reports — Crafting the right prompt for Bedrock Nova to produce consistent, well-formatted reports required iteration. Temperature 0.3 gave the best balance of creativity and consistency.

Key Takeaways

  • Autonomous agents are powerful — The best part is waking up to a report that was generated while I slept. It changes how you think about developer tooling.
  • AWS Free Tier is generous — This entire project runs at $0/month within free tier limits.
  • Security matters — Using Secrets Manager instead of hardcoding tokens is a small effort with huge security benefits.
  • Start simple, iterate — I started with just branch scanning, then added issues, PRs, AI summaries, and auto-labeling incrementally.



Link to App or Repo

The repository contains:
  • Complete Lambda function source code ( src/lambda_function.py )
  • Detailed architecture documentation ( docs/architecture.md )
  • Unit tests ( tests/test_handler.py )
  • Full setup instructions in README


Built with ❤️ for the AWS Weekend Agent Challenge (July 2026) using Amazon Bedrock, Lambda, EventBridge, and SNS.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article