{{!--
  Google Antigravity Template
  Generates multiple files for .agent/ directory:
  - rules/*.md - Workspace rules by category
  - workflows/*.md - On-demand /commands
  - skills/*.md - Modular capabilities
--}}

{{!-- ============================================================ --}}
{{!-- RULES: Main Project Identity                                  --}}
{{!-- ============================================================ --}}
{{{fileStart "rules/identity.md"}}}
<!-- Auto-generated by AI Context Engineering v{{metadata.generator_version}} -->
<!-- Generated: {{metadata.timestamp}} -->

# {{project.name}} - Project Identity

## Overview

- **Name:** {{project.name}}
- **Description:** {{project.description}}
- **Tech Stack:** {{join project.tech_stack ", "}}
- **Primary Language:** {{project.primary_language}}

## Quick Commands

{{#each commands}}
- **{{@key}}:** `{{this}}`
{{/each}}

## Architecture

**Pattern:** {{architecture.pattern}}

{{#if architecture.layers}}
**Layers:**
{{#each architecture.layers}}
- `{{path}}` - {{purpose}}
{{/each}}
{{/if}}

## Key Entry Points

{{#each key_files.entry_points}}
- `{{this}}`
{{/each}}

{{#if environment.required}}
## Environment Variables

**Required:**
{{#each environment.required}}
- `{{this}}`
{{/each}}

{{#if environment.optional}}
**Optional:**
{{#each environment.optional}}
- `{{this}}`
{{/each}}
{{/if}}
{{/if}}

---

{{{coordination.footer}}}
{{{fileEnd}}}

{{!-- ============================================================ --}}
{{!-- RULES: Architecture Details                                   --}}
{{!-- ============================================================ --}}
{{{fileStart "rules/architecture.md"}}}
<!-- Auto-generated by AI Context Engineering -->

# Architecture Rules for {{project.name}}

## Pattern: {{architecture.pattern}}

{{#each architecture.layers}}
### Layer: {{name}}

**Path:** `{{path}}`
**Purpose:** {{purpose}}

{{/each}}

## Key Files by Category

{{#if key_files.entry_points}}
### Entry Points
{{#each key_files.entry_points}}
- `{{this}}`
{{/each}}
{{/if}}

{{#if key_files.api_routes}}
### API Routes
{{#each key_files.api_routes}}
- `{{this}}`
{{/each}}
{{/if}}

{{#if key_files.config}}
### Configuration
{{#each key_files.config}}
- `{{this}}`
{{/each}}
{{/if}}

---

{{{coordination.footer}}}
{{{fileEnd}}}

{{!-- ============================================================ --}}
{{!-- RULES: Gotchas (Critical Issues)                              --}}
{{!-- ============================================================ --}}
{{{fileStart "rules/gotchas.md"}}}
<!-- Auto-generated by AI Context Engineering -->

# Critical Gotchas for {{project.name}}

These are known issues and pitfalls. Review before making changes.

{{#if gotchas}}
{{#each gotchas}}
## {{id}}: {{title}}

**Severity:** {{severity}}

**Symptom:** {{symptom}}

**Fix:**
```
{{fix}}
```

---

{{/each}}
{{else}}
*No gotchas documented yet. Add as discovered.*
{{/if}}

---

{{{coordination.footer}}}
{{{fileEnd}}}

{{!-- ============================================================ --}}
{{!-- RULES: Constraints                                            --}}
{{!-- ============================================================ --}}
{{{fileStart "rules/constraints.md"}}}
<!-- Auto-generated by AI Context Engineering -->

# Critical Constraints for {{project.name}}

These rules MUST be followed. Violations may cause production issues.

{{#if critical_constraints}}
{{#each critical_constraints}}
{{@index}}. {{this}}
{{/each}}
{{else}}
*No constraints documented yet. Add critical rules as identified.*
{{/if}}

## Summary

- Total Constraints: {{length critical_constraints}}
- Gotchas: {{length gotchas}}
- Workflows: {{length workflows}}

---

{{{coordination.footer}}}
{{{fileEnd}}}

{{!-- ============================================================ --}}
{{!-- RULES: Workflows Summary                                      --}}
{{!-- ============================================================ --}}
{{{fileStart "rules/workflows.md"}}}
<!-- Auto-generated by AI Context Engineering -->

# Available Workflows for {{project.name}}

{{#if workflows}}
{{#each workflows}}
## {{name}}

**Category:** {{category}} | **Complexity:** {{complexity}}

{{description}}

{{#if entry_points}}
**Entry Points:**
{{#each (first entry_points 5)}}
- `{{endpoint}}` - {{file}}:{{line}}
{{/each}}
{{/if}}

---

{{/each}}
{{else}}
*No workflows discovered. Run AI analysis to populate.*
{{/if}}

---

{{{coordination.footer}}}
{{{fileEnd}}}

{{!-- ============================================================ --}}
{{!-- WORKFLOWS: Command Files                                      --}}
{{!-- ============================================================ --}}

{{{fileStart "workflows/run.md"}}}
<!-- Auto-generated by AI Context Engineering -->

# /run - Start Development Server

## Command
```bash
{{commands.dev}}
```

## Description
Starts the {{project.name}} development server.

## Prerequisites
- All dependencies installed
- Environment variables configured

## Related
- See `rules/identity.md` for full command list

---

{{{coordination.footer}}}
{{{fileEnd}}}

{{{fileStart "workflows/test.md"}}}
<!-- Auto-generated by AI Context Engineering -->

# /test - Run Test Suite

## Command
```bash
{{commands.test}}
```

## Description
Runs the test suite for {{project.name}}.

## Tips
- Run before committing changes
- Check test coverage reports

---

{{{coordination.footer}}}
{{{fileEnd}}}

{{{fileStart "workflows/build.md"}}}
<!-- Auto-generated by AI Context Engineering -->

# /build - Build Project

## Command
```bash
{{commands.build}}
```

## Description
Builds {{project.name}} for production.

---

{{{coordination.footer}}}
{{{fileEnd}}}

{{!-- ============================================================ --}}
{{!-- SKILLS: Modular Capabilities                                  --}}
{{!-- ============================================================ --}}

{{{fileStart "skills/debugging.md"}}}
<!-- Auto-generated by AI Context Engineering -->

# Debugging Skill for {{project.name}}

## When to Use
Activate this skill when debugging issues in {{project.name}}.

{{#if gotchas}}
## Known Issues

{{#each gotchas}}
### {{id}}: {{title}}

**Severity:** {{severity}}

**Symptom:** {{symptom}}

**Quick Fix:**
```
{{truncate fix 200}}
```

{{/each}}
{{/if}}

## Debug Commands

```bash
# Start dev server
{{commands.dev}}

# Run tests
{{commands.test}}
```

## Tips

- Check application logs for errors
- Review stack traces carefully
- Verify environment configuration

---

{{{coordination.footer}}}
{{{fileEnd}}}

{{{fileStart "skills/implementation.md"}}}
<!-- Auto-generated by AI Context Engineering -->

# Implementation Skill for {{project.name}}

## When to Use
Activate this skill when implementing new features in {{project.name}}.

## Architecture Overview

**Pattern:** {{architecture.pattern}}

{{#if architecture.layers}}
**Layers:**
{{#each architecture.layers}}
- `{{path}}` - {{purpose}}
{{/each}}
{{/if}}

## Code Standards

1. Follow existing patterns in the codebase
2. Add tests for new functionality
3. Update documentation as needed
4. Review gotchas before modifying critical areas

## Key Files to Reference

{{#each key_files.entry_points}}
- `{{this}}`
{{/each}}

{{#if critical_constraints}}
## Constraints to Follow

{{#each critical_constraints}}
- {{this}}
{{/each}}
{{/if}}

---

{{{coordination.footer}}}
{{{fileEnd}}}
