Skip to content

Getting Started with Cortex Projects

This guide will help you understand how to work with Cortex projects, from basic concepts to practical implementation.

What is a Cortex Project?

A Cortex project is a specialized framework for creating, validating, and managing templated documents with variable substitution. It's particularly well-suited for legal documents, compliance materials, and standardized content that needs to be both consistent and customizable.

Visual Overview

Here's a visual overview of a Cortex project structure:

Project Lifecycle

Key Components and Their Relationships

Project Definition Files

The .cortex/project.ctx file defines the project identity and dependencies:

project cortex.law/examples/nda

require {
  cortex.law/templates/legal-base 1.0.0 #d285563c25c5152b1ae80fc64de64ff2775fa733
  cortex.law/compliance/nda-rules 2.1.0 #3ddc9fc93c1d8ce560a3961e55547e5c78bd0f3e
}

Templates with Variables

Template files (.md) contain content with variable placeholders:

markdown
This Agreement is entered into as of {{effective_date}} by and between 
**{{party_a}}** ("**{{party_a_short}}**") and **{{party_b}}** ("**{{party_b_short}}**").

Test Files

Test files (_test.yml) validate template content:

yaml
name: NDA Compliance Test
model: cortex.law/claude-3-7
document: nda.md

tests:
  - name: Contains Confidentiality Definition
    assert: contains
    text: "Confidential Information"

Getting Started Steps

1. Set Up Project Structure

Create the basic directory structure:

my-project/
├── .cortex/
│   └── project.ctx
├── variables.json
├── document.md
└── document_test.yml

2. Define Your Project

Create .cortex/project.ctx:

project your-domain/your-category/your-project-name

require {
  # Add any dependencies you need
}

3. Create Your Template

Create a markdown file (e.g., document.md) with your content and variable placeholders:

markdown
# Example Document

This document is created by {{author}} on {{creation_date}}.

## Content

{{document_content}}

## Signature

________________________
{{signatory_name}}
{{signatory_title}}

4. Define Variables

Create variables.json with your variable definitions:

json
{
  "author": "Your Name",
  "creation_date": "May 15, 2025",
  "document_content": "This is the main content of the document.",
  "signatory_name": "John Smith",
  "signatory_title": "Director"
}

5. Create Tests

Create a test file (e.g., document_test.yml):

yaml
name: Document Test
model: cortex.law/claude-3-7
document: document.md

tests:
  - name: Contains Author
    assert: contains
    text: "{{author}}"
    
  - name: Has Signature Section
    assert: contains
    text: "Signature"

Working with an Existing Project

If you're working with an existing Cortex project like the NDA example:

  1. Understand the structure: Review the project.ctx, templates, and test files
  2. Review variables: Identify the variables used in templates
  3. Customize variables: Modify variable values for your specific needs
  4. Run tests: Ensure your changes maintain compliance
  5. Generate documents: Create final documents with your variable values

Best Practices

  1. Template Reuse: Structure templates to maximize reusability
  2. Comprehensive Testing: Create thorough tests for all critical aspects
  3. Documentation: Document the purpose of variables and templates
  4. Version Control: Keep your Cortex projects in version control
  5. Modular Approach: Break complex documents into reusable components

Next Steps

Once you're familiar with the basics, you can explore:

  • Creating more complex templates with conditional sections
  • Building libraries of reusable template components
  • Developing custom validation rules
  • Integrating Cortex projects with your document workflow