agentloop
Copilot instructions1 starsChanged 6 months agoMITView on GitHub
- Reads credentials
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
14 rules. About 0 are common, 6 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 4
Read runtime configuration from dotenv-backed settings in src/config.ts.
- Very specific: line 5
Do not read process.env directly in business logic files when a value exists in appConfig.
- Very specific: line 6
Keep .env.example in sync whenever new configuration keys are introduced.
- Very specific: line 15
Do not reintroduce backward compatibility hacks for missing bindTools unless explicitly required.
- Very specific: line 49
Use the shared logger from src/logger.ts.
- Distinctive: line 53
Keep logger output machine-readable and avoid ad hoc string-only logs.
- Distinctive: line 54
Default destination is stdout.
- Very specific: line 57
Avoid eval in production tool implementations.
- Distinctive: line 58
When adding external API tools, validate input and handle failures explicitly.
- Distinctive: line 59
Prefer deterministic outputs for tests and mocked tool responses.
- Very specific: line 62
Run tests with npx jest; use --testPathPatterns (not --testPathPattern) for filtering in Jest v30+.
- Very specific: line 63
Keep src/__tests__/index.test.ts compatible with current runtime behavior, including bindTools mocking.
- Distinctive: line 64
When tool execution behavior changes, add or update tests for:
- Distinctive: line 72
Update README.md after changing dependencies, runtime architecture, config keys, or logging behavior.
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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
Copilot Instructions
Runtime Configuration
- Read runtime configuration from dotenv-backed settings in
src/config.ts. - Do not read
process.envdirectly in business logic files when a value exists inappConfig. - Keep
.env.examplein sync whenever new configuration keys are introduced.
Tooling Architecture
- Each tool lives in its own file under
src/tools/and exports atoolDefinition: ToolDefinitionobject. ToolRegistry.loadFromDirectory()insrc/tools/registry.tsauto-discovers all.tsfiles that exporttoolDefinition. Adding a new tool file requires no other edits.- Tools are bound to the LLM in
src/index.tsviallm.bindTools(toolRegistry.toLangChainTools())during the lazyensureInitialized()call. - Preserve the two-step tool flow:
- Model requests tool calls.
- Runtime executes tools and appends
ToolMessageentries before final model response.
- Do not reintroduce backward compatibility hacks for missing
bindToolsunless explicitly required.
MCP Integration
- MCP client is in
src/mcp/client.ts(McpClientclass) andsrc/mcp/bridge.ts(registerMcpTools). - Configure servers via
MCP_SERVERSenv var (JSON array of{ name, transport, command?, args?, url? }). - MCP tools are registered into the
ToolRegistryduringensureInitialized()alongside built-in tools.
Security Layer
ToolPermissionManagerinsrc/security.tsenforces blocklist/allowlist and per-tool permission levels ("safe"/"cautious"/"dangerous") before every tool execution.ToolBlockedErrorfromsrc/errors.tsis thrown on rejection and injected as aToolMessagebysrc/index.tsso the LLM can reason about it.- Configure via
AUTO_APPROVE_ALL,TOOL_ALLOWLIST,TOOL_BLOCKLISTenv vars.
Agent Profiles and Skills
- Agent profiles are JSON files under
src/agents/builtin/(and optionallyAGENT_PROFILES_DIR). - Skills are Markdown files under
src/skills/builtin/(and optionallySKILLS_DIR). - Both are auto-loaded during
ensureInitialized(). Profiles can restrict which tools are active, override model/temperature, and set iteration limits. activateProfile()insrc/agents/activator.tsconverts a profile into anAgentRuntimeConfig.
Orchestrator and Subagents
executePlan()insrc/orchestrator.tsruns multi-step plans: simple steps viarunSubagent()directly, complex steps viaSubagentManager.- Supports
resumeFrom(1-based),onStepFailure(retry/skip/abort), and a pluggableCheckpointStore. - Subagent runner is in
src/subagents/runner.ts; planner is insrc/subagents/planner.ts.
Streaming Support
streamWithTools()insrc/streaming.tsis the streaming-capable agent loop.agentExecutor.streaminsrc/index.tsis the public API; it delegates tostreamWithTools.- Enable via
STREAMING_ENABLED=true; the CLI prints tokens as they arrive.
Observability
Tracerinterface andFileTracer/NoopTracerimplementations are insrc/observability.ts.- Inject a custom tracer in tests with
setTracer()exported fromsrc/index.ts. - Configure via
TRACING_ENABLED,TRACE_OUTPUT_DIR,TRACING_COST_PER_INPUT_TOKEN_USD,TRACING_COST_PER_OUTPUT_TOKEN_USD.
Logging Guidelines
- Use the shared logger from
src/logger.ts. - Log tool lifecycle events with structured fields:
- invocation: tool name, call id, arguments
- completion: tool name, call id, response
- Keep logger output machine-readable and avoid ad hoc string-only logs.
- Default destination is stdout; destination and verbosity must stay configurable via dotenv values.
Security and Reliability
- Avoid
evalin production tool implementations. - When adding external API tools, validate input and handle failures explicitly.
- Prefer deterministic outputs for tests and mocked tool responses.
Testing
- Run tests with
npx jest; use--testPathPatterns(not--testPathPattern) for filtering in Jest v30+. - Keep
src/__tests__/index.test.tscompatible with current runtime behavior, includingbindToolsmocking. - When tool execution behavior changes, add or update tests for:
- no-tool response path
- tool-called path
- tool response re-injection path
ts-jestwithisolatedModules: trueintsconfig.jsonis required to prevent OOM during tests.- ESM-only transitive deps are shimmed via
moduleNameMapperinpackage.json(seetests/jest-shims/).
Documentation
- Update
README.mdafter changing dependencies, runtime architecture, config keys, or logging behavior.
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.

