selfhost-ai: Instructions file for Claude Code

CLAUDE.md

selfhost-ai CLAUDE.md is an instructions file for Claude Code from kossakovsky/selfhost-ai. It costs 11,781 tokens per session, scanned B, original, Apache-2.0.

A contributor guide for Selfhost AI, a Docker Compose installer for running n8n workflow automation and other AI services on your own infrastructure. It explains service profiles, HTTPS routing, shared secrets, databases, and workers.

In plain words
What is it for?
Use it when modifying installation flows, Docker Compose profiles, Caddy HTTPS routing, secret generation, n8n workers, or the included self-hosted services.
Why use it?
It gives an agent the architecture needed to change the installer without breaking service selection or network access. It also clarifies how n8n depends on its database and queue services.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: reads .claude/ paths; mentions CLAUDE.md; positional $N argument.

This is kossakovsky/selfhost-ai's own configuration. It tells Claude Code how to work on selfhost-ai itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything selfhost-ai configures →

Not installable: its command points at a path on the author’s own machine, so it runs nowhere else. The line is /home/node/.openclaw.

Reuse

Borrowing it

Nothing to install: this file belongs to kossakovsky/selfhost-ai. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/kossakovsky/selfhost-ai/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/kossakovsky/selfhost-ai

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for selfhost-ai CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/kossakovsky/selfhost-ai/claude-md/github.svg)](https://agentmods.dev/instructions/kossakovsky/selfhost-ai/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/kossakovsky/selfhost-ai/claude-md"><img src="https://agentmods.dev/badge/instructions/kossakovsky/selfhost-ai/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for selfhost-ai CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/kossakovsky/selfhost-ai/claude-md"><img src="https://agentmods.dev/badge/instructions/kossakovsky/selfhost-ai/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 11,781 This file is loaded in full into every session.
When invoked 11,781 The same file — it is already loaded in full.
Security scan B 2 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.11781 $0.11781
Opus 5.5 $0.04712 $0.04712
Sonnet 5.5 $0.02356 $0.02356
Haiku 4.5 $0.01178 $0.01178

Measured 9d ago against content hash 222402725f46, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade B, and why

selfhost-ai CLAUDE.md scanned grade B with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

- **Never add `OPEN_TERMINAL_ALLOWED_DOMAINS` to the compose file.** The entrypoint distinguishes unset (full egress) from set-but-empty (drop all outbound) and runs `sudo iptables` under `set -e`, which needs `NET_ADMIN

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

- Never mount `docker.sock`: the entrypoint auto-joins the socket's group and the agent's shell would control the host daemon. The server process runs as `user` with passwordless sudo, so no `cap_drop` (apt, useradd and
CLAUDE.md · 478 lines

How it starts

The opening of the file, as written. The whole thing — 478 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

This is Selfhost AI (repository selfhost-ai, formerly n8n-install), a Docker Compose-based installer that provides a comprehensive self-hosted environment for n8n workflow automation and numerous AI/automation services. The installer includes an interactive wizard, automated secret generation, and integrated HTTPS via Caddy.

Core Architecture

  • Profile-based service management: Services are activated via Docker Compose profiles (e.g., n8n, flowise, monitoring). Profiles are stored in the .env file's COMPOSE_PROFILES variable.
  • No exposed ports: Services do NOT publish ports directly. All external HTTPS access is routed through Caddy reverse proxy on ports 80/443.
  • Shared secrets: Core services (Postgres, Valkey (Redis-compatible, container named redis for backward compatibility), Caddy) are always included. Other services are optional and selected during installation.
  • Queue-based n8n: n8n runs in queue mode with Redis, Postgres, and dynamically scaled workers (N8N_WORKER_COUNT).

Key Files

  • Makefile: Common commands (install, update, logs, etc.)
  • docker-compose.yml: Service definitions with profiles
  • Caddyfile: Reverse proxy configuration with automatic HTTPS
  • .env: Generated secrets and configuration (from .env.example)
  • scripts/install.sh: Main installation orchestrator (runs numbered scripts 01-08 in sequence)
  • scripts/utils.sh: Shared utility functions (sourced by all scripts via source "$(dirname "$0")/utils.sh" && init_paths)
  • scripts/01_system_preparation.sh: System updates, firewall, security hardening
  • scripts/02_install_docker.sh: Docker and Docker Compose installation
  • scripts/git.sh: Git utilities (sync with origin, branch detection, configuration)
  • scripts/03_generate_secrets.sh: Secret generation and bcrypt hashing
  • scripts/04_wizard.sh: Interactive service selection using whiptail
  • scripts/05_configure_services.sh: Service-specific configuration logic
  • scripts/databases.sh: Creates isolated PostgreSQL databases for services (library)
  • scripts/telemetry.sh: Anonymous telemetry functions (Scarf integration)
  • scripts/06_run_services.sh: Starts Docker Compose stack
  • scripts/07_final_report.sh: Post-install credential summary
  • scripts/08_fix_permissions.sh: Fixes file ownership for non-root access. Skips the container-written data directories under supabase/docker/volumes (db/data, storage) and dify/docker/volumes (default stack plus every optional vector store's data; CONTAINER_OWNED_DIRS; supabase/postgres cannot read its data as the host user) and, as a backstop, gives Supabase Postgres files back to the uid supabase-db reports
  • scripts/generate_n8n_workers.sh: Generates dynamic worker/runner compose file and the Prometheus n8n targets file
  • scripts/generate_ollama_instances.sh: Generates extra Ollama instances compose file (multi-GPU)
  • scripts/update.sh: Update orchestrator (syncs with origin and updates images)
  • scripts/update_preview.sh: Preview available updates without applying (dry-run)
  • scripts/pull_images.sh: Image pull without the rest of the update (pooled, then per-service retries if that fails); skips locally built services (n8n, runners, OpenClaw) and recreates nothing (used by make pull)
  • scripts/doctor.sh: System diagnostics (DNS, SSL, containers, disk, memory)
  • scripts/apply_update.sh: Applies updates after git sync
  • scripts/docker_cleanup.sh: Removes unused Docker resources (used by make clean)
  • scripts/import_workflows.sh: Imports workflows from n8n/backup/workflows/ into n8n (used by make import)
  • scripts/restart.sh: Restarts services with proper compose file handling (used by make restart)
  • scripts/setup_custom_tls.sh: Configures custom TLS certificates (used by make setup-tls); supports --remove to revert to Let's Encrypt
  • scripts/setup_sysbox.sh: Installs Sysbox (sysbox-runc) for the n8n Assistant sandbox runner; called by 05_configure_services.sh when the n8n-sandbox profile is active
  • start_services.py: Python orchestrator for service startup order, builds Docker images, handles external services (Supabase/Dify cloning, env preparation, startup), generates SearXNG secret key, stops existing containers. Uses python-dotenv (dotenv_values).

Read the full file on GitHub · 478 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago Changed · +1 lines · +104 tokens per session 222402725f46
  2. 18d ago Changed · +3 lines · +532 tokens per session e55374cb3245
  3. 23d ago Changed · +5 lines · +270 tokens per session d24505c9777d
  4. 27d ago Changed · +233 tokens per session 42b236ecefa3
  5. 1mo ago Changed · +2 lines · +173 tokens per session 61592d2c4ab5
  6. 1mo ago Changed · +1 lines · +246 tokens per session 101d2874c58b
  7. 1mo ago Changed · +2 lines · +143 tokens per session 28092c2bce8f
  8. 1mo ago Changed · +12 lines · +1,560 tokens per session 9a7bbced6697
  9. 1mo ago Changed · +3 lines · +233 tokens per session 616d9b420c7d
  10. 1mo ago First seen · 449 lines · 8,287 tokens per session scan B 9b480c01c354

Subscribe to this mod's changes

selfhost-ai CLAUDE.md is an instructions file published in the GitHub repository kossakovsky/selfhost-ai (955 stars, last pushed 10d ago), licensed Apache-2.0. It adds 11,781 tokens to every session, about $0.0471 per session on Opus 5.5. A static security scan graded it B with 2 findings (asks for root, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

selfhost-ai CLAUDE.md compared with instructions from other repositories

selfhost-ai CLAUDE.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
selfhost-ai CLAUDE.mdkossakovsky/selfhost-aiInstructions file95510d agoApache-2.0B11,781Claude Code
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode