Skip to content

Conversation

@nShieldSolo
Copy link

Summary

Added --keep-memory flag to specify init command that preserves memory/constitution.md when switching between AI agents on an existing project.

Problem

When users switch AI assistants (e.g., from Claude to Gemini) using specify init . --ai gemini, the existing memory/constitution.md file (which may contain customized project-specific constitution) gets overwritten with the template version.

Solution

Added --keep-memory flag that skips overwriting memory/constitution.md if it already exists:

specify init . --ai gemini --keep-memory

Copilot AI review requested due to automatic review settings January 16, 2026 03:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a --keep-memory flag to the specify init command to address the known issue where switching AI agents overwrites customized memory/constitution.md files. The flag allows users to preserve their existing constitution when re-initializing a project with a different AI assistant.

Changes:

  • Added --keep-memory flag parameter to the init command
  • Modified download_and_extract_template function to accept a preserve_constitution parameter
  • Implemented logic to skip overwriting constitution.md when the flag is active and the file exists
  • Updated version from 0.0.22 to 0.0.23 and documented the change in CHANGELOG.md

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/specify_cli/init.py Added --keep-memory flag to init command, added preserve_constitution parameter to download_and_extract_template, and implemented constitution preservation logic
pyproject.toml Bumped version from 0.0.22 to 0.0.23
CHANGELOG.md Added changelog entry for version 0.0.23 documenting the new --keep-memory flag

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +831 to +832
# Skip constitution.md if preserve_constitution is True and file exists
if preserve_constitution and dest_file.exists() and rel_path == Path("constitution.md") and item.name == "memory":
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constitution preservation logic is incorrect. When iterating through the extracted template, item represents the .specify directory (not memory), and rel_path would be memory/constitution.md (not just constitution.md). The condition item.name == "memory" will never be true, so the --keep-memory flag won't work. The correct check should be item.name == ".specify" and rel_path == Path("memory/constitution.md") or rel_path == Path("memory") / "constitution.md".

Suggested change
# Skip constitution.md if preserve_constitution is True and file exists
if preserve_constitution and dest_file.exists() and rel_path == Path("constitution.md") and item.name == "memory":
# Skip memory/constitution.md if preserve_constitution is True and file exists
if preserve_constitution and dest_file.exists() and rel_path == Path("memory") / "constitution.md":

Copilot uses AI. Check for mistakes.
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