sruja
AGENTS.md24 starsChanged 6 months agoApache-2.0View on GitHub
This guide helps AI agents work effectively with the Sruja codebase. Procedural workflow instructions belong in .sruja/loop.toml [pipeline], not in natural language. See [PipelineConfig] for the explicit stage model that drives the agent loop. This file contains knowledge and context, not step-by-step procedures. Use this workflow to set up architecture enforcement for any repository. No separate API key needed — the AI agent provides the intelligence, sruja provides the tools. Call sruja_classify with a classification JSON that you (the AI…
- Installs packages
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,773 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 repository14 other files it gives its agents.
- .gemini/AGENTS.mdAGENTS.md
- skills/sruja-architecture/AGENTS.mdAGENTS.md
- skills/sruja-architecture/references/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/cli-handler.mdcCursor rule
- .cursor/rules/core-engine.mdcCursor rule
- .cursor/rules/extension-ts.mdcCursor rule
- .cursor/rules/sruja-context-host.mdcCursor rule
- .cursor/rules/sruja-dev.mdcCursor rule
- .cursor/rules/wasm-constraints.mdcCursor rule
- grill-meSkill
- sruja-architectureSkill
- sruja-harnessSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
62 rules. About 0 are common, 13 are distinctive, and 49 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
49
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 31
Use this workflow to set up architecture enforcement for any repository.
- Very specific: line 43
Call sruja_classify with a classification JSON that you (the AI agent) have determined:
- Very specific: line 102
Run sruja check -r . before merging
- Distinctive: line 109
Use this for non-trivial work (new features, multi-file refactors, tricky bugs).
- Distinctive: line 149
Scoped reads: search, then open only the files you need.
- Distinctive: line 150
Isolated exploration: use a read-only subagent or a short side thread for wide research, then bring back a short summary and file list—not …
- Very specific: line 152
Do not paste full repo.sruja or entire sruja ai briefs into chat when the ladder or focus briefing suffices.
- Very specific: line 178
Do: Use sruja agent loop for autonomous coding tasks against a workspace.
- Very specific: line 179
Do: Use Sruja's deterministic gates (lint, drift, intent check, focus) and MCP tools within your editor host for interactive work.
- Very specific: line 183
Do not: Treat agent apply outputs as reviewed truth — always merge proposals into repo.sruja through manual review.
- Very specific: line 185
Do not: Run agent loop against a production branch without a loop manifest bounding scope and budget.
- Very specific: line 199
Only learnings in surfaced_learning_ids (token-budget subset from focus) get counters — not every find_relevant match.
- Distinctive: line 206
When an agent ships wrong code, misleading edits, or misses a project convention, fix the process layer when the miss is repeatable—not …
- Distinctive: line 208
Before the next task, ask whether any of these should change:
- Distinctive: line 216
Commit those updates like code so the whole team benefits.
- Very specific: line 319
Use use with full paths where appropriate
- Very specific: line 320
Use pub use to re-export commonly used types
- Very specific: line 325
Use #[cfg(test)] for test modules
- Very specific: line 326
Keep lib.rs as public API surface, impl details in other files
- Very specific: line 329
Use Result<T, Box<dyn std::error::Error>> for simple cases
- Very specific: line 330
Use thiserror for custom error types
- Very specific: line 331
Use ? operator for propagation
- Very specific: line 335
Use #[serde(rename_all = "snake_case")] for enums
- Very specific: line 336
Use #[derive(Serialize, Deserialize)] for serializable types
- Distinctive: line 342
Use descriptive test names
- Distinctive: line 343
Test edge cases and error paths
- Very specific: line 355
Use import * as for namespaces
- Distinctive: line 358
Use async/await for async operations
- Very specific: line 360
Use nullish coalescing ?? and optional chaining ?
- Very specific: line 362
Use undefined consistently, avoid null where possible
- Distinctive: line 368
Use OutputChannel for user-facing messages
- Very specific: line 386
Use dot notation to reference nested elements: System.Container, System.Container.Component.
- Very specific: line 389
Every component must have a description field.
- Very specific: line 391
Use person for human actors only.
- Very specific: line 392
Use system for external software (APIs, SaaS).
- Very specific: line 393
Use database (not datastore) for data stores.
- Distinctive: line 398
Use specific, descriptive labels ("HTTPS", "REST API", "publishes events to").
- Distinctive: line 400
Avoid circular dependencies between systems.
- Very specific: line 410
After every code iteration (each time you apply an edit to a .sruja file) in VS Code or Cursor:
- Very specific: line 424
Run cargo fmt for Rust and follow EditorConfig rules.
- Very specific: line 441
Add @element and @layer annotations in //!
- Distinctive: line 456
Keep annotations in the first 5 lines of the doc comment for discoverability
- Very specific: line 457
Use sruja focus --file <path> to resolve file-to-element mappings at runtime
- Very specific: line 467
When working on Sruja:
- Very specific: line 468
First Time Setup: Run just setup (or make setup) to ensure all dependencies and git hooks are correctly installed.
- Very specific: line 470
Dogfooding the Architecture: Before proposing significant PRs, always respect docs/architecture/*.sruja as the "reviewed truth".
- Very specific: line 471
Run just check (or make check) before committing to ensure consistent formatting, linting, and passing tests.
- Very specific: line 473
Use cargo clippy -- -D warnings for strict linting.
- Very specific: line 475
Test CLI commands with just test-cli-smoke (or make test-cli-smoke).
- Very specific: line 532
Architecture Setup: Run sruja classify -r . to generate .sruja/classification.json, then sruja sync-ide-rules -r .
- Very specific: line 533
Daily Context Sync: Run just daily (or make daily) to check for architectural drift and update IDE context.
- Very specific: line 534
Manual Sync: Run sruja sync-ide-rules -r .
- Very specific: line 538
Cross-Repo Context: Use sruja ai-context -r repoA -r repoB to dynamically build context payloads when working on multi-repo features.
- Very specific: line 540
When using AI agents, leverage Sruja's context tools:
- Very specific: line 565
"Command Not Found": Ensure you've run just build (or make build) and the target/release directory is populated.
- Very specific: line 566
"Invalid DSL": Run sruja lint <file> and paste the JSON error output to the assistant.
- Very specific: line 567
"Drift Detected": Run sruja check -r . --fix (if available) or manually align .sruja with code.
- Very specific: line 568
"WASM Mismatch": If logic changed in sruja-language but extension behavior is old, run just wasm-nodejs (or make wasm-nodejs).
- Very specific: line 574
When the user types /graphify, invoke the skill tool with skill: "graphify" before doing anything else.
- Very specific: line 579
If graphify-out/wiki/index.md exists, use it for broad navigation instead of raw source browsing.
- Very specific: line 580
Read graphify-out/GRAPH_REPORT.md only for broad architecture review or when query/path/explain do not surface enough context.
- Very specific: line 581
After modifying code, run graphify update .
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 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
This guide helps AI agents work effectively with the Sruja codebase.
Procedural workflow instructions belong in
.sruja/loop.toml [pipeline], not in natural language. See [PipelineConfig] for the explicit stage model that drives the agent loop. This file contains knowledge and context, not step-by-step procedures.
Table of Contents
- Quick Reference
- Architecture Setup
- Before Coding: Shared Understanding
- AI Agent Workflow
- Code-Embedded Architecture Metadata
- Build, Lint, and Test Commands
- Code Style Guidelines
- Editor-Specific Configs
- Troubleshooting
⚡ Quick Reference (Top 5 Commands)
| Command | Purpose |
make setup / just setup | First-run setup (install deps, hooks, build) |
make check / just check | Pre-commit check (fmt + lint + test) |
make daily / just daily | Sync context + check diagnostic drift |
sruja focus | Task briefing (blast radius, decisions, AI info) |
sruja mcp -r . | Start MCP server for deep context queries |
Architecture Setup (AI Agent Workflow)
Use this workflow to set up architecture enforcement for any repository. No separate API key needed — the AI agent provides the intelligence, sruja provides the tools.
Step 1: Understand the codebase
sruja_list_architecture_index → get structure
sruja_get_topology → get dependencies
sruja_get_repomap → get file overviewStep 2: Classify the architecture
Call sruja_classify with a classification JSON that you (the AI agent) have determined:
{
"schema_version": "classification/v1",
"project_type": "rust-workspace",
"summary": { "crates": 14, "source_files": 500 },
"layers": [
{ "name": "Core Engine", "members": ["sruja-language", "sruja-engine"] },
{ "name": "Delivery", "members": ["sruja-cli", "sruja-wasm"] }
],
"boundaries": [
{ "from": "sruja-language", "to": "sruja-cli", "allowed": false, "reason": "Core should not depend on CLI" }
],
"forbidden_patterns": [
"Lower-tier crates must not depend on higher-tier crates"
]
}Or run sruja classify -r . for heuristic classification (Rust workspaces only).
Step 3: Generate IDE context
sruja_sync_ide_rules → generates .cursorrules, copilot-instructions.md, llms-architecture.txtStep 4: Verify
sruja_check_drift → verifies architecture rulesMCP Tools Available
| Tool | Purpose |
sruja_classify | Generate or set classification (accepts JSON from agent) |
sruja_sync_ide_rules | Generate IDE context from classification |
sruja_list_architecture_index | List architecture elements |
sruja_get_topology | Get upstream/downstream dependencies |
sruja_get_elements | Get element details |
sruja_check_drift | Check architecture enforcement |
sruja_check_violations | Validate changes against boundaries |
Before Coding: Shared Understanding
IMPORTANT: AI produces garbage without shared understanding. The pipeline config (.sruja/loop.toml [pipeline]) defines the deterministic workflow stages. The natural language in this file provides knowledge — it does not override the pipeline.
Anti-Patterns to Avoid
- ✗ Generating code without clear intent
- ✗ Running compiler repeatedly to fix AI errors
- ✗ Shipping code you can't explain in a post-mortem
- ✗ Merging AI output without verification
Code Quality Gates
- Run
sruja check -r .before merging - Track code churn with
./scripts/code-churn.sh - For Dependabot majors and MSRV-sensitive upgrades, follow docs/MSRV_AND_DEPENDENCIES.md
- Review security with
./target/release/sruja lint(if applicable)
AI agent workflow (multi-step tasks)
Use this for non-trivial work (new features, multi-file refactors, tricky bugs). Skip for one-line fixes.
Two layers of planning
- Project or scope layer — What problem are we solving and what is in or out of scope? Sources: GitHub issue / Jira epic, ADR,
docs/architecture/*.sruja,repo.sruja, product notes. Stay high level: user-visible behavior, boundaries, dependencies between initiatives. Do not pick implementation files yet. - Task layer — For a single issue or PR: which crates, modules, and tests change, in what order, and how will we validate? This is the implementation plan for this change only.
Keeping the layers separate avoids baking file-level guesses into scope docs and avoids treating a ticket as full product discovery.
AI-DLC + workflow (full SDLC gates)
For AWS AI-DLC–style inception → construction → operations with Sruja gates, use sruja workflow (init --with-aidlc, status --check, install-rules, design-review). See docs/AIDLC_INTEGRATION.md and .cursor/commands/sruja-workflow-aidlc.md.
Artifact handoffs
Move work between humans and agents with one primary artifact per stage, so intent stays reviewable:
| Stage | Typical artifact |
| Scope | Issue body, epic, or short doc under docs/ |
| Architecture alignment | docs/architecture/*.sruja or repo.sruja updates when boundaries move |
| Task plan | Issue update, PR description section, or a plan.md in the branch (especially if multiple agents touch the same work) |
Review each artifact before the next stage. Passing tests alone is not a substitute for checking the artifact matches intent.
Session hygiene
Long exploratory chats accumulate bias and stale assumptions. After you have a written task plan you are satisfied with:
- Start a new agent conversation for implementation, and paste or point the model only at the plan plus minimal pointers (issue link, file paths). The new session should implement from the plan, not re-derive scope from the entire old thread.
Trivial edits can stay in one session.
Research without flooding context
Broad repo exploration produces large token dumps. Prefer:
- MCP progressive disclosure (in the IDE):
sruja_list_architecture_index→sruja_get_topology→sruja_get_elements— each step returnsestimated_tokensandnext_suggested_tool sruja focus --file <path>(or the issue scope) for a compact briefing when MCP is unavailablesruja ai-context -f for-ai --cache-friendlyfor prompt-cache-ordered invariant/volatile JSON (single repo only)- Scoped reads: search, then open only the files you need; summarize for the main thread
- Isolated exploration: use a read-only subagent or a short side thread for wide research, then bring back a short summary and file list—not raw dumps
Do not paste full repo.sruja or entire sruja ai briefs into chat when the ladder or focus briefing suffices.
Filling the context window “because we can” still hurts quality.
Grounded harness and continual learning
Sruja is a CLI-first autonomous coding agent. It owns the full
observe → act → verify → critique → replan loop via sruja agent loop.
The deterministic layer (verify-task, drift, lint, intent) remains the
independent grader — the actor never grades itself. This is the loop
engineering thesis: the agent that writes code is not the one that evaluates it.
Sruja can also be used as a passive harness (lint, drift, evidence, MCP, agent memory) from any editor host (Cursor, Claude Code, Cline, Windsurf). Both paths coexist. Full guide: docs/GROUNDED_HARNESS_AND_CONTINUAL_LEARNING.md.
CLI agent loop
sruja agent loop --goal "<goal>" drives the full closed-loop agent:
comprehend → plan → execute via tools → critique → replan until approved.
Configuration via CLI flags or .sruja/loop.toml manifest. Bounded by
max_iterations, spend caps, and workspace-scoped file guards.
sruja agent run, agent plan, and agent apply remain as headless/CI
convenience helpers for architecture-bounded validation and evidence authoring.
- Do: Use
sruja agent loopfor autonomous coding tasks against a workspace. - Do: Use Sruja's deterministic gates (
lint,drift,intent check,focus) and MCP tools within your editor host for interactive work. - Do: Leverage Sruja's architecture understanding for intelligent code suggestions in either mode.
- Do not: Treat
agent applyoutputs as reviewed truth — always merge proposals intorepo.srujathrough manual review. - Do not: Run
agent loopagainst a production branch without a loop manifest bounding scope and budget.
Agentic memory utility (.sruja/agent_memory.json)
Learnings are curated skills, not append-only logs.
| Signal | Meaning |
retrieval_count | Learning was injected into context (focus briefing, apply, or MCP fetch) |
task_success_after / task_total_after | After injection, sruja agent run --mode apply finished with all verification steps ok or skipped |
Rules:
- Only learnings in
surfaced_learning_ids(token-budget subset from focus) get counters — not everyfind_relevantmatch. - Plan-only
agent rundoes not bump retrievals; apply records retrievals at apply start and outcomes after verification. - Standalone
sruja focusrecords retrievals (no task outcome — no verification gate). sruja agent curateis suggest-only; useagent update,agent merge,agent delete --forceto act. Merge resets task outcome counters (retrieval history is preserved).
System evolution (outer loop)
When an agent ships wrong code, misleading edits, or misses a project convention, fix the process layer when the miss is repeatable—not only the code diff.
Before the next task, ask whether any of these should change:
AGENTS.md— missing gate, unclear command, wrong default workflow.cursor/rules/*.mdc— file-type or domain-specific constraints the agent ignored- Skills (e.g. under
.agents/skills/or user skill paths) — recurring multi-step procedures belong in a skill, not a one-off wall of text - Cursor project commands (
.cursor/commands/*.md) — stable prompts you use more than a few times - Plan / issue templates — acceptance criteria or validation steps the agent skipped
Commit those updates like code so the whole team benefits.
Cursor commands in this repo
Reusable flows live under .cursor/commands/ (e.g. prime, plan, implement-from-plan, evolve-rules). Prefer invoking them over retyping long procedures.
Build, Lint, and Test Commands
Rust (Core)
# Build all crates
cargo build --release
just build # or: make build
# Run all tests
cargo test --workspace
just test # or: make test
# Run a single test
cargo test test_name
# Run tests in a specific crate
cargo test -p sruja-cli
# Run tests with coverage (excludes sruja-wasm — see docs/WASM_TESTING.md)
just test-coverage # or: make test-coverage
# WASM bindings are tested separately: just test-coverage-wasm (alias for wasm-pack tests)
# CI/script variant with extra llvm-cov flags:
# bash scripts/coverage.sh
# Lint Rust code
cargo clippy -- -D warnings
just lint # or: make lint
# Format Rust code
cargo fmt
just fmt # or: make fmtVS Code Extension (TypeScript)
cd extension
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Run tests
npm test
npm run test:vscode
# Lint (via tsc strict mode)
npm run compileWASM
# Run WASM tests
just test-wasm # or: make test-wasm
cd crates/sruja-wasm && wasm-pack test --node
# Build WASM
just wasm # or: make wasm
just wasm-nodejs # or: make wasm-nodejsE2E Tests
# Build and serve book first in another terminal
just book-serve # or: make book-serve
# Run Playwright E2E
just test-e2e # or: make test-e2e
npm run e2eExtension (VS Code test-electron):
cd extension
# If WASM or language crate changed, copy fresh WASM first:
# (from repo root) bash extension/scripts/copy-assets.sh
npm run test:vscodeCode Style Guidelines
Rust
Naming Conventions:
- Types/Enums: PascalCase (
NodeId,EdgeKind) - Functions/Variables: snake_case (
as_str,from_str) - Constants: SCREAMING_SNAKE_CASE
- Modules: lowercase (
mod severity)
Imports:
- Group external imports first, then internal
- Use
usewith full paths where appropriate - Use
pub useto re-export commonly used types
Code Organization:
- Module-level docs with
//!at top of files - Function docs with
/// - Use
#[cfg(test)]for test modules - Keep
lib.rsas public API surface, impl details in other files
Error Handling:
- Use
Result<T, Box<dyn std::error::Error>>for simple cases - Use
thiserrorfor custom error types - Use
?operator for propagation - Provide context with
context()or.map_err()
Serde:
- Use
#[serde(rename_all = "snake_case")]for enums - Use
#[derive(Serialize, Deserialize)]for serializable types - Consider
#[serde(skip_serializing_if = "Option::is_none")]
Testing:
- Unit tests in
#[cfg(test)]module - Integration tests in
tests/directory - Use descriptive test names
- Test edge cases and error paths
TypeScript (Extension)
Naming Conventions:
- Classes/Interfaces/Types: PascalCase (
DiagnosticCollection) - Functions/Variables: camelCase (
getSrujaPath) - Constants: UPPER_SNAKE_CASE (
DIAGNOSTIC_COLLECTION_ID)
Imports:
- Use ES6 imports
- Group imports: Node stdlib, external libs, internal modules
- Use
import * asfor namespaces
Code Style:
- Use async/await for async operations
- Error handling with try/catch
- Use nullish coalescing
??and optional chaining?. - Type annotations for function parameters and returns
- Use
undefinedconsistently, avoidnullwhere possible
VSCode API:
- Use
vscodenamespace - Register commands and providers in
activate() - Dispose resources properly
- Use OutputChannel for user-facing messages
Sruja DSL (.sruja files)
Structure:
- Define before use – Every referenced component must be defined before use in relationships.
- Pattern –
Id = kind "Label" { ... }(e.g.API = container "API" { ... }). - Nested syntax following C4 hierarchy: Systems at top level, containers nested in systems, components nested in containers.
- Flat top-level declarations only – No
architecture "Name" { }wrapper. - Persons and external systems can be at top level.
- Define kinds at the top of file before using them.
- PascalCase for element IDs.
- Double quotes for all string values.
Nesting Requirements:
container,component,database,queueMUST be nested inside a system.componentMUST be nested inside a container (or system for edge cases).systemandpersoncan be at top level.- Use dot notation to reference nested elements:
System.Container,System.Container.Component.
Components:
- Every component must have a
descriptionfield. - Containers must have
technologyfield (e.g. "PostgreSQL", "React"). - Use
personfor human actors only. - Use
systemfor external software (APIs, SaaS). - Use
database(notdatastore) for data stores. - Unique IDs – Component IDs must be unique.
Relationships:
- Syntax:
source -> target "label". - Use specific, descriptive labels ("HTTPS", "REST API", "publishes events to").
- Reference nested components:
System.Container.Component. - Avoid circular dependencies between systems.
- No orphans – Every component must participate in at least one relationship.
Validation:
sruja lint file.srujaAI Editor UX: Validation
After every code iteration (each time you apply an edit to a .sruja file) in VS Code or Cursor:
- Run validation in the editor – Invoke the command Sruja: Run validation (check after AI/edit). This ensures the file stays valid.
- Or save the file – Saving also triggers validation. For immediate feedback after an AI edit, prefer running the command.
Formatting
All code uses:
- UTF-8 encoding
- LF line endings
- Trim trailing whitespace
- Insert final newline
- 2-space indentation (except Makefiles: tabs)
Run cargo fmt for Rust and follow EditorConfig rules.
Architecture Patterns
The codebase follows a workspace pattern with multiple crates:
- Core: types, diagnostics, language, engine, export
- Product: graph, intent, report, lsp, wasm
- CLI: commands and user interface
WASM is used for browser and Node.js targets. LSP provides language server features.
Code-Embedded Architecture Metadata
Link source code to architecture elements using module-level doc comments. This creates a bidirectional binding that is both human-readable and machine-queryable.
Convention
Add @element and @layer annotations in //! doc comments at the top of each module's lib.rs or mod.rs:
//! @element Sruja.CLI
//! @layer Delivery
//! @boundary CLI must not depend on sruja-wasm internals
//!
//! Command-line interface for Sruja operations.Rules
@element— The architecture element ID fromrepo.sruja(dot notation for nested:Sruja.Context.Scan)@layer— The layer name from classification (Core Engine, Extraction, Delivery, Secondary)@boundary— Optional: specific constraints for this module- Keep annotations in the first 5 lines of the doc comment for discoverability
- Use
sruja focus --file <path>to resolve file-to-element mappings at runtime
Why
Source code cannot express why decisions were made. Code-embedded metadata bridges this gap by linking modules to Decision Records and architecture elements, giving AI agents the context they need without leaving the source file.
Key Commands for AI Agents
For multi-step agent work, follow AI agent workflow (multi-step tasks) above and use .cursor/commands/ when applicable.
When working on Sruja:
- First Time Setup: Run
just setup(ormake setup) to ensure all dependencies and git hooks are correctly installed. - Grounded architecture authoring: For
repo.srujawork, prefer.sruja/author_evidence.json(fromsruja syncorsruja author evidence) or MCPsruja_get_author_evidence. Treat.sruja/graph.jsonas debug/export only—not default agent context. Synthesize proposals under.sruja/proposals/orrepo.sruja.working; promote torepo.srujaonly after human review. See docs/plans/GROUNDED_ARCHITECTURE_AUTHORING_PLAN.md. - Dogfooding the Architecture: Before proposing significant PRs, always respect
docs/architecture/*.srujaas the "reviewed truth". If changing architecture, update those files. Also runsruja status -r .,sruja review -r ., orsruja check -r . -a repo.srujato validate the baseline (repo.sruja). - Run
just check(ormake check) before committing to ensure consistent formatting, linting, and passing tests. - For .sruja files, run
sruja lint file.srujaafter changes. - Use
cargo clippy -- -D warningsfor strict linting. - Build extension with
just build-extension(ormake build-extension). - Test CLI commands with
just test-cli-smoke(ormake test-cli-smoke). - For Rust coverage gaps (CLI handlers, LSP, WASM, tree-sitter) and infrastructure needs, see
docs/internal/TEST_COVERAGE_PLAN.md.
Common Patterns
Rust:
use serde::{Deserialize, Serialize};
use thiserror::Error;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MyType {
pub field: String,
}
#[derive(Error, Debug)]
pub enum MyError {
#[error("not found: {0}")]
NotFound(String),
}TypeScript:
import * as vscode from "vscode";
export async function myFunction(): Promise<void> {
try {
const result = await operation();
return result;
} catch (err) {
vscode.window.showErrorMessage(`Error: ${err}`);
}
}Sruja DSL:
MySystem = system "My System" {
description "A deployable system"
MyContainer = container "My Container" {
technology "Node.js"
description "A deployable service"
}
Database = database "Database" {
technology "PostgreSQL"
description "Data storage"
}
}
MySystem.MyContainer -> MySystem.Database "SQL"Sruja provides native integration for AI code editors (Cursor, Trae, Copilot, Cline, Windsurf, etc.) to give them deep context about the cross-repo architecture:
- Architecture Setup: Run
sruja classify -r .to generate.sruja/classification.json, thensruja sync-ide-rules -r .to generate IDE context files. - Daily Context Sync: Run
just daily(ormake daily) to check for architectural drift and update IDE context. - Manual Sync: Run
sruja sync-ide-rules -r .to regenerate.cursorrules, copilot instructions, andllms-architecture.txt. - MCP Server: Configure your AI editor to use the Sruja Model Context Protocol (MCP) server.
- Command:
sruja mcp -r . - Usage: The MCP server exposes tools for the AI to query the architecture graph, classify repos, sync IDE rules, and check compliance on the fly.
- Command:
- Cross-Repo Context: Use
sruja ai-context -r repoA -r repoBto dynamically build context payloads when working on multi-repo features.
When using AI agents, leverage Sruja's context tools:
sruja focus --file <path>: Generates a task-scoped briefing (blast radius, decisions, boundaries, AI instructions).sruja context-score: Quantifies the repository's AI-readiness (0-100 score across 5 dimensions).sruja ingest <doc>: Imports external documentation (ADRs, design docs) into.sruja/context/.sruja why <id>: Explains the rationale/logic behind a specific architectural component or relationship.sruja impact <id>: Analyzes the blast radius of changing a component.sruja intent check: Verifies if your code changes match your architectural intent.
Editor-Specific Configs
Sruja generates architecture data files. Tool-specific instructions are hand-written.
Generated by sruja sync-ide-rules:
- Cursor:
.cursorrules - GitHub Copilot:
.github/copilot-instructions.md - All tools:
llms-architecture.txt(compact architecture brief)
Hand-written (not generated by sruja):
- Claude Code:
CLAUDE.md - General agents:
AGENTS.md - Windsurf:
.windsurf/rules/ - Cline:
.clinerules
Troubleshooting Agent Tasks
- "Command Not Found": Ensure you've run
just build(ormake build) and thetarget/releasedirectory is populated. - "Invalid DSL": Run
sruja lint <file>and paste the JSON error output to the assistant. - "Drift Detected": Run
sruja check -r . --fix(if available) or manually align.srujawith code. - "WASM Mismatch": If logic changed in
sruja-languagebut extension behavior is old, runjust wasm-nodejs(ormake wasm-nodejs).
graphify
This project has a knowledge graph at graphify-out/ with god nodes, community structure, and cross-file relationships.
When the user types /graphify, invoke the skill tool with skill: "graphify" before doing anything else.
Rules:
- For codebase questions, first run
graphify query "<question>"when graphify-out/graph.json exists. Usegraphify path "<A>" "<B>"for relationships andgraphify explain "<concept>"for focused concepts. These return a scoped subgraph, usually much smaller than GRAPH_REPORT.md or raw grep output. - Dirty graphify-out/ files are expected after hooks or incremental updates; dirty graph files are not a reason to skip graphify. Only skip graphify if the task is about stale or incorrect graph output, or the user explicitly says not to use it.
- If graphify-out/wiki/index.md exists, use it for broad navigation instead of raw source browsing.
- Read graphify-out/GRAPH_REPORT.md only for broad architecture review or when query/path/explain do not surface enough context.
- After modifying code, run
graphify update .to keep the graph current (AST-only, no API cost).
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.

