Context discovery agent

From nlelouche/Unity-SkillForge · View interactive version

Context discovery agent is an AI agent skill from the GitHub repository nlelouche/Unity-SkillForge. Auto-detects the Unity project environment (version, render pipeline, installed packages) and returns a structured context JSON consumed by all other skills before code generation.

How to use this skill

Skill file

Context Discovery Agent

Overview

The Context Discovery Agent is the mandatory pre-flight skill. It reads the three key sources of truth in any Unity project — ProjectVersion.txt, the Render Pipeline asset, and manifest.json — and produces a structured ContextReport that all other skills consume before generating code. It eliminates the #1 cause of bad AI code: wrong assumptions about the environment.

When to Use

Architecture

┌────────────────────────────────────────────────────┐
│              CONTEXT DISCOVERY PIPELINE            │
├────────────────────────────────────────────────────┤
│                                                    │
│  SOURCE FILES           PARSED OUTPUT              │
│  ┌────────────────┐     ┌─────────────────────┐   │
│  │ProjectVersion  │────▶│ unity_version: 6.0  │   │
│  │  .txt          │     │ unity_major: 6       │   │
│  └────────────────┘     └─────────────────────┘   │
│                                                    │
│  ┌────────────────┐     ┌─────────────────────┐   │
│  │ Assets/Settings│────▶│ render_pipeline: URP│   │
│  │  *.asset files │     │ srp_version: 17.x   │   │
│  └────────────────┘     └─────────────────────┘   │
│                                                    │
│  ┌────────────────┐     ┌─────────────────────┐   │
│  │ Packages/      │────▶│ packages:           │   │
│  │  manifest.json │     │   burst: true       │   │
│  └────────────────┘     │   inputsystem: true │   │
│                          │   addressables: true│   │
│                          └─────────────────────┘   │
│                                                    │
│  FINAL OUTPUT → ContextReport (JSON)               │
└────────────────────────────────────────────────────┘

Output Format (ContextReport)

{
  "unity_version": "6000.0.30f1",
  "unity_major": 6,
  "render_pipeline": "URP",
  "srp_asset_path": "Assets/Settings/UniversalRenderPipelineAsset.asset",
  "packages": {
    "com.unity.burst": "1.8.19",
    "com.unity.collections": "2.5.1",
    "com.unity.inputsystem": "1.11.2",
    "com.unity.addressables": "2.3.1",
    "com.unity.netcode.gameobjects": null,
    "com.unity.entities": null,
    "com.unity.render-pipelines.universal": "17.0.3"
  },
  "features": {
    "awaitable_api": true,
    "burst_available": true,
    "jobs_available": true,
    "ecs_available": false,
    "new_input_system": true,
    "addressables_configured": true
  },
  "warnings": []
}

Procedure

  1. Read Unity Version:

```

File: ProjectSettings/ProjectVersion.txt

Parse line: m_EditorVersion: 6000.0.30f1

→ unity_version = "6000.0.30f1", unity_major = 6

```

  1. Detect Render Pipeline:

```

Scan: Assets/Settings/ for files matching RenderPipelineAsset.asset

If found "UniversalRenderPipelineAsset" → URP

If found "HDRenderPipelineAsset" → HDRP

If none found → Built-in

```

  1. Parse Packages:

```

File: Packages/manifest.json

Extract "dependencies" object

Key packages to check:

com.unity.burst

com.unity.collections

com.unity.jobs

com.unity.inputsystem

com.unity.addressables

com.unity.netcode.gameobjects

com.unity.entities

com.unity.render-pipelines.universal

com.unity.render-pipelines.high-definition

com.unity.cinemachine

com.unity.textmeshpro

```

  1. Derive Feature Flags:

```

awaitable_api = unity_major >= 6

burst_available = "com.unity.burst" in packages

jobs_available = "com.unity.collections" in packages

ecs_available = "com.unity.entities" in packages

new_input_system = "com.unity.inputsystem" in packages

addressables_configured = "com.unity.addressables" in packages

```

  1. Report to User:

```

✅ Context validated:

Unity 6.0 | URP 17.x

Burst: ✅ | Jobs: ✅ | ECS: ❌ | Input System: ✅ | Addressables: ✅

```

Best Practices

Few-Shot Examples

Example 1: Discovering a URP Project

User: "Set up a shader for my character."

Agent: Runs Context Discovery → finds URP 17.x → automatically uses Shader Graph (URP) template instead of Built-in shader. Reports: "✅ URP detected — using URP Shader Graph workflow."

Example 2: Missing Burst

User: "Implement the Job System skill for my pathfinding."

Agent: Runs Context Discovery → burst_available: false → "⚠️ The job-system-burst skill requires com.unity.burst. Please install it via Package Manager (Window → Package Manager → Add by name: com.unity.burst). I'll wait."

Example 3: Built-in Render Pipeline Warning

User: "Add post-processing effects."

Agent: Detects Built-in RP → "ℹ️ Your project uses Built-in Render Pipeline. The modern Volume framework is only available in URP/HDRP. I'll use the legacy Post Processing Stack v2 approach. Shall I also provide a URP migration guide?"


TDD Contract

⚠️ Legacy Skill — Refactor Pending

Este skill NO tiene tests automatizados aún. El siguiente boilerplate es un punto de partida.

// Escribe estos tests ANTES de implementar:

// Test 1: should [expected behavior] when [condition]
[Test]
public void ContextDiscoveryAgent_Should{ExpectedBehavior}_When{Condition}()
{{
    // Arrange
    // TODO: Setup test fixtures
    
    // Act
    // TODO: Execute system under test
    
    // Assert
    Assert.Fail("Not implemented — write test first");
}}

// Test 2: should handle [edge case]
[Test]
public void ContextDiscoveryAgent_ShouldHandle{EdgeCase}()
{{
    // Arrange
    // TODO: Setup edge case scenario
    
    // Act
    // TODO: Execute
    
    // Assert
    Assert.Fail("Not implemented");
}}

// Test 3: should throw when [invalid input]
[Test]
public void ContextDiscoveryAgent_ShouldThrow_When{InvalidInput}()
{{
    // Arrange
    var invalidInput = default;
    
    // Act & Assert
    Assert.Throws<Exception>(() => {{ /* execute */ }});
}}

Pasos para completar el TDD:

  1. Descomenta los tests above
  2. Implementa la funcionalidad mínima para que compile
  3. Ejecuta los tests — deben fallar (RED)
  4. Implementa la funcionalidad real
  5. Verifica que los tests pasen (GREEN)
  6. Refactorea manteniendo los tests verdes

Nota: Este skill fue marcado como tdd_first: false durante la auditoría v2.0.1. La sección TDD fue agregada automáticamente pero requiere customización manual para reflejar el comportamiento real del skill.

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.