Claude
Skills
Sign in
Back

init-project

Included with Lifetime
$97 forever

Initialize project with agent infrastructure, documentation structure, and tooling gaps filled

AI Agents

What this skill does


# Init Project

Initialize the current project with agent infrastructure, documentation, and tooling. Stack assumption: **rosemary** (memory), **mise** (tools), **make** (commands). Nix is supported as an opt-in for repos that already use it.

## Phase 1: Scan

Silently collect before asking anything:

- **Language/framework**: file extensions, config files, dependency manifests
- **Build system**: `Makefile`, `Cargo.toml`, `go.mod`, `package.json`, `build.zig`, etc.
- **Existing agent infra**: `AGENTS.md`, `.agents/`, `CLAUDE.md`, `.cursor/`, `rosemary.toml`
- **Tooling**:
  - Mise: `mise.toml`, `.mise.toml` — primary tool source
  - Nix: `flake.nix`, `shell.nix`, `default.nix`, `flake.lock` — optional, only when already present
  - Formatters, linters, git hooks, CI/CD, editor config
  - Task runner: `Makefile` (primary), `justfile`, `Taskfile.yml`
- **Memory**: run `command -v rosemary` — primary store when present; `.agents/` files are the fallback
- **Docs**: `README.md`, `docs/`, existing architecture or design docs
- **Git state**: branch, remotes, recent commits

## Phase 2: Report & Ask

Present scan summary, then ask **one question at a time** for anything not inferable:

1. "What does this project do?" — for AGENTS.md overview
2. "Architecture style?" — monolith / library / CLI / API / microservice
3. "Key coding conventions?" — naming, error handling, testing philosophy
4. "Quality checks that must pass?" — format, lint, test, coverage
5. "Tooling: mise (default) or nix?" — default to mise + Makefile. Choose nix only if `flake.nix` is already present or the user asks; then generate `flake.nix` + the NIX_RUN Makefile wrapper.
6. "Does this project have config management (env files, secrets, migrations) or a release process (tagging, changelogs, CI gates)?" — if yes, generate `rules/config.md` and/or `rules/release.md` in Phase 3.
7. Per tooling gap: "No [tool] found. Want me to add [suggestion]?"

## Phase 3: Generate Agent Infrastructure

If `rosemary` is available, call `rosemary read-graph` first and merge retrieved facts into generated files:

- `CodingStyle` → `AGENTS.md` Coding Conventions
- `ToolPreferences` → `AGENTS.md` Build/Run/Test
- `UserPreferences` → `.agents/CONTEXT.md` Agent Rules

Ask permission before writing each file. Never overwrite without asking.

After generating files, if `rosemary` is available, seed the graph so `/rosemary start` has context on first run:

1. Project entity (repo basename): `rosemary create-entities "[repo-basename]" "project"` then `add-observations` for tech stack + architecture, tool provisioning method (mise / nix), task runner + key make targets, and any non-obvious conventions from the scan.
2. Missing category entities (`UserPreferences`, `CodingStyle`, `ToolPreferences`): seed from the **Global Seed Values in the rosemary skill** — it is the canonical source for these defaults.

### AGENTS.md

Public project briefing for humans and agents. Sections:

- **Project Overview** — description, purpose
- **Tech Stack & Architecture** — detected stack, structure, key patterns
- **Build, Run & Test** — `make fmt`, `make lint`, `make test`, `make check`, etc. All daily operations go through `make <target>`. Tools come from mise (`mise install` to provision). If nix was chosen: enter the shell with `nix develop`, or run a one-off via `nix develop --command <cmd>`.
- **Coding Conventions** — naming, error handling, formatting rules
- **Key Files & Entry Points** — important paths for quick orientation
- **Quality Standards** — required checks before commit/merge

### .agents/ (file fallback)

Generated so the project works when `rosemary` is not installed. When rosemary is present, session state lives in the graph and these files are skipped at runtime. Add all three to `.gitignore`.

- **`.agents/CONTEXT.md`** — Agent Rules (hard DO/DON'T) + Project Context + Tool Provisioning:
  - DO: use `make <target>` for all task execution
  - DO: at session start, load rosemary entities if available; otherwise read `.agents/CONTEXT.md` + `CURRENT_TASK.md`
  - DO: at session end, write state to the `[project]:session` rosemary entity; save conventions to the project entity — fall back to local files only when rosemary is absent
  - DO: dispatch sub-agents for independent parallel tasks by default
  - DON'T: commit without user confirmation
  - DON'T: use plan mode for small, well-scoped tasks
  - DON'T: install tools globally — use mise (or the nix devShell, if nix) instead
  - Tool Provisioning: mise (`mise install`, `mise exec -- <cmd>`); or nix (`nix develop`, `nix develop --command <cmd>`, never install outside the flake)
- **`.agents/CURRENT_TASK.md`** — seed with initial DONE state. Fields: `Objective`, `Status`, `Completed Steps`, `Remaining Steps`, `Next Action`, `Last Updated`.
- **`.agents/MEMORY.md`** — seed with an empty decision-log header.

### `.claude/` directory

Load `configs/claude-infra.md` for templates. Ask permission once for the whole group before writing.

#### CLAUDE.md (root)

Generate if not already present. Keep minimal — `AGENTS.md` is the single source of truth:

```markdown
@AGENTS.md

## Rules

- See `.claude/rules/core.md` for agent DO/DON'T rules
[- See `.claude/rules/config.md` for config management rules  # only if config.md generated]
[- See `.claude/rules/release.md` for release process rules   # only if release.md generated]
```

Never overwrite an existing CLAUDE.md — offer to merge instead.

#### `.claude/rules/core.md`

Always generate. Hard DO/DON'T rules for all agents. Use the template from `configs/claude-infra.md`, adapting the tool-provisioning section to the chosen stack (mise / nix).

Rules without `paths:` frontmatter load every session start. Rules with `paths:` frontmatter load only when Claude reads a matching file — use this for topic-scoped conventions.

#### `.claude/rules/config.md` / `release.md`

Generate only if the user confirmed config management / a release process in Phase 2.

#### `.claude/rules/testing.md` (optional, path-scoped)

Offer if a test directory or pattern is detected. Use `paths:` frontmatter so it loads only on test files:

```markdown
---
paths:
  - "**/*.test.*"
  - "**/*_test.*"
  - "test/**"
  - "tests/**"
---

# Testing conventions

[project-specific testing rules]
```

#### `.claude/agents/` — skip

Do NOT generate `.claude/agents/` files. Global agents (`haiku-developer`, `gemini-developer`, `codex-developer`, `dispatch-debugger`, `repo-scout`) live in `~/.claude/agents/` and apply to every project.

#### `.claude/commands/help.md`

Offer optionally: "Want a `/help` slash command stub?" Generate if accepted.

#### `.claude/settings.json`

Scaffold permissions + hooks. Ask permission before writing. Adapt `allow` to the detected task runner and tooling:

```json
{
  "permissions": {
    "allow": ["Bash(make *)", "Bash(mise *)", "Bash(git log *)", "Bash(git diff *)", "Bash(git status *)"],
    "deny": ["Bash(rm -rf *)"]
  }
}
```

If nix was chosen, add `"Bash(nix develop *)"` to the allow list.

Always include the `block-no-verify` hook — lightweight, protects git hooks on every project:

```json
"hooks": {
  "PreToolUse": [{
    "matcher": "Bash",
    "hooks": [{ "type": "command", "command": "npx -y block-no-verify" }],
    "description": "Block --no-verify flag to protect pre-commit/commit-msg/pre-push hooks"
  }]
}
```

Use `npx -y block-no-verify` (no version pin) — npm caches the resolved version, so repeat invocations are fast; a pin silently goes stale and adds cold-cache latency on every Bash call.

If a formatter is detected (prettier, ruff, taplo, etc.), offer a `PostToolUse` hook scoped to the edited file:

```json
"PostToolUse": [{
  "matcher": "Edit|Write",
  "hooks": [{
    "type": "command",
    "command": "jq -r '.tool_input.file_path // empty' | xargs -I{} prettier --write {} 2>/dev/null || true"
  }],
  "description": "Auto-format file after each edit (prettier)"
}]
```

Scope to `tool_input.file_path` 
Files: 10
Size: 28.7 KB
Complexity: 47/100
Category: AI Agents

Related in AI Agents