selfhost-ai CLAUDE.md

selfhost-ai CLAUDE.md is an instructions file for coding agents from kossakovsky/selfhost-ai. It costs 6,661 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

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/kossakovsky/selfhost-ai/claude-md
Clone the repo
git clone --depth 1 https://github.com/kossakovsky/selfhost-ai

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.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.svg" alt="Measured on agentmods" height="20"></a>
Per session 6,661 This file is loaded in full into every session.
When invoked 6,661 The same file — it is already loaded in full.
Security scan B 2 findings. Scan, not verified.
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 $0.06661 $0.06661
Opus 5 $0.03331 $0.03331
Sonnet 5 $0.01332 $0.01332
Haiku 4.5 $0.00666 $0.00666

Measured yesterday against content hash f25d5a28ad01, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 yesterday.

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.

- `get_real_user` / `get_real_user_home` - Get actual user even under sudo - `backup_preserved_dirs` / `restore_preserved_dirs` - Directory preservation for git updates

Makes network callslowCapability

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

test: ["CMD-SHELL", "wget -qO- http://localhost:8080/health || exit 1"]
CLAUDE.md · 426 lines

How it starts

The opening of the file, as written. The whole thing — 426 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
  • 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/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/download_top_workflows.sh: Downloads community n8n workflows
  • 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
  • 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 · 426 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. yesterday Changed · +9 lines · +716 tokens per session f25d5a28ad01
  2. 5d ago First seen · 417 lines · 5,945 tokens per session scan B fcb0185b50ac

Subscribe to this mod's changes

selfhost-ai CLAUDE.md is an instructions file published in the GitHub repository kossakovsky/selfhost-ai (922 stars, last pushed 2d ago), licensed Apache-2.0. It adds 6,661 tokens to every session, about $0.0333 per session on Opus 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.