cc2-create
F* Labs - Formal verification and dependent type research laboratory
- Category: discovered
- Tags: github, community
- Version: 1.0.0
- Author: walid
- Downloads: 0
- Updated: 2025-11-22
Download the latest version (v1.0.0) from this page.
SKILL.md
# CC2.0 CREATE Function Skill
**Function**: CREATE - Implementation Generation & Artifact Production
**Category Theory**: Pure Total Function (Plan → Implementation)
**Purpose**: Transform strategic plans into concrete, executable implementations
**Status**: ✅ Production-Ready (494 lines, all function laws verified)
**Local Installation**: `/Users/manu/cc2.0`
**Environment Variable**: `export CC2_HOME=/Users/manu/cc2.0`
---
## The Eternal Function
**Universal Question**: *How do we build it?*
This function captures the timeless human activity of transforming intent into reality. Across all domains and eras, humans take strategic plans and manifest them into concrete form. CREATE is that bridge from "what we should do" to "what we have built."
### Universality Across Domains
| Domain | CREATE Applies To | Core Operation |
|--------|-------------------|----------------|
| **Medicine** | Treatment implementation, therapeutic interventions | Transform treatment plan into executed medical procedures |
| **Business** | Strategy execution, initiative implementation | Transform business plan into operational actions and deliverables |
| **Science** | Experimental protocol execution, apparatus construction | Transform experimental design into physical setup and execution |
| **Education** | Lesson delivery, curriculum implementation | Transform pedagogical plan into delivered instruction |
| **Manufacturing** | Production execution, process implementation | Transform process design into manufactured products |
| **Software** | Code implementation, feature development | Transform technical design into executable code |
| **Law** | Case strategy execution, document preparation | Transform legal strategy into briefs, motions, arguments |
| **Architecture** | Building construction, design implementation | Transform architectural design into physical structure |
### The Universal Pattern
Across all domains, CREATE follows the same categorical structure:
```
Strategic Plan → Pure Transformation → Concrete Artifact
(Input) → (Total Function) → (Output)
```
**Historical Precedent**: This pattern appears in:
- **Ancient Engineering**: Roman aqueduct construction from design (312 BCE)
- **Scientific Method**: Experimental execution from protocols (1600s)
- **Industrial Production**: Assembly line execution from blueprints (1913)
- **Software Engineering**: Code generation from specifications (1960s)
The function is eternal; the artifacts change.
### Why This Works Universally
1. **Pure Function**: Deterministic transformation (same plan → same implementation)
2. **Total**: Handles all valid inputs with defined error handling
3. **Compositional**: CREATE (plan1 ⊕ plan2) = CREATE(plan1) ⊕ CREATE(plan2)
4. **Artifact-Agnostic**: Works whether building code, buildings, or medical interventions
Software is simply ONE manifestation of this eternal pattern.
---
## When to Use This Skill
Use CREATE when you need to:
- 🏗️ **Build implementations** - Transform plans into concrete code, features, or artifacts
- 📄 **Generate artifacts** - Produce code files, tests, documentation, configurations
- 🔨 **Execute strategies** - Implement design patterns, refactorings, optimizations
- 🎯 **Maintain traceability** - Link implementation back to plan objectives
- ⚡ **Parallelize creation** - Build independent components concurrently
---
## Core Capabilities
### 1. Pure Total Function (Plan → Implementation)
```typescript
// Pure transformation with no side effects
// From: ${CC2_HOME}/src/functions/create/CreateFunction.ts
const implementation = await create.apply(plan);
// Returns: Either<Error, Implementation>
// Example: Generate refactored code
const plan = {
strategy: "restructure",
objectives: ["Reduce complexity to <5", "Extract methods"],
actions: [
{ id: "extract-1", type: "extract", target: "UserService.create" },
{ id: "test-1", type: "test", target: "extracted methods" }
]
};
const result = await create.apply(plan);
// Returns: Implementation with artifacts, tests, documentation
```
**Categorical Law**: `create(plan)` is deterministic and total
### 2. Strategy-Based Generation
```typescript
// Select creation strategy based on plan
// From: ${CC2_HOME}/src/functions/create/strategies/
const strategies = [
designStrategy, // New feature implementation
correctStrategy, // Bug fix implementation
optimizeStrategy, // Performance improvement
restructureStrategy // Refactoring implementation
];
const create = new CreateFunction(strategies);
const impl = await create.apply(plan);
```
**Categories of Strategies**:
- **DESIGN**: Generate new features from requirements
- **CORRECT**: Generate bug fixes with minimal changes
- **OPTIMIZE**: Generate performance improvements with benchmarks
- **RESTRUCTURE**: Generate refactored code preserving behavior
### 3. Artifact Validation
```typescript
// Validate generated artifacts
// From: ${CC2_HOME}/src/functions/create/CreateFunction.ts
const validation = implementation.artifacts.map(artifact => ({
id: artifact.id,
type: artifact.type,
passed: artifact.validation.passed,
issues: artifact.validation.issues
}));
// All artifacts validated before returning
```
**Validation Types**:
- Syntax validation (parse errors, type errors)
- Semantic validation (logic errors, pattern violations)
- Quality metrics (complexity, duplication, coverage)
---
## Input/Output Format
### Input (from REASON)
```typescript
// From: ${CC2_HOME}/src/functions/reason/types.ts
interface Plan<Context> {
strategy: "design" | "correct" | "optimize" | "restructure";
objectives: string[];
actions: Action[];
dependencies: Dependency[];
constraints: Constraint[];
resources: Resource[];
context: Context;
}
interface Action {
id: string;
type: string;
description: string;
target?: string;
dependencies: string[];
}
```
### Output (for VERIFY)
```typescript
// From: ${CC2_HOME}/src/functions/create/types.ts
interface Implementation<Context, Artifact> {
context: Context;
artifacts: Artifact[]; // Generated code, configs, docs
structure: Structure; // Topology, modules, interfaces
traceability: TraceLink[]; // Plan → Implementation links
quality: QualityMetrics; // Complexity, coverage, etc.
documentation: Documentation; // Auto-generated docs
tests: TestSuite; // Generated test cases
confidence: Probability; // 0-1 implementation confidence
metadata: ImplementationMetadata;
timestamp: number;
}
interface Artifact {
id: string;
type: "CODE" | "TEST" | "CONFIG" | "DOCS";
path: string;
content: string;
language: string;
validation: {
passed: boolean;
issues: ValidationIssue[];
};
}
```
---
## Integration Patterns
### Composing with Other Functions
#### REASON → CREATE (Primary Flow)
```typescript
// Flow: Strategic plan → Implementation
// From: ${CC2_HOME}/tests/integration/create-workflow.test.ts
const plan = await reason(observation);
const implementation = await create.apply(plan);
// Example:
// REASON: "Restructure UserService.create (complexity 15 → 5)"
// CREATE: Generates refactored code with extracted methods
```
#### CREATE → VERIFY (Validation Flow)
```typescript
// Flow: Implementation → Validation
const implementation = await create.apply(plan);
const verification = await verify(implementation);
// Example:
// CREATE: Generates code with tests
// VERIFY: Runs tests, validates quality metrics
```
#### OBSERVE → REASON → CREATE (Full Chain)
```typescript
// Complete development chain
const observation = observe([codeModule]).apply(state);
const plan = await reason(observation);
const implementation = await create.apply(plan);
// Example flow:
// OBSERVE: "Code quality 0.60, complexity high"
// REASON: "Strategy: restructure, extract 3 methods"
// CREATE: "Generated refactored code, 8 tests, complexity 4"
```
#### Parallel Creation
```typescript
// Create multiple independent implementations concurrently
const [impl1, impl2] = await Promise.all([
create.apply(plan1),
create.apply(plan2)
]);
// Merge implementations
const merged = CreateFunction.merge([impl1, impl2]);
```
---
## Practical Examples
### Example 1: Refactoring Implementation
```typescript
// From: ${CC2_HOME}/tests/integration/create-workflow.test.ts
// Input (from REASON)
const plan = {
strategy: "restructure",
objectives: [
"Reduce complexity from 15 to <5",
"Improve maintainability score from 60 to >80",
"Add unit tests for extracted methods"
],
actions: [
{
id: "extract-create-user",
type: "extract-method",
description: "Extract user creation logic",
target: "UserService.create",
dependencies: []
},
{
id: "extract-validate-input",
type: "extract-method",
description: "Extract validation logic",
target: "UserService.create",
dependencies: []
},
{
id: "add-tests",
type: "generate-tests",
description: "Generate unit tests",
target: "UserService",
dependencies: ["extract-create-user", "extract-validate-input"]
}
],
dependencies: [
{ from: "add-tests", to: "extract-create-user", type: "requires" },
{ from: "add-tests", to: "extract-validate-input", type: "requires" }
],
constraints: [
{ type: "behavior-preservation", hard: true, description: "Must preserve existing behavior" },
{ type: "test-coverage", hard: true, description: "Test coverage must be >80%" }
],
context: { file: "src/services/UserService.ts" }
};
// Execute CREATE
const implementation = await create.apply(plan);
// Output
{
artifacts: [
{
id: "user-service-refactored",
type: "CODE",
path: "src/services/UserService.ts",
content: `class UserService {
create(data: UserData): User {
const validated = this.validateInput(data);
return this.createUser(validated);
}
private validateInput(data: UserData): ValidatedData {
// Extracted validation logic
}
private createUser(data: ValidatedData): User {
// Extracted creation logic
}
}`,
language: "typescript",
validation: { passed: true, issues: [] }
},
{
id: "user-service-tests",
type: "TEST",
path: "src/services/UserService.test.ts",
content: `describe('UserService', () => {
describe('create', () => {
it('should create user with valid data', () => { ... });
it('should reject invalid email', () => { ... });
});
describe('validateInput', () => { ... });
describe('createUser', () => { ... });
});`,
language: "typescript",
validation: { passed: true, issues: [] }
}
],
quality: {
complexity: 4, // Reduced from 15
maintainability: 85, // Improved from 60
testCoverage: 0.92, // >80% target met
duplication: 0.02,
documentation: 0.88
},
traceability: [
{ objective: "Reduce complexity from 15 to <5", artifact: "user-service-refactored", satisfied: true },
{ objective: "Add unit tests", artifact: "user-service-tests", satisfied: true }
],
confidence: 0.94,
metadata: {
strategiesUsed: ["restructure"],
executionTime: 234,
artifactsCreated: 2,
linesOfCode: 87,
languages: ["typescript"]
}
}
```
### Example 2: New Feature Implementation
```typescript
// Input: Design strategy plan
const plan = {
strategy: "design",
objectives: [
"Implement password reset functionality",
"Add email verification",
"Create API endpoints"
],
actions: [
{ id: "model", type: "create-model", description: "PasswordReset model" },
{ id: "service", type: "create-service", description: "PasswordResetService" },
{ id: "controller", type: "create-controller", description: "API endpoints" },
{ id: "tests", type: "create-tests", description: "Unit + integration tests" }
],
dependencies: [
{ from: "service", to: "model", type: "depends-on" },
{ from: "controller", to: "service", type: "depends-on" },
{ from: "tests", to: "controller", type: "tests" }
]
};
// Execute
const implementation = await create.apply(plan);
// Output: 4 artifacts (model, service, controller, tests)
// All dependencies satisfied, 100% coverage, fully documented
```
### Example 3: Bug Fix Implementation
```typescript
// Input: Correct strategy plan
const plan = {
strategy: "correct",
objectives: ["Fix null pointer exception in payment processing"],
actions: [
{ id: "add-null-check", type: "add-guard", target: "PaymentService.process" },
{ id: "add-test", type: "create-test", description: "Regression test for null case" }
],
constraints: [
{ type: "minimal-change", hard: true, description: "Only change necessary lines" }
]
};
// Execute
const implementation = await create.apply(plan);
// Output: Minimal fix (2 line change), regression test added
```
### Example 4: Medical Protocol Implementation (Cross-Domain)
```typescript
// CREATE in medicine: Treatment protocol execution
// Demonstrates the SAME categorical structure in different domain
// Input (from REASON function in medical context)
const treatmentPlan = {
strategy: "design", // Design new treatment protocol
objectives: [
"Stabilize patient vitals",
"Administer cardiac medications",
"Monitor for adverse reactions",
"Document all interventions"
],
actions: [
{
id: "oxygen",
type: "administer",
description: "Administer oxygen 4L/min via nasal cannula",
target: "patient",
dependencies: []
},
{
id: "nitro",
type: "administer",
description: "Nitroglycerin 0.4mg sublingual",
target: "patient",
dependencies: ["oxygen"]
},
{
id: "aspirin",
type: "administer",
description: "Aspirin 325mg PO",
target: "patient",
dependencies: ["oxygen"]
},
{
id: "monitor",
type: "continuous-monitoring",
description: "Cardiac monitor, vitals q5min",
target: "patient",
dependencies: ["oxygen", "nitro", "aspirin"]
},
{
id: "document",
type: "documentation",
description: "Document all interventions, vitals, patient response",
target: "medical-record",
dependencies: ["monitor"]
}
],
dependencies: [
{ from: "nitro", to: "oxygen", type: "requires-completion" },
{ from: "monitor", to: "nitro", type: "follows" },
{ from: "document", to: "monitor", type: "records" }
],
constraints: [
{ type: "safety", hard: true, description: "Check for nitro contraindications" },
{ type: "timing", hard: true, description: "All meds within 10 minutes of symptom onset" },
{ type: "documentation", hard: true, description: "Real-time documentation required" }
],
context: {
patient_id: "P-12345",
condition: "acute_coronary_syndrome",
severity: "high",
location: "ED_Bay_3"
}
};
// Execute CREATE (same function, different domain)
const protocolExecution = await create.apply(treatmentPlan);
// Output: IDENTICAL categorical structure to software CREATE
{
artifacts: [
{
id: "oxygen-admin",
type: "INTERVENTION", // Medical equivalent of "CODE"
path: "P-12345/interventions/oxygen",
content: {
intervention: "Oxygen therapy",
dose: "4L/min",
route: "nasal cannula",
time_started: "2025-01-15T14:23:00Z",
patient_response: "SpO2 increased 88% → 95%"
},
validation: {
passed: true,
issues: [] // No safety alerts, correct dosage
}
},
{
id: "nitro-admin",
type: "INTERVENTION",
path: "P-12345/interventions/nitroglycerin",
content: {
intervention: "Nitroglycerin",
dose: "0.4mg",
route: "sublingual",
contraindications_checked: ["hypotension", "PDE5_inhibitor"],
time_administered: "2025-01-15T14:24:30Z",
patient_response: "Chest pain 8/10 → 4/10, BP 145/92 → 128/84"
},
validation: { passed: true, issues: [] }
},
{
id: "aspirin-admin",
type: "INTERVENTION",
path: "P-12345/interventions/aspirin",
content: {
intervention: "Aspirin",
dose: "325mg",
route: "PO",
time_administered: "2025-01-15T14:25:00Z"
},
validation: { passed: true, issues: [] }
},
{
id: "vital-monitoring",
type: "MONITORING", // Medical equivalent of "TEST"
path: "P-12345/monitoring/vitals",
content: {
monitoring_type: "continuous_cardiac",
vitals_frequency: "q5min",
readings: [
{ time: "14:23", BP: "145/92", HR: "88", SpO2: "95%", pain: "8/10" },
{ time: "14:28", BP: "138/88", HR: "82", SpO2: "96%", pain: "6/10" },
{ time: "14:33", BP: "128/84", HR: "78", SpO2: "97%", pain: "4/10" }
]
},
validation: { passed: true, issues: [] }
},
{
id: "clinical-documentation",
type: "DOCS",
path: "P-12345/medical-record/intervention-note",
content: `ACUTE CORONARY SYNDROME PROTOCOL EXECUTED
Time of symptom onset: 14:20
Time of first intervention: 14:23 (3 min door-to-treatment)
Interventions:
1. Oxygen 4L/min NC - started 14:23 → SpO2 95%
2. Nitroglycerin 0.4mg SL - given 14:24 → chest pain ↓, BP normalized
3. Aspirin 325mg PO - given 14:25
4. Continuous cardiac monitoring initiated
Patient response: Positive
- Chest pain 8/10 → 4/10
- Vitals stabilizing
- No adverse reactions
Next steps: Cardiology consult, ECG, troponin labs`,
validation: { passed: true, issues: [] }
}
],
traceability: [
{ objective: "Stabilize patient vitals", artifact: "oxygen-admin", satisfied: true },
{ objective: "Stabilize patient vitals", artifact: "nitro-admin", satisfied: true },
{ objective: "Administer cardiac medications", artifact: "nitro-admin", satisfied: true },
{ objective: "Administer cardiac medications", artifact: "aspirin-admin", satisfied: true },
{ objective: "Monitor for adverse reactions", artifact: "vital-monitoring", satisfied: true },
{ objective: "Document all interventions", artifact: "clinical-documentation", satisfied: true }
],
quality: {
compliance: 1.0, // 100% protocol compliance (equivalent to "complexity")
timing: 0.97, // 97% within timing targets (equivalent to "maintainability")
documentation: 1.0, // Complete documentation (equivalent to "testCoverage")
safety: 1.0, // No safety violations (equivalent to "duplication")
effectiveness: 0.85 // Patient response positive (equivalent to "documentation")
},
confidence: 0.92, // Same confidence scoring as software
metadata: {
strategiesUsed: ["design"],
executionTime: 720000, // 12 minutes (in milliseconds)
artifactsCreated: 5,
protocolCompliance: "ACS-standard-v2.1",
location: "ED_Bay_3"
},
timestamp: 1705329180000
}
```
**Key Insight**: The CREATE function (Pure Total Function) works IDENTICALLY in medicine and software:
- **Pure**: Same plan → same execution (deterministic protocols)
- **Total**: Handles all valid plans (error handling for contraindications)
- **Artifacts**: Medical interventions = code artifacts (both are concrete outputs)
- **Traceability**: Plan objectives → implemented actions (same structure)
- **Validation**: Safety checks = syntax/semantic validation
Medical protocol execution = Software implementation. Same categorical structure, different artifacts.
---
## Building Foundations for Your Domain
**Universal Function = Eternal Structure + Domain Foundations**
CREATE is an eternal categorical structure (Pure Total Function). To use it in YOUR domain, you construct **domain foundations** - the artifact types, generation strategies, and validation rules specific to your field. The universal function remains uncha