# Nlelouche Unity3d Antigravityskills Unified Style Guide

> ---

- Skill: `tomevault-io/nlelouche-unity3d-antigravityskills-unified-style-guide` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/nlelouche-unity3d-antigravityskills-unified-style-guide`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/nlelouche-unity3d-antigravityskills-unified-style-guide/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/nlelouche-unity3d-antigravityskills-unified-style-guide

---

---
name: unified-style-guide
description: "Establish and enforce a consistent C# coding style for Unity projects. Includes .editorconfig generation and architectural guidelines."
version: 2.0.0
tags: ["style-guide", "csharp", "architecture", ".editorconfig", "best-practices"]
argument-hint: "action='install' OR type='config'"
disable-model-invocation: false
user-invocable: true
allowed-tools:
  - run_command
  - list_dir
  - write_to_file
requirements:
  unity_version: ">=6.0"
  render_pipeline: "Any"
  dependencies: []
context_discovery:
  check_unity_version: true
  check_render_pipeline: false
  scan_manifest_for: []
performance_budget:
  gc_alloc_per_frame: "0 bytes target in hot paths"
  max_update_cost: "O(n) - profiler-guided"
tdd_first: true
---

# Unified Style Guide

## Overview
Defines the "North Star" for code quality and consistency. Enforces naming conventions, formatting rules, and architectural standards to ensure the codebase remains maintainable and readable by any team member.

## When to Use
- Use at the **start of a project** to set ground rules.
- Use during **Code Reviews** to cite standards.
- Use when **refactoring** legacy code.
- Use to configure **IDEs** (Rider, VS Code, Visual Studio).
- Use to resolve "Tab vs Space" debates.

## Core Rules

| Category | Rule | Example |
|----------|------|---------|
| **Public Fields** | PascalCase | `public int Health;` |
| **Private Fields** | _camelCase | `private int _currentHealth;` |
| **Methods** | PascalCase | `public void TakeDamage() { }` |
| **Interfaces** | IPrefix | `public interface IDamageable { }` |
| **Classes** | PascalCase | `public class PlayerController : MonoBehaviour` |
| **Serialization** | Force private | `[SerializeField] private int _speed;` |
| **Braces** | Allman (New Line) | `if (true)`<br>`{ ... }` |

## Architecture Standards
1.  **SOLID Principles**: Code should adhere to SOLID where applicable in Unity.
2.  **Composition over Inheritance**: Prefer `GetComponent` and Interfaces over deep class hierarchies.
3.  **Separation of Concerns**: Logic (C#) should be separate from View (Unity UI/Prefab).
4.  **No "Manager" Bloat**: Avoid massive `GameManager.cs` files; break into `ScoreSystem`, `AudioSystem`, etc.

## Best Practices
- ✅ Use `[SerializeField] private` instead of `public` variables.
- ✅ Use `Region` blocks sparingly (only for massive files or interface implementations).
- ✅ Use `namespace` for every script (e.g., `Game.Gameplay.Player`).
- ✅ Remove unused `using` statements.
- ❌ **NEVER** use `GameObject.Find()` in `Update()`.
- ❌ **NEVER** leave empty Unity messages (`Update() {}`) - overhead is non-zero.
- ❌ **NEVER** make fields `public` just to see them in Inspector (use `[SerializeField]`).

## Few-Shot Examples

### Example 1: Installing Config
**User**: "Setup the style guide."

**Agent**:
```bash
# Writes .editorconfig to project root
write_to_file(TargetFile=".editorconfig", Content=TemplateContent...)
```

### Example 2: Code Correction
**User**: "Fix this script style."

**Code (Before)**:
```csharp
public int speed = 10;
void Update() {
    if(speed>5) {
        transform.Translate(0,0,1);
    }
}
```

**Agent (After)**:
```csharp
[SerializeField] private int _speed = 10;

private void Update()
{
    if (_speed > 5)
    {
        transform.Translate(Vector3.forward);
    }
}
```



---

## TDD Contract

> ⚠️ **Legacy Skill — Refactor Pending**
> Este skill NO tiene tests automatizados aún. El siguiente boilerplate es un punto de partida.

```csharp
// Escribe estos tests ANTES de implementar:

// Test 1: should [expected behavior] when [condition]
[Test]
public void UnifiedStyleGuide_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 UnifiedStyleGuide_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 UnifiedStyleGuide_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
- `@automated-unit-testing` - Testing follows style
- `@custom-editor-scripting` - Editor tools style

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/nlelouche) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

