Skip to content

Conversation

harikrishnan83
Copy link

@harikrishnan83 harikrishnan83 commented Oct 3, 2025

Summary

This PR introduces a new /cross-feature command that enables systems thinking analysis across features in Spec Kit. The command helps identify conflicts, dependencies, and emergent behaviors when adding new features to a project.

Comparison between /analyze and /cross-feature.

image

Or as a metaphor, /analyze is vertical alignment; /cross-feature is horizontal alignment.

Here is a detailed writeup.

This is both a proposal / idea for a command as well as PR with initial Proof of Concept that I have tested. Happy to hear your feedback and work on improvements / recommendations.

Changes included:

  • Add /cross-feature command template with systems thinking framework
  • Create bash and PowerShell scripts for cross-feature analysis
  • Add cross-feature-analysis-template.md for structured alignment analysis
  • Update README.md to document the new command in workflow
  • Update /specify command to suggest /cross-feature as optional next step
  • Add settings.local.json to .gitignore

Key features:

  • Analyzes current feature spec against all existing feature specs
  • Identifies real conflicts, dependencies, and side effects
  • Adds clarification markers to spec.md for /clarify to pick up
  • Generates concise, actionable alignment analysis (50-100 lines)
  • Optional step between /specify and /plan

Test plan

  • Tested /cross-feature command with sample feature specifications
  • Verified bash script works on macOS
  • Verified PowerShell script syntax
  • Confirmed analysis file generation using template
  • Verified clarification line injection into spec.md
  • Tested integration with existing /specify and /clarify workflow
  • Updated documentation in README.md
  • Manual testing by maintainers recommended on various feature scenarios

AI Assistance Disclosure

This PR was developed with significant AI assistance (Claude Code). The implementation was guided by systems thinking principles and iteratively tested to ensure alignment with Spec Kit's workflow philosophy. All code has been reviewed and tested by the human contributor.

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

harikrishnan83 and others added 4 commits October 2, 2025 12:15
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Renamed the /align command to /cross-feature to better express that this
command performs cross-feature alignment analysis using systems thinking.
The new name makes it immediately clear that the analysis examines
interactions between multiple features.

Changes:
- Renamed templates/commands/align.md → cross-feature.md
- Renamed templates/alignment-analysis-template.md → cross-feature-analysis-template.md
- Renamed scripts/bash/alignment-check-all-features.sh → cross-feature-check-all-features.sh
- Renamed scripts/powershell/alignment-check-all-features.ps1 → cross-feature-check-all-features.ps1
- Updated all internal references to use new naming:
  - Output filename: alignment-analysis.md → cross-feature-analysis.md
  - Template paths in scripts
  - Command references in documentation
  - Clarification line text in scripts
- Updated README.md command table
- Updated templates/commands/specify.md to suggest /cross-feature

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
* main:
  docs(readme): link Amazon Q slash command limitation issue
  docs: clarify Amazon Q limitation and update init docstring
  feat(agent): Added Amazon Q Developer CLI Integration
@Copilot Copilot AI review requested due to automatic review settings October 3, 2025 07:01
Copy link
Contributor

@Copilot 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 introduces a new /cross-feature command that enables systems thinking analysis to identify conflicts, dependencies, and emergent behaviors when adding new features to a project.

  • Adds /cross-feature command with systems thinking framework for cross-feature analysis
  • Creates platform-specific scripts (bash/PowerShell) to analyze current feature against all existing specs
  • Integrates with existing workflow between /specify and /plan commands

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
templates/cross-feature-analysis-template.md Template for structured alignment analysis output
templates/commands/cross-feature.md Command definition for cross-feature analysis workflow
scripts/bash/cross-feature-check-all-features.sh Bash script implementation for feature comparison
scripts/powershell/cross-feature-check-all-features.ps1 PowerShell script implementation for feature comparison
templates/commands/specify.md Updated to suggest cross-feature analysis as optional next step
README.md Documentation update adding new command to workflow table

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

harikrishnan83 and others added 2 commits October 3, 2025 16:35
…cation

- Fix bash script sed portability for macOS/BSD vs GNU/Linux platforms
- Extract clarification message to template to eliminate duplication
- Update both bash and PowerShell scripts to read clarification from template
- Add fallback to hardcoded message if template extraction fails

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Added /cross-feature command to the Enhancement Commands panel shown after `specify init`
- Positioned after /clarify and before /analyze in the workflow
- Includes timing guidance: "run after /specify, before /plan"
- Described as "Systems thinking alignment analysis to identify cross-feature conflicts"
- Improves discoverability of the cross-feature command for new users

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings October 3, 2025 12:37
Copy link
Contributor

@Copilot 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

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

COMMAND_TEMPLATE="$REPO_ROOT/templates/commands/cross-feature.md"
if [ -f "$COMMAND_TEMPLATE" ]; then
# Extract the clarification message from the template (it's in backticks on line with "Add:")
CLARIFICATION_LINE=$(grep -A 1 "Add:" "$COMMAND_TEMPLATE" | grep "NEEDS CLARIFICATION" | sed 's/.*`\(.*\)`.*/\1/')
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

The regex pattern expects backticks around the clarification line, but the template uses regular quotes. This will cause the extraction to fail and fall back to the hardcoded string.

Suggested change
CLARIFICATION_LINE=$(grep -A 1 "Add:" "$COMMAND_TEMPLATE" | grep "NEEDS CLARIFICATION" | sed 's/.*`\(.*\)`.*/\1/')
CLARIFICATION_LINE=$(grep -A 1 "Add:" "$COMMAND_TEMPLATE" | grep "NEEDS CLARIFICATION" | sed 's/.*["'\'']\(.*NEEDS CLARIFICATION.*\)["'\''].*/\1/')

Copilot uses AI. Check for mistakes.

if (Test-Path $CommandTemplate) {
# Extract the clarification message from the template (it's in backticks on line with "Add:")
$TemplateContent = Get-Content $CommandTemplate -Raw
if ($TemplateContent -match 'Add: `([^`]+)`') {
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

The regex pattern expects backticks around the clarification line, but the template uses regular quotes. This will cause the extraction to fail and fall back to the hardcoded string.

Suggested change
if ($TemplateContent -match 'Add: `([^`]+)`') {
if ($TemplateContent -match 'Add: "([^"]+)"') {

Copilot uses AI. Check for mistakes.

Comment on lines 109 to 110
$CLARIFICATION_LINE
" "$CURRENT_SPEC"
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

The sed command syntax for appending text on macOS is incorrect. The backslash-newline continuation should be followed by the text on the same line, not on separate lines.

Suggested change
$CLARIFICATION_LINE
" "$CURRENT_SPEC"
$CLARIFICATION_LINE" "$CURRENT_SPEC"

Copilot uses AI. Check for mistakes.

Comment on lines 112 to 113
sed -i "/### Functional Requirements/a\\
$CLARIFICATION_LINE" "$CURRENT_SPEC"
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

The sed command syntax for appending text on Linux is incorrect. The backslash should be immediately followed by the text without a newline.

Copilot uses AI. Check for mistakes.

harikrishnan83 and others added 2 commits October 3, 2025 21:50
Remove settings.local.json from .gitignore as it's not related to the
/cross-feature command feature.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…lity

- Update regex patterns to handle both quotes and backticks in template extraction
- Improve sed portability by detecting GNU vs BSD sed at runtime
- Add documentation comments noting template as source of truth for clarification message
- Fix sed append syntax for both macOS (BSD) and Linux (GNU)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings October 3, 2025 17:01
Copy link
Contributor

@Copilot 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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

COMMAND_TEMPLATE="$REPO_ROOT/templates/commands/cross-feature.md"
if [ -f "$COMMAND_TEMPLATE" ]; then
# Extract the clarification message from the template (handles both quotes and backticks)
CLARIFICATION_LINE=$(grep -A 1 "Add:" "$COMMAND_TEMPLATE" | grep "NEEDS CLARIFICATION" | sed 's/.*["'\''`]\(.*NEEDS CLARIFICATION.*\)["'\''`].*/\1/')
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

The complex regex pattern with multiple quote types makes this line difficult to read and maintain. Consider breaking this into multiple steps or using a more straightforward extraction approach.

Suggested change
CLARIFICATION_LINE=$(grep -A 1 "Add:" "$COMMAND_TEMPLATE" | grep "NEEDS CLARIFICATION" | sed 's/.*["'\''`]\(.*NEEDS CLARIFICATION.*\)["'\''`].*/\1/')
CLARIFICATION_RAW=$(grep -A 1 "Add:" "$COMMAND_TEMPLATE" | grep "NEEDS CLARIFICATION")
# Remove leading/trailing quotes or backticks if present
CLARIFICATION_LINE=$(echo "$CLARIFICATION_RAW" | sed 's/^[[:space:]]*["'\''`]\{0,1\}//; s/["'\''`]\{0,1\}[[:space:]]*$//')

Copilot uses AI. Check for mistakes.


# Build output
if ($JsonMode) {
$AllSpecsJson = $AllSpecs | ForEach-Object { "`"$_`"" } | Join-String -Separator ","
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

The variable $AllSpecsJson is created but never used in the JSON output. The actual JSON uses $AllSpecs directly, making this line redundant.

Suggested change
$AllSpecsJson = $AllSpecs | ForEach-Object { "`"$_`"" } | Join-String -Separator ","

Copilot uses AI. Check for mistakes.

Comment on lines +103 to +110
if sed --version >/dev/null 2>&1; then
# GNU sed
sed -i "/### Functional Requirements/a\\$CLARIFICATION_LINE" "$CURRENT_SPEC"
else
# BSD/macOS sed
sed -i.bak "/### Functional Requirements/a\\
$CLARIFICATION_LINE" "$CURRENT_SPEC" && rm -f "$CURRENT_SPEC.bak"
fi
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

The multi-line sed command with line continuation is fragile and platform-dependent. Consider using a more portable approach like awk or a temporary file for better reliability across different Unix systems.

Suggested change
if sed --version >/dev/null 2>&1; then
# GNU sed
sed -i "/### Functional Requirements/a\\$CLARIFICATION_LINE" "$CURRENT_SPEC"
else
# BSD/macOS sed
sed -i.bak "/### Functional Requirements/a\\
$CLARIFICATION_LINE" "$CURRENT_SPEC" && rm -f "$CURRENT_SPEC.bak"
fi
# Use awk to insert the clarification line after "### Functional Requirements" in a portable way
awk -v line="$CLARIFICATION_LINE" '
$0 ~ /### Functional Requirements/ { print; print line; next }
{ print }
' "$CURRENT_SPEC" > "$CURRENT_SPEC.tmp" && mv "$CURRENT_SPEC.tmp" "$CURRENT_SPEC"

Copilot uses AI. Check for mistakes.

7. Add a single clarification line to the current spec.md file in the Requirements section:
- Add: `- [NEEDS CLARIFICATION: Review cross-feature alignment analysis in cross-feature-analysis.md - potential conflicts identified that may require spec adjustments]`
- This ensures `/clarify` will pick up alignment issues naturally
- **Note:** Scripts should extract this clarification text programmatically from this template to avoid duplication
Copy link

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

The instruction to extract clarification text programmatically from this template creates a tight coupling between the template and scripts. Consider defining this text in a shared configuration file or constant to reduce maintenance overhead.

Suggested change
- **Note:** Scripts should extract this clarification text programmatically from this template to avoid duplication
- **Note:** The clarification text is defined in a shared configuration file or constant for scripts to use, reducing maintenance overhead.

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