agentleFS
tky0065tky0065/cortex/.github/copilot-instructions.md

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
  1. Very specific:

    Create src/workflows/<wf>/agents/<role>.rs — async pub fn run(...) that returns Result<String>

    line 53
  2. Very specific:

    Call providers::model_for_role("<role>", &options.config)?

    line 56
  3. Very specific:

    Create src/workflows/<name>/mod.rs implementing #[async_trait] impl Workflow

    line 60

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

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 to cortex.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 fmt

Architecture

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 completion

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), resume_rx/resume_tx (interactive pause), auto, verbose.

Dev workflow phases (the canonical example):

  1. CEO → brief (string)
  2. PM → specs.md (written to project_dir)
  3. Tech Lead → architecture.md (includes FILES_TO_CREATE section)
  4. Developer workers — parallel, semaphore-bounded, each writes one file
  5. QA ↔ Developer loop — capped by config.limits.max_qa_iterations (default 5); QA approves with RECOMMENDATION: APPROVE
  6. 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

  1. Create src/workflows/<wf>/agents/<role>.rs — async pub fn run(...) that returns Result<String>
  2. Load the system prompt with const PREAMBLE: &str = include_str!("../prompts/<role>.md");
  3. Emit TuiEvent::AgentStarted at entry and TuiEvent::AgentDone at exit
  4. Call providers::model_for_role("<role>", &options.config)? for the model name
  5. Register the role in providers::model_for_role() if it's new

Adding a new workflow

  1. Create src/workflows/<name>/mod.rs implementing #[async_trait] impl Workflow
  2. Register it in workflows::get_workflow() match arm
  3. Declare pub mod <name>; in workflows/mod.rs

Security invariants — do not relax

  • Terminal tool (tools/terminal.rs): validate every command against ALLOWED_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 = 4

Output directory

Workflow output lands in ./cortex-output/<slugified-prompt>/ relative to the working directory where cortex was invoked.

DOCUMENTATION

  • Updated README.md and site if we added new features or changed usage instructions.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.