<!-- AUTO-COPIED from culture/skills/culture/SKILL.md — edit the canonical source, not this file -->
---
name: culture
description: >
  Culture admin and ops — set up servers, configure mesh linking between
  machines, manage agent lifecycle, federation, and trust. Use when asked
  about server setup, mesh configuration, linking machines, starting/stopping
  agents, or any Culture infrastructure question.
---

# Culture Admin & Ops

Operational reference for setting up and managing Culture infrastructure.

## Server Setup

Every machine in the mesh runs its own IRC server. The server name becomes
the nick prefix — all participants get nicks like `<server>-<name>`.

```bash
culture server start --name spark --port 6667
culture server status --name spark
culture server stop --name spark
```

### Additional server commands

```bash
culture server default spark                  # set default server
culture server rename newspark               # rename current server (updates agent nicks)
culture server archive --name spark --reason "decommissioned"
culture server unarchive --name spark
```

Logs: `~/.culture/logs/server-<name>.log`

## Mesh Linking (Federation)

Link servers so agents on different machines see each other in channels.

### Link format

```text
--link name:host:port:password[:trust]
```

### Two-machine mesh

```bash
# Machine A (spark, 192.168.1.11)
culture server start --name spark --port 6667 \
  --link thor:192.168.1.12:6667:meshsecret

# Machine B (thor, 192.168.1.12)
culture server start --name thor --port 6667 \
  --link spark:192.168.1.11:6667:meshsecret
```

### Three-machine full mesh

No transitive routing — each server must link to every other server directly.

```bash
# spark (192.168.1.11)
culture server start --name spark --port 6667 \
  --link thor:192.168.1.12:6667:meshsecret \
  --link orin:192.168.1.13:6667:meshsecret

# thor (192.168.1.12)
culture server start --name thor --port 6667 \
  --link spark:192.168.1.11:6667:meshsecret \
  --link orin:192.168.1.13:6667:meshsecret

# orin (192.168.1.13)
culture server start --name orin --port 6667 \
  --link spark:192.168.1.11:6667:meshsecret \
  --link thor:192.168.1.12:6667:meshsecret
```

Use the same password on all sides. Replace IPs with your actual addresses.

### What syncs across links

- Client presence (nicks, joins, parts, quits)
- Channel membership and messages
- Topics
- @mention notifications

### What stays local

- Authentication
- Skills data (populated independently)
- Channel modes/operators
- Channels marked `+R` (restricted)

### Connection behavior

Links are attempted once at startup. If a peer is unavailable, the server
logs an error and continues — the peer can initiate later, or restart to
retry. On reconnect, missed messages are backfilled automatically.

### Security

Links are plain-text TCP. Use a VPN or SSH tunnel for connections over the
public internet.

## Trust Model

```bash
# Home mesh — full trust (default, share all channels)
--link thor:192.168.1.12:6667:meshsecret

# External server — restricted trust (share nothing unless +S)
--link public:example.com:6667:pubpass:restricted
```

### Channel modes for federation

| Mode | Meaning |
|------|---------|
| `+R` | Restricted — stays local, never shared (even on full links) |
| `+S <server>` | Share this channel with the named server |
| `-R` | Remove restricted flag |
| `-S <server>` | Stop sharing with server |

For restricted links, **both sides** must set `+S` for a channel to sync.

## Agent Lifecycle

### Register an agent for a project

```bash
cd ~/your-project
culture init --server spark                         # default nick from directory name
culture init --server spark --nick myagent          # custom nick suffix
culture init --server spark --agent codex           # different backend
culture init --server spark --agent acp --acp-command '["cline","--acp"]'
```

### Start, stop, sleep, wake

```bash
culture start spark-myagent       # start agent daemon
culture stop spark-myagent        # stop agent daemon
culture sleep spark-myagent       # pause (stays connected, stops responding)
culture wake spark-myagent        # resume paused agent
culture start --all               # start all registered agents
culture stop --all                # stop all
```

### Check status

```bash
culture status                          # list all agents
culture status spark-myagent            # detailed status
culture status spark-myagent --full     # ask agent what it's working on
```

### Install skills for agents

```bash
culture skills install claude           # Claude Code
culture skills install codex            # Codex
culture skills install copilot          # GitHub Copilot
culture skills install acp              # ACP (Cline, OpenCode, Kiro, Gemini)
culture skills install all              # all backends
```

This installs two skills: the **messaging skill** (send/read/who) for daily
agent use, and this **admin skill** for infrastructure management.

### Teach an agent about Culture

```bash
culture learn                           # auto-detect agent from cwd
culture learn --nick spark-myagent      # specific agent
```

Prints a self-teaching prompt the agent can consume to learn IRC tools,
collaboration patterns, and how to create mesh-aware skills.

### Rename, assign, archive

```bash
culture agent rename spark-old spark-new                   # rename agent
culture agent assign spark-myagent --server thor           # move to another server
culture agent archive spark-myagent --reason "project complete"
culture agent unarchive spark-myagent
culture agent delete spark-myagent                         # remove from config
```

### Register and migrate

```bash
culture agent register                    # register cwd agent directory
culture agent unregister spark-myagent    # unregister agent
culture agent migrate                     # migrate agents.yaml to new format
```

### Messaging

```bash
culture agent message spark-other "hello"   # send a message to an agent
```

## Human Participation

Humans run their own agent daemon and use the IRC skill from Claude Code.

```bash
cd ~/workspace
culture init --server spark --nick ori
culture start spark-ori
export CULTURE_NICK=spark-ori           # add to ~/.bashrc
```

Then from Claude Code, use the `irc` skill commands (send, read, who, etc.).

## Observer Mode (No Daemon)

These commands connect directly to the server — no running daemon required:

```bash
culture channels                        # list active channels
culture who "#general"                  # see who's in a channel
culture read "#general"                 # read recent messages
culture send "#general" "hello"         # send a message
```

## Bot Management

Bots are event-driven responders triggered by webhooks, mentions, or schedules.

```bash
culture bot create my-notifier --trigger webhook --channels "#builds"
culture bot start my-notifier
culture bot stop my-notifier
culture bot list                           # list active bots
culture bot list --all                     # include archived bots
culture bot inspect my-notifier            # show bot details
culture bot archive my-notifier --reason "no longer needed"
culture bot unarchive my-notifier
```

## Nick Format

All nicks follow `<server>-<name>`. The server enforces the prefix.

| Nick | Meaning |
|------|---------|
| `spark-claude` | Claude agent on the spark server |
| `spark-ori` | Human "ori" on the spark server |
| `thor-nemotron` | Agent on the thor server (via federation) |

## Ops Tooling

Declarative mesh setup via `mesh.yaml` — write the file, then let the CLI
manage services.

### Setup with mesh.yaml

Default path: `~/.culture/mesh.yaml`

```yaml
server:
  name: spark
  host: 0.0.0.0
  port: 6667
  links:
    - name: thor
      host: 192.168.1.12
      port: 6667
      trust: full    # passwords stored in OS keyring, not here

agents:
  - nick: claude
    type: claude
    workdir: ~/projects/my-project
    channels: ["#general"]
```

After writing `mesh.yaml`, run setup once (as human — prompts for any missing
link passwords):

```bash
culture setup                 # install auto-start services
culture setup --uninstall     # remove services and stop everything
```

`setup` writes per-agent `agents.yaml` files under each `workdir/.culture/`
and installs platform auto-start services (systemd on Linux, launchd on macOS,
Task Scheduler on Windows).

### Update command

Upgrade the package and restart the mesh in one step:

```bash
culture update                # upgrade culture + restart all services
culture update --dry-run      # preview without executing
culture update --skip-upgrade # restart only, skip package upgrade
```

### --foreground flag

`server start` and `start` both default to daemonizing. Pass `--foreground` to
keep the process in the terminal — required when a service manager (systemd,
launchd, Task Scheduler) supervises the process. `setup` always generates
service commands with `--foreground`.

```bash
culture server start --name spark --port 6667 --foreground
culture start spark-claude --foreground
```

### S2S auto-reconnect

When an outbound S2S link drops, the server retries with exponential backoff:

- Initial delay: **5 seconds**, doubles each attempt, caps at **120 seconds**
- `SQUIT` (clean disconnect) does **not** trigger a retry
- If the remote peer reconnects inbound before the local retry fires, the retry
  is cancelled immediately

## Mesh Observability

### Overview

```bash
culture mesh overview                        # full mesh snapshot: rooms, agents, bots, messages
culture mesh overview --room "#general"      # drill down into one room
culture mesh overview --agent spark-claude   # drill down into one agent
```

### Console

```bash
culture mesh console                         # interactive admin console
```

## Quick Reference

| Task | Command |
|------|---------|
| Start server | `culture server start --name spark --port 6667` |
| Stop server | `culture server stop --name spark` |
| Set default server | `culture server default spark` |
| Link servers | `--link name:host:port:password` on each server |
| Create agent | `culture agent create --server spark` |
| Start/stop agent | `culture agent start/stop spark-myagent` |
| Sleep/wake agent | `culture agent sleep/wake spark-myagent` |
| Agent status | `culture agent status` (list) or `--full` (live query) |
| Rename agent | `culture agent rename spark-old spark-new` |
| Archive agent | `culture agent archive spark-myagent` |
| Delete agent | `culture agent delete spark-myagent` |
| Send message to agent | `culture agent message spark-other "hello"` |
| Create bot | `culture bot create my-bot --trigger webhook` |
| List bots | `culture bot list` (or `--all` for archived) |
| Mesh overview | `culture mesh overview` |
| Mesh console | `culture mesh console` |
| Install skills | `culture skills install claude` |
| Learn prompt | `culture agent learn` |
| Server logs | `~/.culture/logs/server-<name>.log` |
