Skip to main content

Role-based, scoped AI query/edit operations for any codebase.

Project description

scoped-agent-control

scoped-agent-control is a framework for enforcing role-based, scoped AI interactions with a codebase.

It allows teams to define exactly who can read or modify which parts of a repository and under what constraints. Simple inline annotations and a repo-level config enable AI agents (e.g. Claude Code, Codex, etc.) to operate within approved, role-specific boundaries.

In practice, this enables non-technical users (e.g. PMs, GTM, etc.) to safely make targeted changes without risking unintended or disallowed side effects across the system.

Install

pipx install git+https://github.com/Shriram-Vasudevan/scoped-agent-control
# or
uv tool install git+https://github.com/Shriram-Vasudevan/scoped-agent-control

Both put scoped-control on PATH globally. Requires Python 3.12+.

For local development:

git clone https://github.com/Shriram-Vasudevan/scoped-agent-control
cd scoped-agent-control
uv sync --dev
uv run scoped-control

Quick start

cd path/to/any/repo
scoped-control

The TUI opens. On first run, a wizard asks four questions — role name, description, what to read, what to edit. Press Enter to accept defaults. Setup writes .scoped-control/config.yaml and drops into the main console.

Commands

Type slash commands at the TUI prompt:

Command Purpose
/setup (or /init) Guided role wizard
/role list | add | edit | remove Manage roles
/surface list | show <id> Inspect indexed surfaces
/scan Rebuild the index
/query <role> <request> Scoped read
/edit <role> <request> Scoped edit with enforcement
/annotate --role <name> Add file-scope annotations
/cleanup --dry-run | --force Remove all artifacts
/install claude-code | github | slack Install integrations
/help, /clear, /quit TUI controls

The same commands work as CLI subcommands without the slash:

scoped-control role list
scoped-control query maintainer "explain the auth flow"
scoped-control edit recruiter "update the careers intro" --executor codex

CLI-only commands (long-running or guided):

Command Purpose
triage <request> Classify a request without running it
install slack-bot Guided Slack bot setup with auto-tunneling
serve-slack Run the Slack bot server
remote-edit --event-file <path> Process a GitHub remote-edit payload
remote-triage --event-file <path> Process a GitHub remote-triage payload

End-to-end example

$ cd ~/my-repo
$ scoped-control
# Wizard:
#   Role name → recruiter
#   Description → Recruiting copy editor
#   Read → careers folder and hiring docs
#   Write → only careers/**/*.md
# Output: Role `recruiter` created.

# In the TUI prompt:
> /query recruiter what does the careers intro say
> /edit recruiter update the careers intro to mention remote work

# Or from a shell:
$ scoped-control triage "refactor src/auth.py"
Triage decision: mode=blocked role=None
Reason: No configured role has edit access to the requested target(s).

Slack bot

scoped-control install slack-bot

A guided five-step flow:

  1. Starts a public tunnel (cloudflared preferred, ngrok fallback).
  2. Prints a Slack app manifest with the URL pre-filled.
  3. Prompts for the Signing Secret.
  4. Waits for "Install to Workspace" in the Slack admin UI.
  5. Smoke-tests the round trip and prints a team announcement template.

Total time: ~3 minutes. Requires cloudflared or ngrok on PATH. The tunnel URL is valid only while the process runs; production deployments need a stable domain.

GitHub workflows

scoped-control install github

Writes two workflow_dispatch workflows:

  • scoped-control.yml — explicit role + request.
  • scoped-control-triage.yml — triage picks the role and mode from a request alone.

Add ANTHROPIC_API_KEY and/or OPENAI_API_KEY as Actions secrets before running.

Claude Code slash commands

scoped-control install claude-code

Writes .claude/commands/sc-{setup,triage,query,edit,surfaces}.md. The slash commands work inside any Claude Code session in the repo.

Annotations

Setup writes config only; no files are modified. Files matching a role's globs are accessible without per-file annotations — the resolver synthesizes whole-file surfaces on demand.

Annotations are inline overrides for two cases:

  • Carve-outs — restrict one file to a narrower role than its directory's role.
  • Span rules — invariants: span_scope limits edits to a specific function or class.
# surface: core.compute_total
# roles: maintainer
# modes: query, edit
# invariants: span_scope
def compute_total(items):
    ...

Fields: surface, roles, modes, invariants, depends_on. # and // comment styles supported.

Apply with /annotate --role <name> or scoped-control setup --annotate-files.

Enforcement

Edits run in a sandbox workspace and pass through:

  • Scope — target file matches edit_paths.
  • Span — modifications stay within the target surface's line range.
  • Diff limitlimits.max_changed_files, limits.max_diff_lines.
  • Validators — commands listed under validators: with mode edit.

Failures roll back the sandbox and surface the reason.

Configuration

.scoped-control/config.yaml:

roles:
  - name: recruiter
    description: Recruiting copy editor
    query_paths: ["careers/**"]
    edit_paths: ["careers/**/*.md"]

limits:
  max_changed_files: 5
  max_diff_lines: 400

validators:
  - name: lint
    command: "ruff check"
    modes: [edit]

Testing

uv run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scoped_agent_control-0.2.0.tar.gz (70.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scoped_agent_control-0.2.0-py3-none-any.whl (92.8 kB view details)

Uploaded Python 3

File details

Details for the file scoped_agent_control-0.2.0.tar.gz.

File metadata

  • Download URL: scoped_agent_control-0.2.0.tar.gz
  • Upload date:
  • Size: 70.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scoped_agent_control-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2673361d1bde1df1eaa7d0a397e732950c7452045a18c299b21aca071053ec49
MD5 c4967943569ae1ddc1e590599ae52404
BLAKE2b-256 51daf92d19ea6eab7e46386994dcc196adaac8953a0989e5fe1d43ec79ee4e88

See more details on using hashes here.

Provenance

The following attestation bundles were made for scoped_agent_control-0.2.0.tar.gz:

Publisher: publish-pypi.yml on Shriram-Vasudevan/scoped-agent-control

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scoped_agent_control-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for scoped_agent_control-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a94769448be6115559156b3a9a6388e32e6d196a9c09c522e9e766b37bf72a4
MD5 d86390d4028fba79705eaaccc5e48cc7
BLAKE2b-256 e7350135dc9ca47094e9c8d05d4ab715b9f7d8caecd9d52a9b7b8328b7f1fe88

See more details on using hashes here.

Provenance

The following attestation bundles were made for scoped_agent_control-0.2.0-py3-none-any.whl:

Publisher: publish-pypi.yml on Shriram-Vasudevan/scoped-agent-control

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page