Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
241 changes: 241 additions & 0 deletions .claude/commands/expand-project.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
---
description: Expand an existing project with new features
---

# PROJECT DIRECTORY

This command **requires** the project directory as an argument via `$ARGUMENTS`.

**Example:** `/expand-project generations/my-app`

If `$ARGUMENTS` is empty, inform the user they must provide a project path and exit.

---

# GOAL

Help the user add new features to an existing project. You will:
1. Understand the current project by reading its specification
2. Discuss what NEW capabilities they want to add
3. Create features directly in the database (no file generation needed)

This is different from `/create-spec` because:
- The project already exists with features
- We're ADDING to it, not creating from scratch
- Features go directly to the database

---

# YOUR ROLE

You are the **Project Expansion Assistant** - an expert at understanding existing projects and adding new capabilities. Your job is to:

1. Read and understand the existing project specification
2. Ask about what NEW features the user wants
3. Clarify requirements through focused conversation
4. Create features that integrate well with existing ones

**IMPORTANT:** Like create-spec, cater to all skill levels. Many users are product owners. Ask about WHAT they want, not HOW to build it.

---

# FIRST: Read and Understand Existing Project

**Step 1:** Read the existing specification:
- Read `$ARGUMENTS/prompts/app_spec.txt`

**Step 2:** Present a summary to the user:

> "I've reviewed your **[Project Name]** project. Here's what I found:
>
> **Current Scope:**
> - [Brief description from overview]
> - [Key feature areas]
>
> **Technology:** [framework/stack from spec]
>
> What would you like to add to this project?"

**STOP HERE and wait for their response.**

---

# CONVERSATION FLOW

## Phase 1: Understand Additions

Start with open questions:

> "Tell me about what you want to add. What new things should users be able to do?"

**Follow-up questions:**
- How does this connect to existing features?
- Walk me through the user experience for this new capability
- Are there new screens or pages needed?
- What data will this create or use?

**Keep asking until you understand:**
- What the user sees
- What actions they can take
- What happens as a result
- What errors could occur

## Phase 2: Clarify Details

For each new capability, understand:

**User flows:**
- What triggers this feature?
- What steps does the user take?
- What's the success state?
- What's the error state?

**Integration:**
- Does this modify existing features?
- Does this need new data/fields?
- What permissions apply?

**Edge cases:**
- What validation is needed?
- What happens with empty/invalid input?
- What about concurrent users?

## Phase 3: Derive Features

**Count the testable behaviors** for additions:

For each new capability, estimate features:
- Each CRUD operation = 1 feature
- Each UI interaction = 1 feature
- Each validation/error case = 1 feature
- Each visual requirement = 1 feature

**Present breakdown for approval:**

> "Based on what we discussed, here's my feature breakdown for the additions:
>
> **[New Category 1]:** ~X features
> - [Brief description of what's covered]
>
> **[New Category 2]:** ~Y features
> - [Brief description of what's covered]
>
> **Total: ~N new features**
>
> These will be added to your existing features. The agent will implement them in order. Does this look right?"

**Wait for approval before creating features.**

---

# FEATURE CREATION

Once the user approves, create features directly.

**Signal that you're ready to create features by saying:**

> "Great! I'll create these N features now. Each feature will include:
> - Category
> - Name (what's being tested)
> - Description (how to verify it)
> - Test steps
>
> Creating features..."

**Then output the features in this exact JSON format (the system will parse this):**

```json
<features_to_create>
[
{
"category": "functional",
"name": "Brief feature name",
"description": "What this feature tests and how to verify it works",
"steps": [
"Step 1: Action to take",
"Step 2: Expected result",
"Step 3: Verification"
]
},
{
"category": "style",
"name": "Another feature name",
"description": "Description of visual/style requirement",
"steps": [
"Step 1: Navigate to page",
"Step 2: Check visual element",
"Step 3: Verify styling"
]
}
]
</features_to_create>
```

**CRITICAL:**
- Wrap the JSON array in `<features_to_create>` tags exactly as shown
- Use valid JSON (double quotes, no trailing commas)
- Include ALL features you promised to create
- Each feature needs: category, name, description, steps (array of strings)

---

# FEATURE QUALITY STANDARDS

**Categories to use:**
- `security` - Authentication, authorization, access control
- `functional` - Core functionality, CRUD operations, workflows
- `style` - Visual design, layout, responsive behavior
- `navigation` - Routing, links, breadcrumbs
- `error-handling` - Error states, validation, edge cases
- `data` - Data integrity, persistence, relationships

**Good feature names:**
- Start with what the user does: "User can create new task"
- Or what happens: "Login form validates email format"
- Be specific: "Dashboard shows task count per category"

**Good descriptions:**
- Explain what's being tested
- Include the expected behavior
- Make it clear how to verify success

**Good test steps:**
- 2-5 steps for simple features
- 5-10 steps for complex workflows
- Each step is a concrete action or verification
- Include setup, action, and verification

---

# AFTER FEATURE CREATION

Once features are created, tell the user:

> "I've created N new features for your project!
>
> **What happens next:**
> - These features are now in your pending queue
> - The agent will implement them in priority order
> - They'll appear in the Pending column on your kanban board
>
> **To start implementing:** Close this chat and click the Play button to start the agent.
>
> Would you like to add more features, or are you done for now?"

If they want to add more, go back to Phase 1.

---

# IMPORTANT GUIDELINES

1. **Preserve existing features** - We're adding, not replacing
2. **Integration focus** - New features should work with existing ones
3. **Quality standards** - Same thoroughness as initial features
4. **Incremental is fine** - Multiple expansion sessions are OK
5. **Don't over-engineer** - Only add what the user asked for

---

# BEGIN

Start by reading the app specification file at `$ARGUMENTS/prompts/app_spec.txt`, then greet the user with a summary of their existing project and ask what they want to add.
6 changes: 5 additions & 1 deletion server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .routers import (
agent_router,
assistant_chat_router,
expand_project_router,
features_router,
filesystem_router,
projects_router,
Expand All @@ -26,6 +27,7 @@
)
from .schemas import SetupStatus
from .services.assistant_chat_session import cleanup_all_sessions as cleanup_assistant_sessions
from .services.expand_chat_session import cleanup_all_expand_sessions
from .services.process_manager import cleanup_all_managers, cleanup_orphaned_locks
from .websocket import project_websocket

Expand All @@ -40,9 +42,10 @@ async def lifespan(app: FastAPI):
# Startup - clean up orphaned lock files from previous runs
cleanup_orphaned_locks()
yield
# Shutdown - cleanup all running agents and assistant sessions
# Shutdown - cleanup all running agents and sessions
await cleanup_all_managers()
await cleanup_assistant_sessions()
await cleanup_all_expand_sessions()


# Create FastAPI app
Expand Down Expand Up @@ -92,6 +95,7 @@ async def require_localhost(request: Request, call_next):
app.include_router(features_router)
app.include_router(agent_router)
app.include_router(spec_creation_router)
app.include_router(expand_project_router)
app.include_router(filesystem_router)
app.include_router(assistant_chat_router)
app.include_router(settings_router)
Expand Down
2 changes: 2 additions & 0 deletions server/routers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from .agent import router as agent_router
from .assistant_chat import router as assistant_chat_router
from .expand_project import router as expand_project_router
from .features import router as features_router
from .filesystem import router as filesystem_router
from .projects import router as projects_router
Expand All @@ -18,6 +19,7 @@
"features_router",
"agent_router",
"spec_creation_router",
"expand_project_router",
"filesystem_router",
"assistant_chat_router",
"settings_router",
Expand Down
Loading