Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Cross-Repo Smart CopyNew to Visual Studio Code? Get it now.
Cross-Repo Smart Copy

Cross-Repo Smart Copy

Eshant Sahu

|
5 installs
| (0) | Free
Intelligent code copying with full context: file paths, line numbers, git info, and code structure. Perfect for multi-repo workflows and AI assistants.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

🔗 Cross-Repo Smart Copy

The intelligent way to copy code with full context across repositories

Version License: MIT VS Code Cursor

Cross-Repo Smart Copy is a powerful extension for Cursor and VS Code that transforms the way you copy and share code. Instead of copying just the code snippet, it automatically captures complete context: file paths, line numbers, git information, code structure, and more—making it perfect for multi-repository workflows, microservices, and AI-powered development.


✨ Why Smart Copy?

Working across multiple repositories? Sharing code with team members or AI assistants? Regular copy-paste loses context. Smart Copy ensures you never lose important details:

  • 📍 File location - Know exactly where the code lives
  • 🔢 Line numbers - Reference specific lines easily
  • 🌿 Git context - Branch, commit, and repository info
  • 🏗️ Code structure - Function/class/method names automatically detected
  • 🎨 Multiple formats - Markdown, plain text, or JSON for any use case

Perfect for:

  • 🤖 AI assistants (Cursor Chat, ChatGPT, etc.) - Give them full context
  • 👥 Code reviews - Share snippets with complete reference info
  • 📚 Documentation - Generate docs with automatic source citations
  • 🔄 Cross-repo collaboration - Work seamlessly across microservices
  • 💬 Team communication - Share code snippets with all context intact

🚀 Features

🎯 One-Click Smart Copy

Right-click on selected code → Smart Copy → Paste anywhere with full metadata. It's that simple.

📦 Comprehensive Metadata Capture

Feature Description
📁 File Paths Absolute and relative paths from workspace root
🔢 Line Numbers Start line, end line, and total line count
🌐 Language Detection Automatically identifies programming language
🌿 Git Information Repository name, branch, commit hash, remote URL
🏗️ Code Context Function/class/method names containing the selection
💼 Workspace Current workspace/project name

🎨 Multiple Output Formats

Markdown (Default) - Perfect for chat interfaces and documentation

```
File: src/services/userService.ts:45-62
Repository: my-project | Branch: feature/auth | Commit: a1b2c3d4
Context: UserService.authenticateUser
Workspace: my-workspace
```

```typescript
async authenticateUser(email: string, password: string): Promise<User> {
    const user = await this.userRepository.findByEmail(email);
    if (!user) {
        throw new NotFoundError('User not found');
    }
    return user;
}
```

Plain Text - Human-readable format with clear separators

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SMART COPIED CODE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

File: src/services/userService.ts
Lines: 45-62 (18 lines)
Language: typescript
...

JSON - Structured format for programmatic use

{
  "code": "...",
  "filePath": {...},
  "lineNumbers": {...},
  "git": {...}
}

⚙️ Fully Configurable

Customize every aspect through settings:

  • ✅ Toggle git information on/off
  • ✅ Enable/disable code context detection
  • ✅ Choose output format (markdown/plain/json)
  • ✅ Switch between relative and absolute paths

🛡️ Production Ready

  • ⚡ Fast & Lightweight - No performance impact
  • 🔒 Error Handling - Gracefully handles edge cases
  • 🔄 Git Agnostic - Works even without git repositories
  • 🌍 Cross-Platform - Works on Windows, macOS, and Linux

📥 Installation

From VS Code Marketplace (Coming Soon)

  1. Open VS Code / Cursor
  2. Go to Extensions (Cmd+Shift+X / Ctrl+Shift+X)
  3. Search for "Cross-Repo Smart Copy"
  4. Click Install

Manual Installation

  1. Download the .vsix file from Releases
  2. Open VS Code / Cursor
  3. Go to Extensions → ... → Install from VSIX...
  4. Select the downloaded .vsix file

From Source

# Clone the repository
git clone https://github.com/yourusername/cursor-plugin-smart-copy.git
cd cursor-plugin-smart-copy

# Install dependencies
npm install

# Compile
npm run compile

# Package
npm install -g vsce
vsce package

🎬 Quick Start

  1. Select code in your editor
  2. Right-click → Choose "Smart Copy"
  3. Paste anywhere (Cursor Chat, Slack, docs, etc.)
  4. Enjoy the formatted output with all context!

Keyboard Shortcut (Optional)

Add a custom keyboard shortcut:

  1. Press Cmd+K Cmd+S (Mac) or Ctrl+K Ctrl+S (Windows/Linux)
  2. Search for "Smart Copy"
  3. Click the + icon and set your preferred shortcut (e.g., Cmd+Shift+C)

📖 Usage Examples

Example 1: Sharing with AI Assistant

Before (Regular Copy):

async function getUser() { ... }

After (Smart Copy):

```
File: src/api/users.ts:23-35
Repository: backend-api | Branch: main | Commit: 3f2a1b9
Context: UserController.getUser
Workspace: backend-services
```

```typescript
async getUser(req: Request, res: Response) {
    const user = await userService.findById(req.params.id);
    return res.json(user);
}
```

Example 2: Code Review Comment

Share code snippets in PR reviews with automatic file references and line numbers, making it easy for reviewers to navigate.

Example 3: Documentation Generation

Generate documentation with automatic source citations—no need to manually add file paths and line numbers.


⚙️ Configuration

Open Settings (Cmd+, / Ctrl+,) and search for "crossRepoSmartCopy":

Setting Default Description
crossRepoSmartCopy.includeGitInfo true Include git repository information
crossRepoSmartCopy.includeCodeContext true Include function/class context
crossRepoSmartCopy.format markdown Output format: markdown, plain, or json
crossRepoSmartCopy.showRelativePath true Show relative path from workspace root

JSON Settings Example

{
  "crossRepoSmartCopy.includeGitInfo": true,
  "crossRepoSmartCopy.includeCodeContext": true,
  "crossRepoSmartCopy.format": "markdown",
  "crossRepoSmartCopy.showRelativePath": true
}

🎯 Use Cases

🔄 Multi-Repository Development

Working with microservices or monorepos? Copy code with complete context to share across repositories seamlessly.

👀 Code Reviews

Provide reviewers with complete context including file paths, line numbers, and repository information—no more guessing where code lives.

📝 Documentation

Generate documentation snippets with source file references automatically included. Perfect for API docs, README files, and technical documentation.

🤖 AI/Chat Assistants

Give AI assistants (like Cursor Chat, GitHub Copilot Chat, or ChatGPT) complete context about the code you're discussing. They'll understand the codebase better and provide more accurate assistance.

👥 Cross-Team Collaboration

Share code snippets with team members working in different repositories, ensuring they have all necessary context to understand and integrate the code.

🐛 Bug Reports

Include code snippets in bug reports with automatic file paths and line numbers, making it easy for developers to reproduce issues.


🛠️ Development

Prerequisites

  • Node.js 18+
  • npm or yarn
  • VS Code or Cursor
  • TypeScript

Setup

# Clone repository
git clone https://github.com/yourusername/cursor-plugin-smart-copy.git
cd cursor-plugin-smart-copy

# Install dependencies
npm install

# Compile TypeScript
npm run compile

# Watch mode (auto-compile on changes)
npm run watch

Project Structure

cursor-plugin-smart-copy/
├── src/
│   ├── extension.ts           # Extension entry point
│   ├── smartCopyService.ts    # Main orchestration service
│   ├── gitService.ts          # Git repository info extraction
│   ├── codeContextService.ts  # Code context detection
│   └── formatService.ts       # Output formatting logic
├── out/                       # Compiled JavaScript (generated)
├── package.json               # Extension manifest
├── tsconfig.json             # TypeScript configuration
└── README.md                 # This file

Testing

# Run tests (if available)
npm test

# Test in Extension Development Host
# 1. Press F5 in VS Code
# 2. New window opens with extension loaded
# 3. Test the "Smart Copy" feature

Building for Distribution

# Install vsce globally
npm install -g @vscode/vsce

# Package extension
vsce package

# This creates: cross-repo-smart-copy-0.1.0.vsix

🚢 Deployment

Publishing to VS Code Marketplace

  1. Install vsce (VS Code Extension Manager):

    npm install -g @vscode/vsce
    
  2. Get a Personal Access Token:

    • Go to https://dev.azure.com
    • User Settings → Personal Access Tokens
    • Create token with Marketplace (Manage) scope
  3. Login to Azure DevOps:

    vsce login <your-publisher-name>
    
  4. Package and Publish:

    # Package first
    vsce package
    
    # Publish
    vsce publish
    

Alternative: GitHub Releases

  1. Package the extension:

    vsce package
    
  2. Create a GitHub Release:

    • Go to your repository → Releases → Draft a new release
    • Upload the .vsix file
    • Tag the version (e.g., v0.1.0)
  3. Install from GitHub: Users can download the .vsix and install via "Install from VSIX..."

Pre-Publishing Checklist

  • [ ] Update version in package.json
  • [ ] Update CHANGELOG.md (if you have one)
  • [ ] Test the extension thoroughly
  • [ ] Ensure all dependencies are listed
  • [ ] Verify engines.vscode compatibility
  • [ ] Test installation from .vsix file
  • [ ] Review package.json metadata (description, keywords, etc.)

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Roadmap

  • [ ] Template customization for output format
  • [ ] Security scanning for sensitive data
  • [ ] Dependency detection (auto-include imports)
  • [ ] Copy history with search
  • [ ] Keyboard shortcuts by default
  • [ ] Integration with Git hosting platforms (permalink generation)
  • [ ] Multi-selection support
  • [ ] Export/import configurations

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


🙏 Acknowledgments

  • Built for developers working with complex, multi-repository codebases
  • Inspired by the need for better code sharing and context preservation
  • Special thanks to the VS Code extension community

📞 Support

  • 🐛 Issues: GitHub Issues
  • 💬 Discussions: GitHub Discussions
  • 📧 Email: your-email@example.com

Made with ❤️ for developers who work across repositories

⭐ Star this repo if you find it useful!

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft