Skip to content
move-a-file logo

Move a File

move-a-file

Move or rename a file while automatically updating all references in source code and documentation

mattnigh/skills_collection0installs24stars

SKILL.md

Full skill instructions

Move a File

This skill instructs AI agents on how to safely move or rename files in a codebase while automatically finding and updating all references to the file in source code, documentation, and configuration files.

Inputs

The move-a-file skill takes the following inputs:

  • Old file path: The current path of the file to move/​rename (relative to project root)
  • New file path: The destination path for the file (relative to project root)
  • Context: Any additional context about what the file contains or why it's being moved

Workflow for AI Agents

When this skill is invoked, the AI agent MUST follow these steps in order:

1. Validate File Paths

Before proceeding, verify that:

  • The old file path exists
  • The new file path's parent directory exists (or can be created)
  • The new file path does not already exist (to avoid overwrites)
  • Both paths are relative to the project root

If any validation fails, inform the user and abort.

2. Search for All References

Use rg (ripgrep) or grep to find all references to the file across the codebase.

IMPORTANT: Search for multiple patterns to catch all references:

  1. Exact filename: Search for the exact filename (without path)

    rg --type-add 'docs:*.md' --type-add 'config:*.{yaml,yml,json,toml}' \
       -t md -t config -t py -t js -t sh -t c -t cpp \
       "<filename>"
    
  2. Full relative path: Search for the full path from project root

    rg --type-add 'docs:*.md' --type-add 'config:*.{yaml,yml,json,toml}' \
       -t md -t config -t py -t js -t sh -t c -t cpp \
       "<old-path>"
    
  3. Path variations: Search for common path variations

    • With leading ./: "./<old-path>"
    • Without extension (if applicable): "<path-without-ext>"
    • In import statements: "import.*<filename-without-ext>"

Search scope: Include at minimum:

  • Source code files (.py, .js, .sh, .c, .cpp, etc.)
  • Documentation files (.md, .txt, .rst)
  • Configuration files (.yaml, .yml, .json, .toml)
  • Build files (Makefile, CMakeLists.txt, package.json)

3. Review and Update References

For each file containing a reference:

  • Read the file to understand the context
  • Determine the correct new path to use (may be relative to that file's location)
  • Update the reference using the Edit tool
  • Report what was changed in that file

Path calculation rules:

  • For documentation and config files: usually use paths relative to project root
  • For import statements: follow the language's import conventions
  • For file system operations: may need relative paths from the current file

4. Move the File

After updating all references, move the file:

git mv "<old-path>" "<new-path>"

If the parent directory of the new path doesn't exist:

mkdir -p "$(dirname '<new-path>')" && git mv "<old-path>" "<new-path>"

5. Verify and Report

After moving the file:

  1. Verify the new file exists: ls "<new-path>"
  2. Report summary to the user:
    • Old path → New path
    • Number of files updated
    • List of updated files with brief description of changes
    • Any references that might need manual review

Examples

Example 1: Renaming a Skill File

Context: User wants to rename git-commit/​SKILL.md to commit-msg/​SKILL.md

Workflow:

User: Use move-a-file to rename the git-commit skill to commit-msg

Agent: I'll move the file and update all references.

1. Validating paths...
   - Source exists: claude/​skills/​git-commit/​SKILL.md ✓
   - Destination available: claude/​skills/​commit-msg/​SKILL.md ✓

2. Searching for references to "git-commit"...
   Found references in:
   - claude/​skills/​CLAUDE.md (2 references)
   - claude/​commands/​README.md (1 reference)
   - README.md (1 reference)

3. Updating references...
   - claude/​skills/​CLAUDE.md:79 - Updated skill name reference
   - claude/​skills/​CLAUDE.md:123 - Updated example path
   - claude/​commands/​README.md:45 - Updated skill link
   - README.md:67 - Updated workflow reference

4. Moving the file...
   [Runs: mkdir -p claude/​skills/​commit-msg && git mv claude/​skills/​git-commit/​SKILL.md claude/​skills/​commit-msg/​SKILL.md]

5. Summary:
   Moved: claude/​skills/​git-commit/​SKILL.md → claude/​skills/​commit-msg/​SKILL.md
   Updated 4 references across 3 files

Example 2: Moving Documentation File

Context: User wants to reorganize docs by moving a file

Workflow:

User: Move docs/​workflow.md to docs/​agent/​workflow.md

Agent: I'll move the file and update all references.

1. Validating paths...
   - Source exists: docs/​workflow.md ✓
   - Creating parent directory: docs/​agent/ ✓

2. Searching for references...
   Found references in:
   - README.md (3 references)
   - docs/​index.md (1 reference)
   - claude/​skills/​plan-guideline/​SKILL.md (1 reference)

3. Updating references...
   - README.md:23 - Updated link: [workflow](docs/​workflow.md) → [workflow](docs/​agent/​workflow.md)
   - README.md:45 - Updated link in list
   - README.md:89 - Updated reference in text
   - docs/​index.md:12 - Updated link
   - claude/​skills/​plan-guideline/​SKILL.md:234 - Updated documentation reference

4. Moving the file...
   [Runs: mkdir -p docs/​agent && git mv docs/​workflow.md docs/​agent/​workflow.md]

5. Summary:
   Moved: docs/​workflow.md → docs/​agent/​workflow.md
   Updated 5 references across 3 files

Example 3: No References Found

Context: Moving a new file that hasn't been referenced yet

Workflow:

User: Move temp/​draft.md to docs/​draft/​implementation.md

Agent: I'll move the file and check for references.

1. Validating paths...
   - Source exists: temp/​draft.md ✓
   - Creating parent directory: docs/​draft/ ✓

2. Searching for references...
   No references found to "draft.md" or "temp/​draft.md"

3. Moving the file...
   [Runs: mkdir -p docs/​draft && git mv temp/​draft.md docs/​draft/​implementation.md]

4. Summary:
   Moved: temp/​draft.md → docs/​draft/​implementation.md
   No references needed updating

Important Notes

  1. Always use git mv: This preserves file history in git. Never use regular mv command.

  2. Case sensitivity: File systems may be case-insensitive, but git is case-sensitive. Be careful when changing only the case of a filename.

  3. Search thoroughly: Different files may reference the moved file in different ways. Use multiple search patterns to catch all variations.

  4. Path relativity: When updating references, consider whether the reference should be:

    • Relative to project root
    • Relative to the file containing the reference
    • An absolute path
  5. Import statements: Programming language imports may need special handling:

    • Python: from module.submodule import file
    • JavaScript: import { func } from './​path/​to/​file'
    • Shell: source ./​path/​to/​file.sh
  6. Glob patterns: Also search for glob patterns that might match the file:

    • docs/​**/​*.md might be used to reference all markdown files
    • These might need updating if the file moves to a different directory structure
  7. Report uncertainty: If you find a reference that you're unsure how to update, include it in the final report and ask the user to review it manually.

  8. Don't move directories: This skill is for moving individual files only. For moving entire directories, the process is more complex and should be handled separately.

More skills from mattnigh

spring-framework-patterns logo
mattnigh/skills_collection

spring-framework-patterns

Comprehensive Spring Framework and Spring Boot best practices including dependency injection patterns, bean lifecycle and scopes, REST API development, Spring Data JPA, service layer design, Spring Security, testing strategies, caching, AOP, async processing, error handling, and common anti-patte...

24 0
View

TypeScript厳格モードによる型安全性設計を専門とするスキル。 📖 参照書籍: - 『Effective TypeScript』(Dan Vanderkam): 型設計 📚 リソース参照: - `resources/Level1_basics.md`: レベル1の基礎ガイド - `resources/Level2_intermediate.md`: レベル2の実務ガイド - `resources/Level3_advanced.md`: レベル3の応用ガイド - `resources/Level4_expert.md`: レベル4の専門ガイド - `resources/di...

24 0
View
deploying-cloud-k8s logo
mattnigh/skills_collection

deploying-cloud-k8s

Deploys applications to cloud Kubernetes (AKS/GKE/DOKS) with CI/CD pipelines. Use when deploying to production, setting up GitHub Actions, troubleshooting deployments. Covers build-time vs runtime vars, architecture matching, and battle-tested debugging.

24 0
View
moai-alfred-agent-guide logo
mattnigh/skills_collection

moai-alfred-agent-guide

19-agent team structure, decision trees for agent selection, Haiku vs Sonnet model selection, and agent collaboration principles. Use when deciding which sub-agent to invoke, understanding team responsibilities, or learning multi-agent orchestration.

24 0
View
mermaid-diagram-generator logo
mattnigh/skills_collection

mermaid-diagram-generator

Converts architecture descriptions, module specs, or workflow docs into Mermaid diagrams. Use when visualizing brick module relationships, workflows (DDD, investigation), or system architecture. Supports: flowcharts, sequence diagrams, class diagrams, state machines, entity relationship diagrams,...

24 0
View
pre-flight-check logo
mattnigh/skills_collection

pre-flight-check

INVOKE FIRST before any code work. Validates git workflow (branch, issue, worklog) and checks approach. Use at START of every task and END before completing. Prevents skipped steps.

24 0
View
browser-dev-tools logo
mattnigh/skills_collection

browser-dev-tools

This skill should be used when working with browser-rendered artifacts (i.e. Bun, React/React Native) to proactively validate that development work on localhost is being built appropriately and to support debugging browser-rendered content. Use this skill after making frontend changes to verify t...

24 0
View
lead-dev logo
mattnigh/skills_collection

lead-dev

Lead Développeur - Coordination technique opérationnelle, code review, mentoring et livraison. Pair de web-dev-process au niveau OPÉRATIONS.

24 0
View
worker-monitor logo
mattnigh/skills_collection

worker-monitor

Monitor Docker workers, RQ queue health, and auto-scale workers (max 4). Use when: checking job progress, monitoring queue depth, scaling workers up/down, diagnosing slow processing, or waiting for jobs to complete. Referenced by data-quality skill during reprocessing.

24 0
View
quality-advisor logo
mattnigh/skills_collection

quality-advisor

Proactive quality guidance system that monitors artifact creation and provides real-time feedback on documentation quality

24 0
View
bump-version logo
mattnigh/skills_collection

bump-version

This skill should be used when the user wants to bump the version number in the workspace. It updates versions across all pyproject.toml files (root, tde, and tda packages) and the CHANGELOG.md to keep them synchronized.

24 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View