From 7edea7e169bfbd47c3cee5aa6a24307015299ace Mon Sep 17 00:00:00 2001 From: deerdear Date: Wed, 14 Jan 2026 00:44:12 +0100 Subject: [PATCH] feat: add project-init plugin with /new-project command Add a new plugin that creates project directories with a single command: - Creates named directory - Initializes git repository - Creates CLAUDE.md template - Creates .gitignore with common defaults - Makes initial commit This provides a workaround for the feature request to add project name argument to the init command (#18024). Co-Authored-By: Claude Opus 4.5 --- plugins/README.md | 1 + .../project-init/.claude-plugin/plugin.json | 9 ++ plugins/project-init/README.md | 56 +++++++++ plugins/project-init/commands/new-project.md | 112 ++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 plugins/project-init/.claude-plugin/plugin.json create mode 100644 plugins/project-init/README.md create mode 100644 plugins/project-init/commands/new-project.md diff --git a/plugins/README.md b/plugins/README.md index cf4a21ecc5..e25f063c7e 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -23,6 +23,7 @@ Learn more in the [official plugins documentation](https://docs.claude.com/en/do | [learning-output-style](./learning-output-style/) | Interactive learning mode that requests meaningful code contributions at decision points (mimics the unshipped Learning output style) | **Hook:** SessionStart - Encourages users to write meaningful code (5-10 lines) at decision points while receiving educational insights | | [plugin-dev](./plugin-dev/) | Comprehensive toolkit for developing Claude Code plugins with 7 expert skills and AI-assisted creation | **Command:** `/plugin-dev:create-plugin` - 8-phase guided workflow for building plugins
**Agents:** `agent-creator`, `plugin-validator`, `skill-reviewer`
**Skills:** Hook development, MCP integration, plugin structure, settings, commands, agents, and skill development | | [pr-review-toolkit](./pr-review-toolkit/) | Comprehensive PR review agents specializing in comments, tests, error handling, type design, code quality, and code simplification | **Command:** `/pr-review-toolkit:review-pr` - Run with optional review aspects (comments, tests, errors, types, code, simplify, all)
**Agents:** `comment-analyzer`, `pr-test-analyzer`, `silent-failure-hunter`, `type-design-analyzer`, `code-reviewer`, `code-simplifier` | +| [project-init](./project-init/) | Initialize new projects with a single command: create directory, git repo, and Claude Code configuration | **Command:** `/new-project` - Create a new project directory with git and CLAUDE.md | | [ralph-wiggum](./ralph-wiggum/) | Interactive self-referential AI loops for iterative development. Claude works on the same task repeatedly until completion | **Commands:** `/ralph-loop`, `/cancel-ralph` - Start/stop autonomous iteration loops
**Hook:** Stop - Intercepts exit attempts to continue iteration | | [security-guidance](./security-guidance/) | Security reminder hook that warns about potential security issues when editing files | **Hook:** PreToolUse - Monitors 9 security patterns including command injection, XSS, eval usage, dangerous HTML, pickle deserialization, and os.system calls | diff --git a/plugins/project-init/.claude-plugin/plugin.json b/plugins/project-init/.claude-plugin/plugin.json new file mode 100644 index 0000000000..a112c6f32d --- /dev/null +++ b/plugins/project-init/.claude-plugin/plugin.json @@ -0,0 +1,9 @@ +{ + "name": "project-init", + "description": "Initialize new projects with a single command: create directory, git repo, and Claude Code configuration", + "version": "1.0.0", + "author": { + "name": "Anthropic", + "email": "support@anthropic.com" + } +} diff --git a/plugins/project-init/README.md b/plugins/project-init/README.md new file mode 100644 index 0000000000..c7f88a76b1 --- /dev/null +++ b/plugins/project-init/README.md @@ -0,0 +1,56 @@ +# Project Init Plugin + +Initialize new projects with a single command. Creates a directory, initializes git, and sets up Claude Code configuration. + +## Commands + +### `/new-project ` + +Creates a new project directory with: +- Git repository initialized +- `CLAUDE.md` template for project context +- `.gitignore` with common defaults +- Initial commit + +**Usage:** +```bash +/new-project my-awesome-app +``` + +**What it creates:** +``` +my-awesome-app/ +├── .git/ +├── .gitignore +└── CLAUDE.md +``` + +## Installation + +This plugin is included in the Claude Code plugins directory. To use it: + +1. Ensure Claude Code is installed +2. The plugin is automatically available when running Claude Code from the repository +3. Or install via the plugin marketplace + +## Why Use This? + +This plugin streamlines the project creation workflow. Instead of: +```bash +mkdir my-project +cd my-project +git init +# manually create CLAUDE.md +# manually create .gitignore +git add -A +git commit -m "Initial commit" +``` + +Just run: +```bash +/new-project my-project +``` + +## Feature Request + +This plugin serves as a workaround until native support is added to the Claude Code CLI. See the feature request: [Add project name argument to init command](https://github.com/anthropics/claude-code/issues/18024) diff --git a/plugins/project-init/commands/new-project.md b/plugins/project-init/commands/new-project.md new file mode 100644 index 0000000000..63a1c57124 --- /dev/null +++ b/plugins/project-init/commands/new-project.md @@ -0,0 +1,112 @@ +--- +description: Create and initialize a new project directory with git and Claude Code configuration +argument-hint: +allowed-tools: Bash(mkdir:*), Bash(cd:*), Bash(git init:*), Bash(git add:*), Bash(git commit:*), Bash(ls:*), Bash(pwd:*), Write, AskUserQuestion +--- + +## Your Task + +Create a new project directory and initialize it for development with Claude Code. + +**Project name from arguments:** $ARGUMENTS + +## Workflow + +### 1. Validate Project Name + +If no project name was provided (`$ARGUMENTS` is empty), ask the user: +- "What would you like to name your project?" + +Validate the project name: +- Must not be empty +- Should be a valid directory name (no special characters that would cause issues) +- Should not already exist as a directory + +### 2. Create Project Structure + +Execute these steps: + +1. **Create the project directory:** + ```bash + mkdir -p + ``` + +2. **Initialize git repository:** + ```bash + cd && git init + ``` + +3. **Create CLAUDE.md with basic structure:** + Create a `CLAUDE.md` file in the new directory with: + ```markdown + # + + ## Overview + [Brief description of what this project does] + + ## Tech Stack + [List technologies, frameworks, languages used] + + ## Project Structure + [Describe the directory layout once established] + + ## Development Guidelines + [Any coding standards, patterns, or practices to follow] + + ## Getting Started + [How to set up and run the project] + ``` + +4. **Create .gitignore with common defaults:** + ``` + # Dependencies + node_modules/ + venv/ + __pycache__/ + + # Environment + .env + .env.local + + # IDE + .idea/ + .vscode/ + *.swp + + # OS + .DS_Store + Thumbs.db + + # Build + dist/ + build/ + *.egg-info/ + ``` + +5. **Create initial commit:** + ```bash + cd && git add -A && git commit -m "Initial commit: project scaffolding" + ``` + +### 3. Report Success + +After creating the project, inform the user: + +1. What was created: + - Directory: `/` + - Git repository initialized + - `CLAUDE.md` created + - `.gitignore` created + - Initial commit made + +2. Next steps: + - `cd ` to enter the project + - Run `claude` to start working with Claude Code + - Edit `CLAUDE.md` to add project-specific context + +## Important Notes + +- Create all files in the NEW directory, not the current directory +- Use the exact project name provided (preserve casing) +- Do not create unnecessary files beyond what's specified +- If the directory already exists, ask the user how to proceed (overwrite, use different name, or cancel)