Nano Banana Pro
Agent skill for nano-banana-pro
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Sign in to like and favorite skills
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Commitly is an AI-powered, multi-agent commit automation system that orchestrates the entire post-commit workflow through a local Python pipeline. It uses LangGraph to coordinate seven specialized agents that handle code validation, testing, refactoring, synchronization, Slack integration, and reporting.
Key Value: Automates the entire process after Git commits through a local multi-agent pipeline with minimal manual intervention (single approval gate via SyncAgent).
# Install dependencies poetry install # Load environment variables (required before running commands) set -a && source .env && set +a # Initialize project structure (.commitly directory) poetry run commitly init
# Execute the full pipeline after making changes poetry run commitly commit -m "Your commit message" # Equivalent to: poetry run commitly git commit -m "Your commit message"
# Run linting (Ruff) ruff check src/ # Format code (Black) black src/ # Type checking (MyPy) mypy src/commitly/ # Run tests pytest tests/ # Run tests with coverage pytest --cov=src/commitly tests/ # Run a single test file pytest tests/test_agent.py # Run a specific test pytest tests/test_agent.py::test_clone_agent_execution
# Check pipeline status poetry run commitly status # Generate a report from pipeline execution poetry run commitly report --from 2025-10-20 --to 2025-10-22 # View logs from a specific agent cat .commitly/logs/{agent_name}/$(ls -t .commitly/logs/{agent_name} | head -1) # Check cached output from previous agent runs cat .commitly/cache/{agent_name}.json
The pipeline follows a sequential agent orchestration pattern where a central
CommitlyPipeline class (in src/commitly/pipeline/graph.py) constructs a LangGraph StateGraph with seven nodes. Each agent executes sequentially, sharing state through a RunContext (TypedDict) that persists data between agents.
User Workspace ↓ (git commit) [CommitlyPipeline] orchestration layer ↓ [CloneAgent] → Hub setup & local change sync ↓ [CodeAgent] → Static analysis, SQL extraction ↓ [TestAgent] → Test execution, SQL optimization ↓ [RefactoringAgent] → Code quality improvement ↓ [SyncAgent] → USER APPROVAL GATE → Remote push ↓ [SlackAgent] → Slack integration (non-blocking) ↓ [ReportAgent] → Report generation (non-blocking)
Template Method Pattern:
BaseAgent (src/commitly/agents/base.py) defines the run() wrapper that handles error handling, output caching, and persistence. Each agent implements execute() for custom logic.
Hub Repository Pattern: Agents work in a shared hub directory (cloned from remote) rather than modifying the user's workspace directly. This provides safety and auditability. Only SyncAgent can push changes back to the user's workspace.
Approval Gate: SyncAgent is the only point requiring user interaction. It summarizes all changes and requires explicit approval before pushing to remote.
Error Handling & Rollback: Failed agents trigger rollback logic that deletes created branches and resets the hub to the last successful state. Non-blocking agents (Slack, Report) don't abort the pipeline if they fail.
Comprehensive Logging: Every agent logs to
.commitly/logs/{agent_name}/{timestamp}.log. Outputs are also cached as JSON in .commitly/cache/{agent_name}.json for traceability.
src/commitly/ ├── cli/ # Command-line interface entry point ├── core/ # Shared utilities (config, git, logging, LLM) ├── pipeline/ # LangGraph orchestration (CommitlyPipeline) ├── agents/ # Seven agent implementations │ ├── base.py # BaseAgent abstract class (critical) │ ├── clone/ # Hub sync │ ├── code/ # Validation & SQL parsing │ ├── test/ # Testing & SQL optimization │ ├── refactoring/ # Code improvement │ ├── sync/ # Remote push & approval gate │ ├── slack/ # Slack integration │ └── report/ # Report generation └── tests/ # Test suite (placeholder)
src/commitly/pipeline/graph.py:CommitlyPipeline - Main orchestrator that builds the LangGraph and executes agents sequentially. Initializes shared config, LLM client, Git manager, and RunContext.src/commitly/agents/base.py:BaseAgent - Abstract base class defining the agent execution template. All agents inherit from this. Key methods: run() (executes with error handling), execute() (override in subclasses), _save_output() (persists to cache).src/commitly/agents/clone/agent.py:CloneAgent - Creates hub repo, syncs with remote, applies local changessrc/commitly/agents/code/agent.py:CodeAgent - Runs static checks (ruff, mypy), executes user application, extracts SQL queriessrc/commitly/agents/test/agent.py:TestAgent - Optimizes SQL queries (LLM generates candidates, EXPLAIN ANALYZE evaluates), runs test suitesrc/commitly/agents/refactoring/agent.py:RefactoringAgent - Removes duplicate code, adds error handling via LLM, applies formattingsrc/commitly/agents/sync/agent.py:SyncAgent - THE APPROVAL GATE: summarizes changes, waits for user confirmation, pushes to remotesrc/commitly/agents/slack/agent.py:SlackAgent - Queries Slack, matches messages, auto-replies (non-blocking)src/commitly/agents/report/agent.py:ReportAgent - Generates markdown/PDF/HTML reports from logs (non-blocking)src/commitly/core/config.py - YAML configuration loader with environment variable substitution (${VAR_NAME})src/commitly/core/context.py - TypedDict definitions for RunContext (shared state) and AgentOutput (standardized results)src/commitly/core/git_manager.py - GitPython wrapper for branch/commit operationssrc/commitly/core/llm_client.py - OpenAI API wrappersrc/commitly/core/logger.py - Per-agent logging to .commitly/logs/{agent_name}/src/commitly/core/rollback.py - Failure handling, branch deletion, hub cleanupsrc/commitly/agents/code/sql_parser.py - Parses SQL queries from code filessrc/commitly/agents/test/sql_optimizer.py - LLM-based SQL optimization with EXPLAIN ANALYZE evaluationconfig.yaml in repo root (version controlled).commitly/config.yaml (created by commitly init, can be project-specific)llm: enabled: true model: gpt-4o-mini api_key: ${OPENAI_API_KEY} execution: command: python main.py # User app to run timeout: 300 test: timeout: 300 pipeline: cleanup_hub_on_failure: false # Control hub cleanup on errors database: # For SQL optimization host: ${DB_HOST} port: 5432 user: ${DB_USER} password: ${DB_PASSWORD} dbname: ${DB_NAME}
.env file must define (sourced before running pipeline):
OPENAI_API_KEY - Required for LLM operationsDB_USER, DB_PASSWORD, DB_NAME - For SQL optimization${VAR_NAME}src/commitly/agents/{agent_name}/agent.pyBaseAgentexecute(self, context: RunContext) -> Dict[str, Any]src/commitly/pipeline/graph.py:build_graph().commitly/logs/{agent_name}/.commitly/logs/{agent_name}/{latest_timestamp}.log.commitly/cache/{agent_name}.json (shows status, error details, and previous results).commitly/hub/ contains the state agents modifiedgit log in hub to trace branch historygit -C .commitly/hub reset --hard {branch}All agent logic is in their respective
execute() methods. Changes here are immediate:
agents/clone/agent.py, agents/sync/agent.pyagents/code/agent.py, agents/code/static_checker.pyagents/test/agent.py, agents/test/sql_optimizer.pyagents/refactoring/agent.py (edit the refactoring prompts)Place test files in
tests/ with test_*.py naming. Use pytest fixtures to mock:
RunContext (create a dict matching the TypedDict schema)LLMClient (mock OpenAI responses)GitManager (use temporary git repos or mocks)Example:
def test_clone_agent_execution(tmp_path): context = { "pipeline_id": "test-123", "hub_path": str(tmp_path / "hub"), # ... other required fields } agent = CloneAgent() result = agent.run(context) assert result["status"] == "success"
# Run all tests with coverage report pytest --cov=src/commitly --cov-report=html tests/ # Open coverage report open htmlcov/index.html # Check coverage for specific file pytest --cov=src/commitly/agents/base --cov-report=term-missing tests/
| Issue | Diagnosis | Solution |
|---|---|---|
| Missing or not sourced | Run before pipeline |
| Agent hangs | Timeout configuration | Increase or in config.yaml |
| Hub sync fails | Network/permission issue | Check for remote URL |
| Test optimization fails | DB not accessible | Verify config matches your PostgreSQL setup |
| Refactoring introduces bugs | LLM output quality issue | Review model choice or refactoring prompts in agent code |
From
pyproject.toml:
disallow_untyped_defs = trueAll functions must have type annotations. Use TypedDict for structured data (as done in
core/context.py).