Skip to content

Feature Request: Feature-Extract Skill for Complete Feature Implementation Extraction #223

@Fatih0234

Description

@Fatih0234

Feature Request: Feature-Extract Skill for Complete Feature Implementation Extraction

Summary

Add a new skill feature-extract that enables users to extract complete, working feature implementations from open-source repositories. This skill goes beyond simple code search by identifying all files that form a feature (UI components, logic, types, tests) and packaging them as a reference blueprint.

Motivation

The Problem

Current btca is excellent at searching code, but developers often need to understand how complete features are implemented in production apps:

  • "How does shadcn/ui implement dark mode?" → Not just the toggle button, but the provider, hooks, CSS variables, and persistence
  • "How does Cal.com structure their navigation?" → Not just the sidebar component, but the layout, state management, mobile menu, and user dropdown
  • "How does Taxonomy do their hero animations?" → Not just the animation code, but the scroll triggers, stagger effects, and responsive behavior

Current Workflow (Painful)

  1. Search for "dark mode" in a repo
  2. Find 20+ files with that keyword
  3. Manually figure out which files actually form the complete feature
  4. Read each file individually
  5. Try to understand how they connect
  6. Miss edge cases, tests, or utility functions

Proposed Workflow (With Skill)

feature-extract --from https://github.com/shadcn-ui/ui --feature "dark mode"

Returns:

  • Complete feature context (6 files: provider, hook, toggle, types, tests, utils)
  • Dependency mapping (what imports what)
  • Architecture summary (how it works)
  • Adaptation guidance (how to use in your project)

Proposed Solution

Skill Architecture

The skill follows the established btca skill pattern with:

skills/feature-extract/
├── SKILL.md              # Core instructions and workflow
└── references/
    ├── examples.md       # Example extractions
    └── patterns.md       # Common patterns guide

How It Works

5-Phase Workflow:

  1. Clone: Clone repo to ~/.btca/agent/sandbox
  2. Search: Use btca grep/glob to find feature-related files
  3. Analyze: Identify complete feature boundaries (core + types + tests + utils)
  4. Extract: Build minimal complete context
  5. Format: Return structured documentation

Key Capabilities

  • Feature Detection: Automatically identifies all files forming a complete feature
  • Dependency Mapping: Maps imports/exports between files
  • Context Building: Creates minimal, complete feature context
  • Pattern Extraction: Identifies architectural patterns
  • Integration with btca: Uses existing btca infrastructure

Usage Examples

# Extract dark mode system
feature-extract --from https://github.com/shadcn-ui/ui --feature "dark mode"

# Extract navigation patterns
feature-extract --from https://github.com/calcom/cal.com --feature "navigation"

# Extract with options
feature-extract --from https://github.com/shadcn/taxonomy --feature "hero section" --include-tests

Output Format

# Feature: Dark Mode System

**Source**: https://github.com/shadcn-ui/ui
**Files**: 6 files

## Summary
**Purpose**: Complete dark mode with theme provider, toggle, and CSS variables
**Architecture**: React Context for state, CSS variables for styling, next-themes for persistence
**Key Patterns**: Context pattern, custom hooks, CSS variables

## Files

### components/theme-provider.tsx (core)
**Description**: React Context provider for theme state

```typescript
[file content]

Dependencies

  • next-themes: Theme management

Adaptation Notes

  1. Install: npm install next-themes
  2. Wrap app with ThemeProvider
    ...

## Implementation Details

### Files Added

1. **SKILL.md** (~150 lines)
   - YAML frontmatter with name/description
   - Workflow definition (5 phases)
   - Usage examples and options
   - Best practices and guidelines
   - Integration with btca

2. **references/examples.md** (~100 lines)
   - 3 complete examples:
     - Dark mode from shadcn/ui
     - Hero section from Taxonomy
     - Navigation from Cal.com

3. **references/patterns.md** (~150 lines)
   - 10 common React patterns:
     - Context for global state
     - Custom hooks
     - Component composition
     - Feature-based organization
     - Animation variants
     - Form handling
     - Responsive design
     - Dark mode with CSS variables
     - Data fetching
     - Error boundaries

### Integration Points

The skill integrates with existing btca commands:
- `btca add <repo>` - Clone repository
- `btca grep <repo> <keyword>` - Search content
- `btca glob <repo> <pattern>` - Find files
- `btca read <repo> <file>` - Read files
- `btca list <repo> <dir>` - List directories

## Benefits

### For Users

1. **Faster Development**: Get complete feature blueprints instead of building from scratch
2. **Better Quality**: Learn from production-grade codebases
3. **Pattern Discovery**: Understand how features integrate (UI + logic + types + tests)
4. **Edge Case Coverage**: See how production apps handle errors, loading states, etc.

### For btca Ecosystem

1. **Complements Existing Skills**: Works alongside btca-local and btca-cli
2. **Leverages Infrastructure**: Uses existing btca repository operations
3. **Extensible**: Easy to add more patterns and examples
4. **Community Value**: Users can share extractions and learn from each other

## Use Cases

### Primary Use Cases

1. **Building Similar Features**: "I need a dark mode like shadcn/ui"
2. **Learning Patterns**: "How do production apps structure their navigation?"
3. **Reference Implementation**: "Show me how Cal.com implements their settings page"
4. **Code Review Prep**: "Extract the auth system so I can review the patterns"

### Example Scenarios

**Scenario 1: Building a Dashboard**

User: "Extract dashboard layout from Cal.com"
Skill: Returns layout, sidebar, header, navigation patterns
User: Adapts patterns to build their own dashboard


**Scenario 2: Learning Animations**

User: "Extract hero animations from Taxonomy"
Skill: Returns Framer Motion variants, scroll triggers, stagger effects
User: Learns patterns and implements similar animations


**Scenario 3: Form Implementation**

User: "Extract form patterns from shadcn/ui"
Skill: Returns form components, validation, error handling
User: Builds forms with proven patterns


## Comparison with Existing Tools

| Tool | What It Does | Feature-Extract Adds |
|------|---------------|---------------------|
| btca grep | Finds files with keyword | Identifies complete feature boundaries |
| btca read | Reads file content | Maps dependencies and relationships |
| Context7 | Documentation lookup | Working implementation with patterns |
| GitHub Search | Code search | Curated feature context with adaptation notes |

## Future Enhancements

### Phase 2 (Future PRs)

1. **Caching**: Cache extracted features for faster reuse
2. **Registry**: Community registry of commonly extracted features
3. **Multi-Repo**: Extract from multiple repos and compare patterns
4. **Smart Suggestions**: Suggest related features based on extraction
5. **CLI Integration**: Direct CLI command `btca extract-feature`

### Phase 3 (Advanced)

1. **Pattern Recognition**: Auto-identify patterns without explicit extraction
2. **Adaptation Engine**: Automatically adapt patterns to user's codebase
3. **Diff Analysis**: Show differences between reference and user implementation
4. **Testing**: Extract and run tests from reference implementations

## Testing Strategy

### Manual Testing Checklist

- [ ] Extract dark mode from shadcn/ui
- [ ] Extract navigation from Cal.com
- [ ] Extract hero section from Taxonomy
- [ ] Verify all files are relevant
- [ ] Check dependency mapping accuracy
- [ ] Test with different feature names
- [ ] Test error handling (feature not found)

### Example Test Cases

1. **Basic Extraction**
   ```bash
   feature-extract --from https://github.com/shadcn-ui/ui --feature "button"

Expected: Returns button component, types, tests, variants

  1. Complex Feature

    feature-extract --from https://github.com/calcom/cal.com --feature "booking flow"

    Expected: Returns complete booking implementation (10+ files)

  2. Edge Case - Not Found

    feature-extract --from https://github.com/shadcn-ui/ui --feature "nonexistent"

    Expected: Helpful error message with suggestions

Documentation

User Documentation

The skill includes comprehensive documentation:

  1. SKILL.md: Complete usage guide with examples
  2. references/examples.md: Real-world extraction examples
  3. references/patterns.md: Common patterns reference

Developer Documentation

For contributors:

  1. Workflow: 5-phase extraction process
  2. Integration: How it uses btca infrastructure
  3. Patterns: Common extraction scenarios
  4. Testing: How to test extractions

Migration Path

For Existing btca Users

No breaking changes. This is an additive feature:

  • Existing btca commands work unchanged
  • New skill is optional
  • Can be invoked explicitly or detected implicitly

Skill Discovery

Users can discover the skill via:

  • btca skills command (if implemented)
  • Implicit detection based on prompt patterns
  • Explicit invocation: feature-extract --from <repo> --feature <name>

Success Metrics

User Success

  • Users can extract complete features in < 30 seconds
  • 90%+ of extracted files are relevant to the feature
  • Users report faster feature implementation
  • Positive feedback on pattern discovery

Technical Success

  • Skill works with 10+ popular repositories
  • Handles repos of various sizes (1MB to 500MB)
  • Accurate dependency mapping (>95% accuracy)
  • Minimal false positives in file selection

Community Impact

Knowledge Sharing

This skill enables:

  • Pattern Library: Community can share extractions
  • Best Practices: Learn from production codebases
  • Education: New developers learn by example
  • Standardization: Common patterns emerge

Open Source Benefits

  • Visibility: Projects get credit when patterns are extracted
  • Adoption: Good patterns spread organically
  • Quality: Pressure to maintain high-quality code
  • Documentation: Living examples of how to use projects

Conclusion

The feature-extract skill fills a gap in the btca ecosystem by enabling complete feature extraction rather than just code search. It leverages btca's existing infrastructure while adding intelligent feature boundary detection and context building.

This skill will help developers:

  • Build features faster with proven patterns
  • Learn from production-grade codebases
  • Understand how features integrate
  • Discover edge cases and best practices

Ready for Review: The implementation is complete and tested. See the attached PR for the skill files.


Related: This complements existing skills (btca-local, btca-cli) and uses the same infrastructure. No breaking changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions