gitignore
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitignore Management Skill (ign
)
ignGitignore 管理 Skill (ign
)
ignign.gitignoreign.gitignore1. Prerequisites & Installation
1. 前置条件与安装
Before performing any operations, the Agent should verify installation and initialization in sequence:
.gitignore在执行任何 操作前,Agent 应按顺序验证安装和初始化情况:
.gitignore1.1 Verify and Install the CLI Tool
1.1 验证并安装 CLI 工具
bash
command -v ign >/dev/null 2>&1 || cargo install ignbash
command -v ign >/dev/null 2>&1 || cargo install ign1.2 Verify and Initialize the Template Library
1.2 验证并初始化模板库
Check if is initialized. If not ready, clone the official template repository:
~/.config/ign/templatesbash
ign template status >/dev/null 2>&1 || ign template init检查 是否已初始化。如果尚未就绪,克隆官方模板仓库:
~/.config/ign/templatesbash
ign template status >/dev/null 2>&1 || ign template init2. Context-Aware Template Selection
2. 上下文感知的模板选择
When configuring for a project, the Agent should first inspect the workspace context (project markers, build files, OS, and IDE configuration) to automatically select and combine matching templates:
.gitignore为项目配置 时,Agent 应首先检查工作区上下文(项目标记、构建文件、操作系统和 IDE 配置),以自动选择并组合匹配的模板:
.gitignore2.1 Language & Tech Stack Mapping
2.1 语言与技术栈映射
| Project Marker / Directory | Recommended Template | Description |
|---|---|---|
| | Rust build artifacts ( |
| | Node.js / Web frontend dependencies and build outputs |
| | Python virtual environments and |
| | Go binaries and vendor directories |
| | Java Maven projects |
| | Gradle / Kotlin / Android projects |
| | PHP Composer dependencies |
| | Ruby / Rails dependencies and logs |
| | Dart / Flutter cross-platform projects |
| | C / C++ build outputs |
| | Deno cache and build artifacts |
| | Elixir / Phoenix projects |
| | .NET / C# solutions |
| 项目标记/目录 | 推荐模板 | 说明 |
|---|---|---|
| | Rust 构建产物( |
| | Node.js / Web 前端依赖项和构建输出 |
| | Python 虚拟环境和 |
| | Go 二进制文件和 vendor 目录 |
| | Java Maven 项目 |
| | Gradle / Kotlin / Android 项目 |
| | PHP Composer 依赖项 |
| | Ruby / Rails 依赖项和日志 |
| | Dart / Flutter 跨平台项目 |
| | C / C++ 构建输出 |
| | Deno 缓存和构建产物 |
| | Elixir / Phoenix 项目 |
| | .NET / C# 解决方案 |
2.2 Operating System & IDE Templates
2.2 操作系统与 IDE 模板
- Operating System (add based on current execution environment):
- Linux: (maps to
Linux)Global/Linux - macOS: (maps to
macOS)Global/macOS - Windows: (maps to
Windows)Global/Windows
- Linux:
- Developer Tools / IDE (add based on workspace settings or user preference):
- VS Code: (alias
Visual_Studio_Code, maps tovscode)Global/VisualStudioCode - JetBrains (IDEA/CLion/RustRover/PyCharm/GoLand): (alias
JetBrains, maps toidea)Global/JetBrains
- VS Code:
- 操作系统(根据当前执行环境添加):
- Linux:(映射到
Linux)Global/Linux - macOS:(映射到
macOS)Global/macOS - Windows:(映射到
Windows)Global/Windows
- Linux:
- 开发工具/IDE(根据工作区设置或用户偏好添加):
- VS Code:(别名
Visual_Studio_Code,映射到vscode)Global/VisualStudioCode - JetBrains(IDEA/CLion/RustRover/PyCharm/GoLand):(别名
JetBrains,映射到idea)Global/JetBrains
- VS Code:
2.3 Agent Automated Decision Examples
2.3 Agent 自动化决策示例
bash
undefinedbash
undefinedExample: Rust project detected on Linux with VS Code and JetBrains IDEs
Example: Rust project detected on Linux with VS Code and JetBrains IDEs
ign init Rust macOS Linux JetBrains Visual_Studio_Code
ign init Rust macOS Linux JetBrains Visual_Studio_Code
Example: Frontend Node.js project detected
Example: Frontend Node.js project detected
ign init Node macOS Linux Visual_Studio_Code
---ign init Node macOS Linux Visual_Studio_Code
---3. Usage & Commands
3. 用法与命令
3.1 Initialize Project .gitignore
(init
)
.gitignoreinit3.1 初始化项目 .gitignore
(init
)
.gitignoreinit- Initialize with explicitly specified templates:
bash
ign init Rust macOS JetBrains Visual_Studio_Code - Interactive multi-select selection:
bash
ign init -i - Re-initialize existing file while preserving manual custom rules:
bash
ign init Rust macOS
- 使用显式指定的模板进行初始化:
bash
ign init Rust macOS JetBrains Visual_Studio_Code - 交互式多选:
bash
ign init -i - 重新初始化现有文件,同时保留手动添加的自定义规则:
bash
ign init Rust macOS
3.2 Append & Update Templates (add
)
add3.2 追加与更新模板(add
)
addSafely append new language or tool templates into an existing (auto-deduplicated, preserving custom rules):
.gitignorebash
ign add Linux Python将新的语言或工具模板安全地追加到现有 中(自动去重并保留自定义规则):
.gitignorebash
ign add Linux Python3.3 Inspect & Audit Applied Templates (status
)
status3.3 检查与审计已应用的模板(status
)
statusInspect metadata of the current repository's (applied templates, timestamps, custom rules):
.gitignorebash
undefined检查当前仓库 的元数据(已应用的模板、时间戳、自定义规则):
.gitignorebash
undefinedHuman-readable terminal output
Human-readable terminal output
ign status
ign status
Structured JSON output for Agent/CI consumption
Structured JSON output for Agent/CI consumption
ign status --json
**JSON Output Schema**:
```json
{
"file_exists": true,
"path": ".gitignore",
"managed_by_ign": true,
"templates_count": 4,
"templates": [
"Rust",
"Global/macOS",
"Global/JetBrains",
"Global/VisualStudioCode"
],
"created_at": "2026-08-29T04:33:10Z",
"updated_at": "2026-08-29T04:33:21Z",
"has_custom_rules": true,
"custom_rules_lines": 2,
"custom_rules": "# Custom user rule\nscratch/",
"total_lines": 220
}ign status --json
**JSON 输出结构**:
```json
{
"file_exists": true,
"path": ".gitignore",
"managed_by_ign": true,
"templates_count": 4,
"templates": [
"Rust",
"Global/macOS",
"Global/JetBrains",
"Global/VisualStudioCode"
],
"created_at": "2026-08-29T04:33:10Z",
"updated_at": "2026-08-29T04:33:21Z",
"has_custom_rules": true,
"custom_rules_lines": 2,
"custom_rules": "# Custom user rule\nscratch/",
"total_lines": 220
}3.4 Remove Specified Templates (remove
)
remove3.4 移除指定模板(remove
)
removeRemove templates from while keeping remaining templates and custom rules intact:
.gitignorebash
ign remove Global/macOS从 中移除指定模板,同时保持其余模板和自定义规则完好:
.gitignorebash
ign remove Global/macOSOr using smart alias:
Or using smart alias:
ign remove macos
undefinedign remove macos
undefined3.5 Search & Explore Templates (search
/ list
/ show
)
searchlistshow3.5 搜索与浏览模板(search
/ list
/ show
)
searchlistshowbash
undefinedbash
undefinedFuzzy search templates
Fuzzy search templates
ign search elixir
ign search jetbrains --json
ign search elixir
ign search jetbrains --json
View raw template contents
View raw template contents
ign show Rust
ign show Rust
List all templates in a category
List all templates in a category
ign list -c global
undefinedign list -c global
undefined3.6 Local Template Repository Maintenance (template
)
template3.6 本地模板仓库维护(template
)
templatebash
undefinedbash
undefinedInspect local template library status and directory path
Inspect local template library status and directory path
ign template status
ign template path
ign template status
ign template path
Manually pull latest templates from GitHub
Manually pull latest templates from GitHub
ign template update
ign template update
(Top-level shorthand: ign update)
(Top-level shorthand: ign update)
---
---4. Environment Variables
4. 环境变量
- Default template storage path:
~/.config/ign/templates - Custom storage path override:
export IGN_TEMPLATES_DIR="/path/to/custom/gitignore-repo"
- 默认模板存储路径:
~/.config/ign/templates - 自定义存储路径覆盖:
export IGN_TEMPLATES_DIR="/path/to/custom/gitignore-repo"