KoteGuard โ run GitHub Copilot agents safely in isolated git worktrees
Project description
KoteGuard ๐ก๏ธ
Safe GitHub Copilot agent sandboxing for Android (Kotlin) and iOS (Swift) developers.
kote prep โ isolated git worktree โ agent works safely โ kote cleanup --accept
KoteGuard runs Copilot agents in isolated git worktrees so they can never accidentally commit secrets, break your main branch, or touch real signing credentials. Every session is planned, gated, validated, and audited.
Why KoteGuard?
| Problem | Without KoteGuard | With KoteGuard |
|---|---|---|
Agent pushes to main |
๐ฅ Happens | --deny-tool='shell(git push)' blocks it |
Agent reads your .jks / .p12 |
๐ฅ Full access | Replaced with stubs before session starts |
| No record of what the agent did | ๐ฌ Nothing | Per-session audit.jsonl + validation-report.md |
| Agent goes off-script | ๐ฌ No way to know | PLAN.md hard gate + change validation on cleanup |
| Context bloat across sessions | ๐ฌ Expensive | --compact accumulates knowledge into WORKSPACE.md |
Features
- ๐ Smart project analysis โ auto-detects Android/iOS, parses
build.gradle+Info.plist, scans docs - ๐ Interactive planning wizard โ builds
PLAN.mdwith a refine loop and a hardYESgate - ๐ฟ Isolated git worktrees โ agent works on a dedicated branch, never touches
main - ๐ Sensitive file stubs โ
.jks,google-services.json,.p12replaced with safe placeholders - ๐ค Copilot CLI ready โ generates the complete
copilot --deny-tool=...command for you - ๐ Session tracking โ rich status table with age, Android CLI status, skills loaded, context pressure
- โ
Auto-validation โ validates PLAN.md + changed files on
kote cleanup --accept - ๐งฐ Android Skills โ bundled SKILL.md guides for Navigation 3, Compose, AGP 9, Edge-to-Edge
- ๐ง Token hygiene โ
--compactsaves session knowledge back intoWORKSPACE.md
Installation
pip install koteguard
Requires Python 3.12+
Or install from source (alpha branch):
git clone https://github.com/alisen/KoteGuard.git
cd KoteGuard
git checkout alpha/v1.0.0-alpha.1
pip install -e ".[dev]"
Local install (no GitHub push needed โ for testing before publishing):
# Using pipx (recommended for CLI tools)
brew install pipx && pipx ensurepath
pipx install /path/to/KoteGuard
# Or with pip directly
pip install /path/to/KoteGuard
Quick Start
cd your-android-or-ios-project
# 1. Run the wizard โ it detects your project, plans, creates the worktree
kote prep
# 2. See what it created
kote status
# 3. Copy the ready-to-run Copilot CLI command
kote cli
# 4. When the agent is done โ validate + merge back
kote cleanup --accept
# 5. Or throw it away
kote cleanup --discard
Android-first (with skills wizard)
kote prep --android-first
# โ detects Compose/Navigation/AGP usage
# โ shows checkbox to select which skill guides to inject
# โ pre-populates PLAN.md with selected skills
How It Works
kote prep
โ
โโโ Phase 0: Scan project
โ detect Android/iOS ยท parse build.gradle/Info.plist
โ scan docs ยท detect Android CLI ยท suggest skills
โ
โโโ Phase 1: Interactive planning
โ title ยท objectives ยท tasks ยท definition of done ยท risks
โ โโโโ HARD GATE: type YES to proceed, refine to re-edit โโโโ
โ
โโโ Phase 2: Create worktree
new git branch (kote/<session-id>-<slug>)
writes: PLAN.md ยท TASK.md ยท AGENTS.md ยท WORKSPACE.md
.github/copilot-instructions.md
.github/instructions/security.instructions.md
stubs: google-services.json ยท *.jks ยท *.p12 ยท etc.
logs: sessions/<id>/context/ ยท logs/ ยท output/
kote cli
โโโ prints: cd /worktree && COPILOT_CUSTOM_INSTRUCTIONS_DIRS=... copilot --deny-tool=...
[agent works here]
kote cleanup --accept
โโโ auto-validates PLAN.md + changed files
โโโ generates sessions/<id>/output/validation-report.md
โโโ merges branch back
โโโ archives PLAN ยท TASK ยท diff ยท audit ยท report โ .kote/history/
Command Reference
| Command | Description |
|---|---|
kote prep |
Full wizard: analyse โ plan โ worktree โ IDE |
kote prep --android-first |
Wizard with Android skills selection |
kote prep --agent-mode <mode> |
Override agent mode: copilot-cli | copilot-plugin | none |
kote prep --dry-run |
Simulate without creating a worktree |
kote ide [session] |
Launch Android Studio or Xcode for a session |
kote cli [session] |
Print complete copilot command + open terminal |
kote status |
Rich table: all sessions with age, skills, context pressure |
kote cleanup --accept |
Validate โ merge โ archive history |
kote cleanup --discard |
Throw away changes, preserve audit trail |
kote cleanup --accept --force |
Accept even when validation has errors |
kote cleanup --accept --compact |
Accept + save session summary to WORKSPACE.md |
kote validate [plan.md] |
Validate PLAN.md against schema |
kote validate -w WORKSPACE.md |
Also validate WORKSPACE.md |
kote android skills |
List bundled skills + suggest for current project |
kote android docs |
Android KB links + worktree status |
kote version |
Print version |
Android Skills
KoteGuard bundles best-practice SKILL.md guides that get injected into the agent's context. The scanner auto-detects which ones are relevant based on your build.gradle.
| Skill | Triggered by | Guide covers |
|---|---|---|
navigation3 |
androidx.navigation dependency |
Type-safe NavHost, @Serializable routes, no string routes |
edge-to-edge |
enableEdgeToEdge / API 35 target |
windowInsetsPadding, Scaffold insets, API 35 enforcement |
agp9 |
AGP 9.x in libs.versions.toml |
JDK 21 requirement, namespace, declarative Kotlin DSL |
compose-migration |
androidx.compose dependency |
State hoisting, collectAsStateWithLifecycle, LazyColumn keys |
kote android skills # see what's available + what's suggested
kote android docs # Android developer documentation links
Spec-Driven Development
Every PLAN.md KoteGuard creates has a machine-readable YAML block at the top. This is the source of truth โ not just documentation.
---
spec_version: '1.0'
title: Implement login screen
tasks:
- id: t1
description: Create LoginViewModel
done: false
- id: t2
description: Wire up UI
done: false
definition_of_done:
- All tests pass
- Reviewed
---
# Implement login screen
...
The agent is instructed to update done: true for each task it completes, directly inside that YAML block. When you run kote cleanup --accept, KoteGuard:
- Parses the YAML โ reads exactly which tasks were marked done
- Validates semantically โ checks that changed files actually match each task's keywords (CamelCase-aware:
NavGraphโ searches fornav,graphin file paths) - Warns if tasks are undone โ if files changed but all tasks are still
done: false, it flags it - Survives corruption โ if the agent breaks the YAML, a regex fallback recovers the plan silently
This is why PLAN.md is not just a text document โ it's a live spec the agent writes back to.
Security Model
KoteGuard is designed so that even a misbehaving agent can't cause lasting damage.
| Layer | Mechanism |
|---|---|
| Planning gate | Must type YES (or refine) โ no accidental starts |
| Branch isolation | Agent never touches main โ always a kote/<id> branch |
| Secret stubs | google-services.json, .jks, .p12 etc. swapped for placeholders before the session |
| Deny-tool flags | git push, git clone, git remote add/set-url are CLI-level blocked |
| Dual instructions | Agent gets both a task brief and a security rules file |
| Validation on accept | PLAN.md compliance + file change analysis before any merge |
| Audit trail | Every event written to sessions/<id>/logs/audit.jsonl + global ~/.kote/audit.jsonl |
| History archival | PLAN, TASK, diff, audit, report copied to .kote/history/ on every accept or discard |
Generated Copilot CLI Command
kote cli prints this โ ready to paste:
cd /path/to/worktree && \
COPILOT_CUSTOM_INSTRUCTIONS_DIRS=".github/instructions" \
copilot \
--deny-tool='shell(git push)' \
--deny-tool='shell(git remote add)' \
--deny-tool='shell(git remote set-url)' \
--deny-tool='shell(git clone)'
Project Structure
src/koteguard/
โโโ cli.py # Typer CLI (kote + kote android subgroup)
โโโ models.py # Pydantic v2 models + Android v1.1 skill models
โโโ config.py # TOML config ยท session audit ยท worktree context check
โโโ project_scanner.py # Phase 0: file-signature detection + gradle parsing + doc analysis
โโโ worktree.py # Git worktree engine ยท session subdirs ยท history archival
โโโ sensitive_files.py # Sensitive file stub injection
โโโ planning.py # PLAN.md ยท WORKSPACE.md ยท Copilot instructions rendering
โโโ launcher.py # IDE launcher ยท build_copilot_cli_command()
โโโ validation.py # Plan/change/skills validation ยท report generation
โโโ templates.py # Template file management
templates/
โโโ PLAN.md # Includes Token & Context Rules section
โโโ WORKSPACE.md # Includes Android Agent Stack section
โโโ TASK.md
โโโ instructions.md # Includes model selection guidance
โโโ security.instructions.md # applyTo: "**/*" ยท Android + iOS deny rules
โโโ AGENTS.md
โโโ config.toml
โโโ android-skills/
โโโ navigation3.skill.md
โโโ edge-to-edge.skill.md
โโโ agp9.skill.md
โโโ compose-migration.skill.md
Requirements
- Python 3.12+
- Git 2.5+ (for worktree support)
- GitHub Copilot CLI (
copilotbinary) for the terminal workflow - Android Studio or Xcode (optional, for IDE auto-launch)
Agent Modes
KoteGuard supports three ways to run the Copilot agent. Set the default in ~/.kote/config.toml or override per session with kote prep --agent-mode.
| Mode | How it runs | kote cli output |
|---|---|---|
copilot-cli (default) |
Terminal binary with --deny-tool security flags |
Full copy-pasteable command |
copilot-plugin |
IDE chat panel (Android Studio, VS Code) | Open IDE at worktree path |
none |
Instructions injected only โ bring your own agent | cd <worktree> |
Set default in ~/.kote/config.toml:
agent_mode = "copilot-cli" # copilot-cli | copilot-plugin | none
android_cli_enabled = true
Override per session:
kote prep --agent-mode copilot-plugin
Contributing
git clone https://github.com/alisen/KoteGuard.git
cd KoteGuard
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest # 196 tests, all green
License
MIT ยฉ Alishen
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file koteguard-1.0.0a1.tar.gz.
File metadata
- Download URL: koteguard-1.0.0a1.tar.gz
- Upload date:
- Size: 65.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69b3c0b420f8c0ef40359f1fadf9e85d8db49fc1b5377e842256a51358c68775
|
|
| MD5 |
6b9099ca748197f95695d5a0ccf56d45
|
|
| BLAKE2b-256 |
3800763ee2e7e77406aaac456e788509d28deded7abba4f2d58c1f8a44dc6c5e
|
File details
Details for the file koteguard-1.0.0a1-py3-none-any.whl.
File metadata
- Download URL: koteguard-1.0.0a1-py3-none-any.whl
- Upload date:
- Size: 53.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c347855f83bd500abaf9197df4216e45cd31da473b0b5cc9ff290e8ea7f3e0e
|
|
| MD5 |
0e57fe9f34b366f0f7b624d639009c50
|
|
| BLAKE2b-256 |
81f8915ab6def2f34aeae0540aa8582ce18e42bec7c4249531f3b645c153a183
|