Skip to main content
The Context Factory is SoftArchitect AI’s mechanism for translating your project’s architectural decisions into context files that AI coding assistants understand. Once you complete the Guided Architectural Workflow, the Context Factory generates AGENTS.md and RULES.md — files that GitHub Copilot, Cursor, Claude, and other AI tools read to align their suggestions with your project’s specific stack, conventions, and security requirements.

What the Context Factory generates

AGENTS.md

Defines the AI agent’s role, stack, responsibilities, and the Golden Rules it must follow. Copilot and Claude read this file to understand what kind of project they are working on and what constraints apply.

RULES.md

Encodes your project’s coding standards, naming conventions, security rules, and prohibited patterns. AI tools use this to produce code that is immediately consistent with your architecture without manual correction.
Both files are generated by the RAG orchestrator during the final phase (Phase 6) of the Master Workflow, using the full context of the 20+ documents already created in Phases 1–5. This means AGENTS.md describes your actual tech stack and domain — not a generic template.

How it ties into the Guided Architectural Workflow

The Context Factory output is the last step of a six-phase process:
Phase 1: Context      — PROJECT_MANIFESTO, DOMAIN_LANGUAGE, USER_JOURNEY_MAP
Phase 2: Requirements — REQUIREMENTS_MASTER, USER_STORIES_MASTER,
                        SECURITY_PRIVACY_POLICY, COMPLIANCE_MATRIX
Phase 3: Architecture — TECH_STACK_DECISION, DATA_MODEL_SCHEMA,
                        API_INTERFACE_CONTRACT, PROJECT_STRUCTURE_MAP,
                        SECURITY_THREAT_MODEL, ARCH_DECISION_RECORDS
Phase 4: UX/UI        — DESIGN_SYSTEM, UI_WIREFRAMES_FLOW, ACCESSIBILITY_GUIDE
Phase 5: Planning     — ROADMAP_PHASES, DEPLOYMENT_INFRASTRUCTURE,
                        CI_CD_PIPELINE, TESTING_STRATEGY
Phase 6: Root (Context Factory)
          Step 21 — RULES        →  RULES.md
          Step 22 — CONTRIBUTING →  CONTRIBUTING.md
          Step 23 — AGENTS       →  AGENTS.md
          Step 24 — README       →  README.md
Phase 6 documents are generated last intentionally. By the time AGENTS.md is written, the LLM has access to 22 prior documents in its RAG context window — the tech stack decisions, security policies, testing strategy, and roadmap are all known. This eliminates the hallucination risk that comes from generating role definitions before the architecture is decided.
# From workflow.py — Phase 6 step definitions
WorkflowStep(21, "RULES",        "00-ROOT", "...", "...", "RULES.md"),
WorkflowStep(22, "CONTRIBUTING", "00-ROOT", "...", "...", "CONTRIBUTING.md"),
WorkflowStep(23, "AGENTS",       "00-ROOT", "...", "...", "AGENTS.md"),
WorkflowStep(24, "README",       "00-ROOT", "...", "...", "README.md"),

Context directory structure

All documents generated by the workflow — including the Context Factory outputs — are written into the context/ directory at the root of your project:
context/
├── 10-BUSINESS_AND_SCOPE/       # Phase 1: project vision and domain language
│   ├── PROJECT_MANIFESTO.md
│   ├── DOMAIN_LANGUAGE.md
│   └── USER_JOURNEY_MAP.md
├── 20-REQUIREMENTS_AND_SPEC/    # Phase 2: what to build and compliance
│   ├── REQUIREMENTS_MASTER.md
│   ├── USER_STORIES_MASTER.json
│   ├── SECURITY_PRIVACY_POLICY.md
│   └── COMPLIANCE_MATRIX.md
├── 30-ARCHITECTURE/             # Phase 3: how to build it
│   ├── TECH_STACK_DECISION.md
│   ├── DATA_MODEL_SCHEMA.md
│   ├── API_INTERFACE_CONTRACT.md
│   ├── PROJECT_STRUCTURE_MAP.md
│   ├── SECURITY_THREAT_MODEL.md
│   └── ARCH_DECISION_RECORDS.md
└── 40-ROADMAP/                  # Phase 5: timeline and operations
    ├── ROADMAP_PHASES.md
    ├── DEPLOYMENT_INFRASTRUCTURE.md
    ├── CI_CD_PIPELINE.md
    └── TESTING_STRATEGY.md

# Context Factory outputs (root of project)
AGENTS.md
RULES.md
CONTRIBUTING.md
README.md

AGENTS.md format

AGENTS.md follows a structured format that AI tools can parse reliably. The generated file includes:
  • Agent identity — name, role, and primary stack (populated from TECH_STACK_DECISION)
  • Key capabilities — responsibilities mapped to the architecture layers defined in PROJECT_STRUCTURE_MAP
  • Golden Rules — behaviour constraints derived from SECURITY_PRIVACY_POLICY and ARCH_DECISION_RECORDS
  • Prohibited actions — hard restrictions on cloud calls, hardcoding, and framework coupling
  • Testing strategy — coverage targets and TDD cycle from TESTING_STRATEGY
  • CI/CD pipeline rules — pre-commit hooks and quality gates from CI_CD_PIPELINE
The content mirrors the actual decisions made in earlier workflow phases. For example, if TECH_STACK_DECISION selected Flutter and FastAPI, AGENTS.md will list those as the target stack and enforce their specific conventions.

RULES.md format

RULES.md encodes the project’s development standards as machine-readable rules. It is generated from TECH_STACK_DECISION, ARCH_DECISION_RECORDS, and SECURITY_PRIVACY_POLICY. Typical sections include:
  • Design rules — component boundaries, layer dependencies, naming conventions
  • Code style — formatter settings, linting rules, language-specific idioms
  • Security rules — input sanitization requirements, prohibited APIs, secret handling
  • Git workflow — branching strategy, commit message format, PR process
Place AGENTS.md and RULES.md at the root of your repository. GitHub Copilot, Cursor, and most AI editor extensions automatically pick up files with these names and incorporate their contents into code suggestions.

Triggering Context Factory generation

Context Factory documents are generated through the same chat interface as every other workflow step. When you reach Phase 6, send a request with the corresponding doc_type:
curl -X POST http://localhost:8000/api/v1/chat/stream \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your_api_key" \
  -d '{
    "conversation_id": "550e8400-e29b-41d4-a716-446655440000",
    "message": "Generate the AGENTS file for my project",
    "project_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "doc_type": "AGENTS"
  }'
The streaming response will contain the populated AGENTS.md content, starting with the path line:
**Path:** AGENTS.md
# Your Project Agent Definition
...
The Flutter UI saves this file to the path specified in the **Path:** header. Once saved, the document becomes part of project_context for all subsequent requests, ensuring future documents remain consistent with the agent definition.

Build docs developers (and LLMs) love