cortex
Copilot instructions4 starsChanged 6 months agoMITView on GitHub
Cortex is an agentic CLI written in Rust that simulates a software development company. Given a natural-language idea, it orchestrates specialized AI agents to produce a deployable Git repository. Event bus: TuiEvent is sent over an mpsc::UnboundedSender<TuiEvent> (TuiSender) that flows from agents through the orchestrator to the TUI renderer. Every agent must emit AgentStarted / AgentDone around its LLM call. RunOptions is the single struct threaded through every workflow and agent. It carries: config, tx (TUI sender), project_dir, cancel (CancellationToken),…
The file
We split this copilot-instructions.md into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 53
Create src/workflows/<wf>/agents/<role>.rs — async pub fn run(...) that returns Result<String>
- Very specific: line 56
Call providers::model_for_role("<role>", &options.config)?
- Very specific: line 60
Create src/workflows/<name>/mod.rs implementing #[async_trait] impl Workflow
≈ “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
What is Cortex
Cortex is an agentic CLI written in Rust that simulates a software development company. Given a natural-language idea, it orchestrates specialized AI agents to produce a deployable Git repository.
- REPL mode (default):
cargo run— slash commands/start,/status,/abort,/continue - One-shot mode:
cargo run -- start "<idea>" --auto [--workflow dev|marketing|prospecting|code-review] - Resume:
cargo run -- resume <project-dir> - Verbose logging: any subcommand accepts
-v(writes tocortex.log)
Commands
cargo build
cargo run
cargo check # fast type/borrow check — use frequently
cargo test # all tests
cargo test <test_name> # single test, e.g. `cargo test rejects_unlisted_command`
cargo clippy -- -D warnings # lint; warnings are errors
cargo fmtArchitecture
Orchestrator
└── Box<dyn Workflow> (resolved by get_workflow("dev"|"marketing"|…))
└── runs agents sequentially (or parallel via tokio::spawn + Semaphore)
└── each agent calls providers::model_for_role() → LLM completionEvent bus: TuiEvent is sent over an mpsc::UnboundedSender<TuiEvent> (TuiSender) that flows from agents through the orchestrator to the TUI renderer. Every agent must emit AgentStarted / AgentDone around its LLM call.
RunOptions is the single struct threaded through every workflow and agent. It carries: config, tx (TUI sender), project_dir, cancel (CancellationToken), resume_rx/resume_tx (interactive pause), auto, verbose.
Dev workflow phases (the canonical example):
- CEO → brief (string)
- PM →
specs.md(written toproject_dir) - Tech Lead →
architecture.md(includesFILES_TO_CREATEsection) - Developer workers — parallel, semaphore-bounded, each writes one file
- QA ↔ Developer loop — capped by
config.limits.max_qa_iterations(default 5); QA approves withRECOMMENDATION: APPROVE - DevOps → Dockerfile, docker-compose, git commit
Interactive pauses (when !opts.auto) use tokio::select! on wait_for_resume() + cancel.cancelled().
Key Conventions
File-as-memory pattern
Agents never receive the full accumulated transcript. Downstream agents read their inputs from disk (specs.md, architecture.md) via FileSystem::read(). This keeps context windows bounded. Context budget per call is configured in config.toml under [limits].
Adding a new agent to an existing workflow
- Create
src/workflows/<wf>/agents/<role>.rs— asyncpub fn run(...)that returnsResult<String> - Load the system prompt with
const PREAMBLE: &str = include_str!("../prompts/<role>.md"); - Emit
TuiEvent::AgentStartedat entry andTuiEvent::AgentDoneat exit - Call
providers::model_for_role("<role>", &options.config)?for the model name - Register the role in
providers::model_for_role()if it's new
Adding a new workflow
- Create
src/workflows/<name>/mod.rsimplementing#[async_trait] impl Workflow - Register it in
workflows::get_workflow()match arm - Declare
pub mod <name>;inworkflows/mod.rs
Security invariants — do not relax
- Terminal tool (
tools/terminal.rs): validate every command againstALLOWED_COMMANDS = ["cargo", "go", "npm", "pip", "git", "docker"]before execution. LLM output is untrusted input. - Filesystem tool (
tools/filesystem.rs): reject../path traversal; all I/O must stay within the project output directory.
QA loop tracking
Track iteration count in the orchestrator / workflow (for iteration in 0..max_iterations), never inside an agent.
Provider routing
providers::model_for_role() maps role strings to model names from Config. Unknown roles return an error. Code-review workflow roles (reviewer, security, performance, reporter) fall back to the qa model.
Config file
~/.cortex/config.toml — loaded once at startup via Config::load(), then shared as Arc<Config>.
[provider]
default = "ollama"
[models]
ceo = "ollama/qwen2.5-coder:32b"
developer = "ollama/qwen2.5-coder:32b"
qa = "ollama/qwen2.5-coder:14b"
[limits]
max_qa_iterations = 5
max_tokens_per_call = 8192
max_parallel_workers = 4Output directory
Workflow output lands in ./cortex-output/<slugified-prompt>/ relative to the working directory where cortex was invoked.
DOCUMENTATION
- Updated
README.mdandsiteif we added new features or changed usage instructions.
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.

