Perform find-and-replace operations across multiple files using the sd CLI tool. The tool simplifies text replacement with regex support and safer defaults than traditional sed.
下載技能 ZIP
在 Claude 中上傳
前往 設定 → 功能 → 技能 → 上傳技能
開啟並開始使用
測試它
正在使用「find-replace」。 Replace 'console.log' with 'logger.info' in my JavaScript files
預期結果:
- Previewing replacements in src/**/*.js...
- Found 12 occurrences across 5 files
- Files affected: src/utils.js, src/handlers.js, src/main.js, src/config.js, src/api.js
- Apply with: sd 'console\.log\((.*)\)' 'logger.info($1)' src/**/*.js
正在使用「find-replace」。 Rename 'getUser' to 'fetchUser' in all TypeScript files
預期結果:
- Searching for 'getUser' with word boundaries...
- Found 23 occurrences across 8 files
- Use '\bgetUser\b' pattern to match whole words only
- Apply: sd '\bgetUser\b' 'fetchUser' src/**/*.ts
正在使用「find-replace」。 Update all API v1 endpoints to v2
預期結果:
- Found 15 occurrences of '/api/v1/' in 6 files
- Files: src/api.ts, src/routes.ts, src/endpoints.js, and 3 more
- Apply: sd '/api/v1/' '/api/v2/' src/**/*.ts
安全審計
安全Pure documentation skill containing only markdown files with examples for the sd CLI tool. No executable code, file access, network access, or command execution capabilities. All static findings are false positives triggered by bash examples in documentation context.
風險因素
⚙️ 外部命令 (110)
🔑 環境變數 (1)
🌐 網路存取 (1)
📁 檔案系統存取 (2)
品質評分
你能建構什麼
Rename variables across codebase
Rename functions, variables, or constants across many TypeScript or JavaScript files with precise matching
Update configuration strings
Update API endpoints, environment variable names, or configuration values across project files
Modernize legacy code patterns
Replace deprecated APIs, convert CommonJS to ES modules, or update import paths systematically
試試這些提示
Replace all occurrences of 'oldFunction' with 'newFunction' in my src directory using sd
Use sd to replace console.log statements with logger.info in my JavaScript files, preserving the logged content
Change all '../utils' imports to '@/utils' in my TypeScript files using sd capture groups
Preview what would change if I replaced 'api.example.com' with 'api.new.com' across my project, then apply safely
最佳實務
- Preview changes with ripgrep before applying bulk replacements
- Use word boundaries '\b' to avoid partial matches
- Commit to git before running batch replacements for easy rollback
避免
- Running replacements without previewing first
- Using patterns without escaping special regex characters
- Applying changes directly to production without version control