polyclaw
AGENTS.md87 starsChanged 10 months agoMITView on GitHub
Polyclaw is an autonomous AI copilot built on the GitHub Copilot SDK. It runs outside the IDE: browser, terminal, messaging apps, and phone calls. The codebase has three main surfaces: a Python backend (app/runtime/), a React + TypeScript frontend (app/frontend/), and a Node.js terminal UI (app/tui/). Production code uses relative imports (from ..config.settings import cfg). Test code uses absolute imports (from app.runtime.config.settings import Settings).
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository4 other files it gives its agents.
- daily-briefingSkill
- note-takingSkill
- summarize-urlSkill
- web-searchSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
14 rules. About 0 are common, 5 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 24
Every file starts with from __future__ import annotations.
- Very specific: line 25
Use PEP 604 union syntax (str | None) instead of Optional[str].
- Very specific: line 26
Use collections.abc for abstract types (Callable, Awaitable), not typing equivalents.
- Very specific: line 28
Use %-style formatting in log calls (lazy evaluation), never f-strings.
- Very specific: line 60
Async bridging: Use run_sync() helper to run blocking code in an executor.
- Very specific: line 63
Immutable collections: Use frozenset for constant sets (SECRET_ENV_KEYS, _QUIET_PATHS).
- Very specific: line 74
Always attach exc_info=True to warning/error calls that catch exceptions.
- Very specific: line 85
Test files mirror source: test_<module>.py.
- Distinctive: line 97
No component library -- all custom HTML + CSS.
- Very specific: line 104
All functional components using named function declarations: export default function TopBar({ onTogglePanel }: Props).
- Distinctive: line 177
Keep dependencies minimal.
- Distinctive: line 178
Prefer composition over inheritance.
- Distinctive: line 179
Use dispatch tables over long if/elif chains.
- Distinctive: line 180
Every module has a single-line docstring describing its purpose.
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md -- Custom Instructions for Polyclaw
Project Overview
Polyclaw is an autonomous AI copilot built on the GitHub Copilot SDK. It runs outside the IDE: browser, terminal, messaging apps, and phone calls. The codebase has three main surfaces: a Python backend (app/runtime/), a React + TypeScript frontend (app/frontend/), and a Node.js terminal UI (app/tui/).
Repository Layout
app/runtime/ Python backend (aiohttp, Copilot SDK, Azure integrations)
app/frontend/ React 19 + TypeScript SPA (Vite, Playwright E2E)
app/tui/ Ink-based terminal UI (TypeScript)
plugins/ Plugin packs (PLUGIN.json + skill markdown files)
skills/ Built-in skill definitions (SKILL.md with YAML frontmatter)
docs/ Hugo documentation site
scripts/ Shell helpers for local devPython Backend (app/runtime/)
Style and Tooling
- Ruff enforces style: line-length 100, target Python 3.11, rules
E,W,F,I(isort),UP(pyupgrade). - Every file starts with
from __future__ import annotations. - Use PEP 604 union syntax (
str | None) instead ofOptional[str]. - Use
collections.abcfor abstract types (Callable,Awaitable), nottypingequivalents. - Annotate every function signature fully, including
-> Noneon void functions. - Use
%-style formatting in log calls (lazy evaluation), never f-strings.
Imports
from __future__ import annotations- Standard library
- Third-party packages
- Relative imports for intra-package references
Production code uses relative imports (from ..config.settings import cfg). Test code uses absolute imports (from app.runtime.config.settings import Settings).
Naming
| Element | Convention | Example |
| Modules | snake_case | event_handler.py |
| Private modules | Leading underscore | _json_store.py |
| Classes | PascalCase | EventHandler, McpConfigStore |
| Functions/methods | snake_case | build_system_prompt() |
| Private methods | Leading underscore | _handle_delta() |
| Constants | UPPER_SNAKE_CASE | MAX_START_RETRIES |
| Module-level private constants | _UPPER_SNAKE_CASE | _BUILTIN_SERVERS |
Architecture Patterns
- Configuration: Singleton
cfg = Settings()accessed viafrom ..config.settings import cfg. Reads from.envfile andos.getenv, with@kv:prefix for Azure Key Vault resolution. - State stores: JSON-file-backed, built on
_json_store.JsonStorewiththreading.Lockfor thread safety. One store class per concern (e.g.,McpConfigStore,SessionStore). - Singletons: Module-level
_instance: T | None = Nonewithget_*()factory and_reset_*()teardown registered viaregister_singleton()for test isolation. - Route handlers: One class per feature area with a
register(router)method. App wired inAppFactory.build(). - Error responses: JSON envelope
{"status": "error", "message": "..."}with appropriate HTTP codes. - Tools: Defined with
@define_tooldecorator +pydantic.BaseModelfor parameter schemas. - Event dispatch: Dict-based dispatch table (
_DISPATCH_TABLE) mapping event types to handler methods, not if/elif chains. - Async bridging: Use
run_sync()helper to run blocking code in an executor. Background loops viaasyncio.create_task(). - Safe teardown: Wrap cleanup in
_safe_*()methods that catch all exceptions to prevent cascade failures. Resulttype: Frozen dataclass withok()/fail()constructors and boolean evaluation for operations that can fail.- Immutable collections: Use
frozensetfor constant sets (SECRET_ENV_KEYS,_QUIET_PATHS).
Logging
logger = logging.getLogger(__name__)
logger.info("[module.action] key=%s value=%r", key, value)- One
loggerper module. - Bracket-prefixed context tags:
[agent.start],[chat.dispatch]. - Always attach
exc_info=Trueto warning/error calls that catch exceptions.
Error Handling
ValueErrorfor validation errors, caught at API boundaries and returned as 400.RuntimeErrorfor precondition failures.- Defensive
except Exceptionwith log-and-continue for non-critical paths (fallback to defaults).
Testing
- pytest with
pytest-asyncio(asyncio_mode = "auto"). - Test files mirror source:
test_<module>.py. - Group related tests in
class Test<Topic>:withtest_<scenario>methods. - Isolation via
autousefixtures:_isolate_data_dir(tmp_path + monkeypatch),_reset_singletons. - Mock with
unittest.mock.patch/AsyncMock/MagicMock, applied as decorators. - Route tests use
aiohttp.test_utils.TestClient. - Mark slow tests with
@pytest.mark.slow(skipped unless--run-slow).
Frontend (app/frontend/)
Style and Tooling
- React 19 + TypeScript (strict mode) + Vite.
- No component library -- all custom HTML + CSS.
- Single global CSS file with BEM-like class naming (
block__element--modifier). - CSS custom properties for design tokens (
--gold,--surface,--radius). - Dark theme only.
Components
- All functional components using named function declarations:
export default function TopBar({ onTogglePanel }: Props). - Props defined via local
interface Propsabove the component. NoReact.FC. - Sub-components are non-exported
functiondeclarations co-located in the same file. - Pages are lazy-loaded with
lazy(() => import(...))+<Suspense>. - React Router v7 with
BrowserRouter.
State Management
useState/useCallback/useRefonly. No global state library.- Custom hooks return plain objects:
{ authenticated, loading, login, logout }. - Side effects in
useEffectwith cleanup returns.
File Naming
| Type | Convention | Example |
| Components | PascalCase.tsx | TopBar.tsx |
| Hooks | camelCase.ts with use prefix | useAuth.ts |
| Pages | PascalCase.tsx | SetupWizard.tsx |
| Utilities | camelCase.ts | api.ts, types.ts |
API Layer
- Central
api<T>(path, opts)generic wrapper aroundfetchwith Bearer auth fromlocalStorage. apiFormData()for multipart uploads.createChatSocket()returning aChatSocketinterface for WebSocket.- Mock mode via
VITE_MOCK=1.
Types
- Centralized in
types.ts. Useinterfacefor object shapes,typefor unions. import typefor type-only imports.
Testing
- Playwright E2E only (no unit tests).
mockApi(page)andbypassAuth(page)helpers for test isolation.- Mock data constants prefixed with
MOCK_.
Plugins and Skills
Skills
Markdown files named SKILL.md with YAML frontmatter:
---
name: web-search
description: 'Search the web using a search engine'
metadata:
verb: search
---Body contains natural-language instructions for the agent.
Plugins
Directory with PLUGIN.json manifest:
{
"id": "foundry-agents",
"name": "Microsoft Foundry Agents",
"skills": ["foundry-code-interpreter", "foundry-agent-chat"],
"dependencies": { "cli": ["az"], "pip": ["azure-ai-projects"] }
}Plugins bundle multiple skills and declare their dependencies.
General Principles
- Keep dependencies minimal. No unnecessary frameworks or libraries.
- Prefer composition over inheritance.
- Use dispatch tables over long if/elif chains.
- Every module has a single-line docstring describing its purpose.
- Security defaults to locked-down: auth required on all API routes, whitelist-based channel access.
- Deferred imports to break circular dependencies when needed.
- Thread-safe file I/O via locks in shared stores.
__all__in__init__.pyfiles to control public API surface.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

