|
| 1 | +--- |
| 2 | +title: "CLI Reference" |
| 3 | +linkTitle: "CLI Reference" |
| 4 | +weight: 25 |
| 5 | +description: "Complete reference for the devrail init command." |
| 6 | +--- |
| 7 | + |
| 8 | +## Installation |
| 9 | + |
| 10 | +`devrail init` is a single shell script. No package manager is required — run it directly with `curl`: |
| 11 | + |
| 12 | +```bash |
| 13 | +curl -fsSL https://devrail.dev/init.sh | bash |
| 14 | +``` |
| 15 | + |
| 16 | +Or download it for repeated use: |
| 17 | + |
| 18 | +```bash |
| 19 | +curl -fsSL https://devrail.dev/init.sh -o devrail-init.sh |
| 20 | +chmod +x devrail-init.sh |
| 21 | +./devrail-init.sh [options] |
| 22 | +``` |
| 23 | + |
| 24 | +## Synopsis |
| 25 | + |
| 26 | +``` |
| 27 | +devrail init [options] |
| 28 | +``` |
| 29 | + |
| 30 | +When run without options, the script launches an interactive wizard that prompts for languages, CI platform, and which adoption layers to install. |
| 31 | + |
| 32 | +## Options |
| 33 | + |
| 34 | +| Option | Description | |
| 35 | +|---|---| |
| 36 | +| `--languages <list>` | Comma-separated list of languages (e.g., `python,bash,go`) | |
| 37 | +| `--ci <platform>` | CI platform: `github`, `gitlab`, or `none` | |
| 38 | +| `--all` | Install all 4 layers (agent files, pre-commit, Makefile, CI) | |
| 39 | +| `--agents-only` | Install only Layer 1 (agent instruction files) | |
| 40 | +| `--yes` | Non-interactive mode; skip existing files without prompting | |
| 41 | +| `--force` | Overwrite existing files without prompting | |
| 42 | +| `--dry-run` | Show what would be generated without writing any files | |
| 43 | +| `--version` | Print the DevRail version and exit | |
| 44 | +| `--help` | Print usage information and exit | |
| 45 | + |
| 46 | +## Supported Languages |
| 47 | + |
| 48 | +The `--languages` flag accepts any combination of the following: |
| 49 | + |
| 50 | +| Language | Pre-commit Hooks | Makefile Targets | |
| 51 | +|---|---|---| |
| 52 | +| `python` | ruff (lint + format) | ruff check, ruff format, pytest | |
| 53 | +| `bash` | shellcheck, shfmt | shellcheck, shfmt | |
| 54 | +| `terraform` | terraform_fmt, terraform_validate, terraform_tflint, terragrunt_fmt | tflint, terraform fmt | |
| 55 | +| `ansible` | ansible-lint | ansible-lint | |
| 56 | +| `ruby` | rubocop | rubocop, brakeman, bundler-audit | |
| 57 | +| `go` | golangci-lint | golangci-lint, gofumpt, govulncheck | |
| 58 | +| `javascript` | eslint, prettier | eslint, prettier, tsc, npm audit | |
| 59 | +| `rust` | cargo-fmt, cargo-clippy | cargo fmt, cargo clippy, cargo audit | |
| 60 | + |
| 61 | +## Adoption Layers |
| 62 | + |
| 63 | +`devrail init` uses a 4-layer progressive adoption model. In interactive mode, you choose which layers to install. In non-interactive mode, use `--all` for everything or `--agents-only` for just Layer 1. |
| 64 | + |
| 65 | +### Layer 1: Agent Instruction Files |
| 66 | + |
| 67 | +Files that tell AI coding agents (Claude Code, Cursor, OpenCode) how to work in your project. |
| 68 | + |
| 69 | +| File | Purpose | |
| 70 | +|---|---| |
| 71 | +| `CLAUDE.md` | Claude Code agent instructions | |
| 72 | +| `AGENTS.md` | Generic agent instructions | |
| 73 | +| `.cursorrules` | Cursor agent instructions | |
| 74 | +| `.opencode/agents.yaml` | OpenCode agent instructions | |
| 75 | + |
| 76 | +### Layer 2: Pre-commit Hooks |
| 77 | + |
| 78 | +Language-aware `.pre-commit-config.yaml` with hooks for your declared languages, plus conventional commits and gitleaks secret detection. |
| 79 | + |
| 80 | +### Layer 3: Makefile + Container |
| 81 | + |
| 82 | +| File | Purpose | |
| 83 | +|---|---| |
| 84 | +| `Makefile` | Two-layer delegation pattern (host → Docker → container) | |
| 85 | +| `DEVELOPMENT.md` | Canonical development standards reference | |
| 86 | +| `.editorconfig` | Editor formatting rules | |
| 87 | +| `.gitignore` | Standard ignore patterns (appended if exists) | |
| 88 | +| `.gitleaksignore` | Gitleaks allowlist | |
| 89 | +| `.devrail.yml` | Language declaration and project settings | |
| 90 | + |
| 91 | +### Layer 4: CI Pipelines |
| 92 | + |
| 93 | +**GitHub Actions** generates 6 workflow files: |
| 94 | + |
| 95 | +- `.github/workflows/lint.yml` |
| 96 | +- `.github/workflows/format.yml` |
| 97 | +- `.github/workflows/test.yml` |
| 98 | +- `.github/workflows/security.yml` |
| 99 | +- `.github/workflows/scan.yml` |
| 100 | +- `.github/workflows/docs.yml` |
| 101 | + |
| 102 | +Plus `.github/PULL_REQUEST_TEMPLATE.md` and `.github/CODEOWNERS`. |
| 103 | + |
| 104 | +**GitLab CI** generates: |
| 105 | + |
| 106 | +- `.gitlab-ci.yml` (single file with parallel check-stage jobs) |
| 107 | +- `.gitlab/merge_request_templates/default.md` |
| 108 | +- `.gitlab/CODEOWNERS` |
| 109 | + |
| 110 | +## Conflict Resolution |
| 111 | + |
| 112 | +When `devrail init` encounters an existing file: |
| 113 | + |
| 114 | +| Mode | Behavior | |
| 115 | +|---|---| |
| 116 | +| Interactive (default) | Prompts: **[s]kip**, **[o]verwrite**, or **[b]ackup + overwrite** | |
| 117 | +| `--yes` | Skips existing files (safe, preserves your files) | |
| 118 | +| `--force` | Overwrites existing files without prompting | |
| 119 | + |
| 120 | +### Makefile Merge Strategy |
| 121 | + |
| 122 | +| Scenario | Behavior | |
| 123 | +|---|---| |
| 124 | +| No existing Makefile | DevRail Makefile written normally | |
| 125 | +| Existing Makefile with DevRail markers | Updated in-place between markers | |
| 126 | +| Existing non-DevRail Makefile | Backed up to `Makefile.pre-devrail`, DevRail Makefile written, include guidance printed | |
| 127 | + |
| 128 | +### .gitignore Handling |
| 129 | + |
| 130 | +DevRail patterns are appended below a `# --- DevRail ---` marker. If the marker already exists, the append is skipped (idempotent). |
| 131 | + |
| 132 | +## `.devrail.yml` Configuration |
| 133 | + |
| 134 | +The script reads `.devrail.yml` if it exists, or creates one based on the `--languages` flag or interactive prompts. |
| 135 | + |
| 136 | +```yaml |
| 137 | +# .devrail.yml |
| 138 | +languages: |
| 139 | + - python |
| 140 | + - bash |
| 141 | + |
| 142 | +fail_fast: false |
| 143 | +log_format: json |
| 144 | +``` |
| 145 | +
|
| 146 | +## Examples |
| 147 | +
|
| 148 | +```bash |
| 149 | +# Interactive mode — walks through all choices |
| 150 | +curl -fsSL https://devrail.dev/init.sh | bash |
| 151 | + |
| 152 | +# Greenfield Python project with GitHub Actions |
| 153 | +curl -fsSL https://devrail.dev/init.sh | bash -s -- --all --languages python --ci github --yes |
| 154 | + |
| 155 | +# Add agent files only to any project |
| 156 | +curl -fsSL https://devrail.dev/init.sh | bash -s -- --agents-only --yes |
| 157 | + |
| 158 | +# Preview what would be generated (dry run) |
| 159 | +curl -fsSL https://devrail.dev/init.sh | bash -s -- --all --languages go,rust --ci gitlab --dry-run |
| 160 | + |
| 161 | +# Multi-language project with GitLab CI |
| 162 | +curl -fsSL https://devrail.dev/init.sh | bash -s -- --all --languages python,bash,terraform --ci gitlab --yes |
| 163 | + |
| 164 | +# Force overwrite all existing files |
| 165 | +curl -fsSL https://devrail.dev/init.sh | bash -s -- --all --languages javascript --ci github --force |
| 166 | +``` |
| 167 | + |
| 168 | +## Environment Variables |
| 169 | + |
| 170 | +| Variable | Default | Description | |
| 171 | +|---|---|---| |
| 172 | +| `DEVRAIL_VERSION` | `v1` | Container image tag used in generated files | |
0 commit comments