Skip to content

Conversation

@DanielHashmi
Copy link

@DanielHashmi DanielHashmi commented Jan 21, 2026

Smart Detection: Preserve User Work When Adding Agents

Problem

When users initialized a project with one agent and later wanted to add another agent, running specify init again would overwrite the .specify/ directory

Solution

Implement smart detection that automatically detects existing .specify/ directory and preserves user's work by default.

How It Works

  1. Detects if .specify/ directory exists with content
  2. Preserves constitution, specs, and plans automatically
  3. Adds only the new agent-specific directory
  4. Requires --force flag to explicitly overwrite

User Experience

specify init . --ai claude
Work on project...
specify init . --ai copilot
✅ Automatically preserves .specify/, adds .github/ directory
Shows: "Existing project detected - preserving your work"

Key Features

✅ Safe by default - Automatically preserves existing work
✅ Intuitive - Users do what feels natural (just run init again)
✅ Clear feedback - Shows what's being preserved or overwritten
✅ Explicit override - Use --force to reinitialize
✅ Backward compatible - Existing single-agent workflow unchanged

Implementation Details

Code Changes (~100 lines)

Added:

  • preserve_specify parameter to download_and_extract_template() function
  • Logic to skip .specify/ directory during extraction when preserve_specify=True
  • Smart detection in init() function to detect existing .specify/ with content
  • Clear user feedback panels for both scenarios
  • Updated --force flag description

Files Modified:

  • src/specify_cli/init.py (~100 lines added/modified)
  • README.md (updated with examples)

Breaking Changes

None. This is a purely additive feature that improves existing behavior.

AI Assistance

This implementation was developed with assistance from Claude Code, which was utilized for both the technical implementation and the creation of this pull request description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant