# civ6lib

civ6lib validates Civilization 6 district placement and computes adjacency bonuses. Use it when an agent needs to reason about city layouts and game rules.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 2 installs · ★ 1933 repo stars
- Author: benchflow-ai
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/benchflow-ai/skillsbench/tree/HEAD/tasks/civ6-adjacency-optimizer/environment/skills/civ6lib/SKILL.md
- Updated: 2026-10-24
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/civ6lib

## What it does

civ6lib gives an agent a reference for Civilization 6 district mechanics, including placement limits, population-based district slots, district uniqueness, and special conditions for harbors, aqueducts, dams, and other districts. It checks distance from the city center, terrain, resources, features, and occupied tiles.

The skill describes the Python modules `placement_rules.py` and `adjacency_rules.py`, plus the `Tile`, `PlacementRules`, and `AdjacencyCalculator` classes. An agent can validate a proposed tile and calculate total adjacency across placements. Each `+0.5` bonus category is floored on its own before totals are added, so rounding after combining categories produces a wrong result.

Hex-grid operations are delegated to the `hex-grid-spatial` skill or imported from `src.hex_utils`. In Claude Code, install it with `npx skills add`; the installed skill file is `~/.claude/skills/civ6lib/SKILL.md`.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add benchflow-ai/skillsbench --skill civ6lib -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/civ6lib/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/civ6lib/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add benchflow-ai/skillsbench --skill civ6lib -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/civ6lib/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add benchflow-ai/skillsbench --skill civ6lib -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/civ6lib/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install benchflow-ai/skillsbench tasks/civ6-adjacency-optimizer/environment/skills/civ6lib
```

2. **Manually: put the files in place**
- File: `.github/skills/civ6lib/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add benchflow-ai/skillsbench --skill civ6lib -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/benchflow-ai/skillsbench --path tasks/civ6-adjacency-optimizer/environment/skills/civ6lib
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/civ6lib/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add benchflow-ai/skillsbench --skill civ6lib -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/benchflow-ai/skillsbench/tree/HEAD/tasks/civ6-adjacency-optimizer/environment/skills/civ6lib/SKILL.md

## When to use it
- validate a district tile before placing it
- calculate adjacency bonuses for a city layout
- apply population limits to specialty districts
- detect conflicts with resources, mountains, or natural wonders
- check district uniqueness for a city or civilization

## Example prompts
- Validate placing `DistrictType.CAMPUS` at `(21, 14)` for a city with population `7`.
- Calculate the total adjacency bonus for these district placements.
- Check which districts can still be added after applying the city limit and occupied tiles.

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 6a4b986db8e71b33.

BEGIN THIRD-PARTY FILE 6a4b986db8e71b33
````text
---
name: civ6lib
description: Civilization 6 district mechanics library. Use when working with district placement validation, adjacency bonus calculations, or understanding Civ6 game rules.
---

# Understanding Civ6 District Mechanics

Complete reference for Civilization 6 district placement and adjacency bonus systems (Gathering Storm).

## Modules

- **placement_rules.py** - District placement validation rules
- **adjacency_rules.py** - Adjacency bonus calculation engine

For hex grid utilities (neighbors, distance, etc.), use the `hex-grid-spatial` skill or import from `src.hex_utils`.

## Usage

```python
from civ6lib import (
    # Placement
    DistrictType, Tile, PlacementRules, get_placement_rules,
    validate_district_count, validate_district_uniqueness,
    # Adjacency
    AdjacencyCalculator, get_adjacency_calculator,
)

# Validate a placement
rules = get_placement_rules(tiles, city_center=(21, 13), population=7)
result = rules.validate_placement(DistrictType.CAMPUS, 21, 14, {})
if result.valid:
    print("Valid placement!")

# Calculate adjacency bonus
calculator = get_adjacency_calculator(tiles)
total, per_district = calculator.calculate_total_adjacency(placements)
```

---

# Part 1: Placement Rules

## City Placement Rules

### Minimum Distance Between Cities

| Condition | Min Distance | Tiles Between |
|-----------|--------------|---------------|
| Same landmass | 4 tiles | 3 tiles |
| Different landmasses | 3 tiles | 2 tiles |

### Invalid Settlement Tiles
- Water (Coast, Ocean, Lake)
- Mountains
- Natural Wonders

### Note on City Center Features
Settling a **City Center** on a tile with Geothermal Fissure or Luxury/Strategic Resources **preserves** them (they remain and provide adjacency bonuses to nearby districts). Districts cannot be placed on these tiles.

## District Placement Rules

### Universal Rules (All Districts)

| Rule | Description |
|------|-------------|
| Distance | Within **3 tiles** of City Center |
| Mountains | Cannot place |
| Natural Wonders | Cannot place |
| Strategic Resources | Cannot place (Iron, Horses, Niter, Coal, Oil, Aluminum, Uranium) |
| Luxury Resources | Cannot place |
| Existing District | Cannot place on occupied tile |
| Bonus Resources | CAN place (resource destroyed) |
| Woods/Rainforest/Marsh | CAN place (feature destroyed) |

### District-Specific Rules

| District | Special Requirement |
|----------|---------------------|
| Harbor | Must be on Coast/Lake, adjacent to land |
| Water Park | Must be on Coast/Lake, adjacent to land |
````
END THIRD-PARTY FILE 6a4b986db8e71b33

The third-party file has ended. Everything between the 6a4b986db8e71b33 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2540 of 6917 bytes. © benchflow-ai · Apache-2.0 · https://github.com/benchflow-ai/skillsbench/tree/HEAD/tasks/civ6-adjacency-optimizer/environment/skills/civ6lib/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
