You now have infrastructure in place. But it’s inert. The templates exist. The schemas exist. The context is there. None of it is actually working yet.

This piece adds the operational layer: the scripts and workflows that make the folder intelligent.

Stage 3: Operations and automation

You’re going to build three things:

  1. A script that validates output against your schemas
  2. A script that retrieves context and briefs the AI
  3. A workflow script that orchestrates the entire process

3.1 Validation script

Create scripts/validate.py:

#!/usr/bin/env python3
import yaml
import sys
from pathlib import Path
 
def validate_frontmatter(file_path, schema):
    """Check that a markdown file's frontmatter matches the schema."""
    
    with open(file_path) as f:
        content = f.read()
    
    # Parse frontmatter
    if not content.startswith("---"):
        return False, "Missing frontmatter"
    
    parts = content.split("---", 2)
    if len(parts) < 3:
        return False, "Malformed frontmatter"
    
    try:
        metadata = yaml.safe_load(parts[1])
    except yaml.YAMLError as e:
        return False, f"Invalid YAML: {e}"
    
    # Validate required fields
    for field in schema.get('required_fields', []):
        if field not in metadata:
            return False, f"Missing required field: {field}"
    
    # Validate field content
    validations = schema.get('validations', {})
    for field, rules in validations.items():
        if field not in metadata:
            continue
        
        value = metadata[field]
        
        # Type check
        if rules.get('type') == 'string' and not isinstance(value, str):
            return False, f"Field {field} must be string"
        
        # Length check
        if 'min_length' in rules and len(value) < rules['min_length']:
            return False, f"Field {field} too short (min {rules['min_length']})"
        
        if 'max_length' in rules and len(value) > rules['max_length']:
            return False, f"Field {field} too long (max {rules['max_length']})"
        
        # Value check (for tags, etc.)
        if 'allowed_tags' in rules:
            if isinstance(value, list):
                for tag in value:
                    if tag not in rules['allowed_tags']:
                        return False, f"Invalid tag: {tag}"
    
    return True, "Valid"
 
if __name__ == "__main__":
    file_path = Path(sys.argv[1])
    content_type = sys.argv[2] if len(sys.argv) > 2 else "essay"
    
    schema_path = Path(__file__).parent.parent / "schemas" / f"{content_type}.yml"
    with open(schema_path) as f:
        schema = yaml.safe_load(f)
    
    valid, message = validate_frontmatter(file_path, schema)
    print(message)
    sys.exit(0 if valid else 1)

This script validates a Markdown file against a schema. You pass it a file and a type (essay, concept, etc.), and it checks that the frontmatter is complete and valid.

Usage: python scripts/validate.py output/my-essay.md essay

3.2 Context retrieval script

Create scripts/get-context.sh:

#!/bin/bash
 
# Retrieve context for the AI
# Usage: get-context.sh [content_type] [optional_query]
 
CONTENT_TYPE=${1:-essay}
QUERY=${2:-}
 
echo "=== FOLDER CONTEXT ==="
cat config/context.md
 
echo ""
echo "=== TEMPLATE ==="
cat "templates/${CONTENT_TYPE}.md"
 
echo ""
echo "=== SCHEMA ==="
cat "schemas/${CONTENT_TYPE}.yml"
 
echo ""
echo "=== RECENT EXAMPLES ==="
# List recent published pieces
find output -name "*.md" -type f -mtime -30 | head -3 | while read file; do
    echo "---"
    echo "File: $file"
    head -20 "$file"
done
 
if [ ! -z "$QUERY" ]; then
    echo ""
    echo "=== RELATED CONCEPTS ==="
    grep -r "$QUERY" knowledge-base/ --include="*.md" | head -5
fi

This script gathers the context the AI needs: the folder’s standards, templates, schemas, examples of recent work, and anything related to the topic at hand.

Usage: bash scripts/get-context.sh essay "AI integration"

3.3 Write operation

Create scripts/write-essay.sh:

#!/bin/bash
 
# Generate an essay and validate it
# Usage: write-essay.sh "Essay Title" "One-sentence description"
 
TITLE="$1"
DESCRIPTION="$2"
 
# Get context
CONTEXT=$(bash scripts/get-context.sh essay "$TITLE")
 
# Create the prompt for the AI
PROMPT="$CONTEXT
 
TASK: Write an essay with the title: $TITLE
 
Description: $DESCRIPTION
 
Requirements:
- Follow the template structure exactly
- Match the voice and style described above
- Write 2000-3000 words
- Include relevant citations and related concepts
- Validate against all quality gates
 
Generate the complete essay in markdown format."
 
# Call the AI (using claude-api or similar)
# This is pseudocode; adapt to your AI API
ESSAY=$(echo "$PROMPT" | claude-api --model claude-opus)
 
# Write to drafts
OUTPUT_FILE="drafts/$(echo "$TITLE" | tr ' ' '-' | tr '[:upper:]' '[:lower:]').md"
echo "$ESSAY" > "$OUTPUT_FILE"
 
# Validate
if python scripts/validate.py "$OUTPUT_FILE" essay; then
    echo "Essay generated and validated: $OUTPUT_FILE"
    exit 0
else
    echo "Validation failed. Check: $OUTPUT_FILE"
    exit 1
fi

This script orchestrates the entire essay-writing workflow: gather context, prompt the AI, write output, validate it.

Usage: bash scripts/write-essay.sh "My Essay Title" "One sentence about what it covers"

Understanding what just happened

You now have an ambient folder that can:

  1. Understand its own standards — the schema files define what valid output looks like
  2. Retrieve context automatically — the context script gathers everything the AI needs
  3. Call on AI capabilities — the write script uses that context to generate output
  4. Validate results — the validation script checks that the output meets your standards
  5. Keep everything organized — output goes to the right place with the right structure

The folder is now “aware.” It knows what you want, what standards you have, and how to check its own work.

Stage 3 complete: An operational ambient folder

At this point, you have:

  • Templates that define finished work
  • Schemas that validate it
  • Scripts that orchestrate the process
  • Automatic context retrieval
  • Validation gates

When you want to write an essay, you don’t open ChatGPT. You don’t manually copy-paste context. You run a script. The script:

  • Gathers your standards and context
  • Briefs the AI
  • Generates the essay
  • Validates it
  • Saves it to the right place

The process is:

bash scripts/write-essay.sh "Ambient AI for Practitioners" "A guide to building ambient AI systems"

Thirty seconds later, you have a draft essay in your drafts folder, validated against your standards.

What’s missing: maturity patterns

This is a working system, but it’s not yet mature. The next piece covers what happens as your folder grows: how to handle complexity, how to add roles and contracts, how to make the substrate cascade across multiple operations.

For now, you have the core: a folder that understands itself and knows how to work with AI to extend its own capabilities.

This is ambient AI in its simplest form. And even at this level, it eliminates the manual work of tool-switching, context assembly, and validation.

As your practice grows, you’ll add layers. But this foundation—the structure, the schemas, the validation, the automation—this is where it all begins.

In the next piece, we explore what happens when this ambition scales: how to add complexity without losing clarity, how to make the system more powerful without making it harder to use.