返回技能列表

configure-git-repository

pjt222
更新于 2 days ago
6 次查看
17
2
17
在 GitHub 上查看
其他general

关于

This skill configures a Git repository with language-specific .gitignore files, branching strategies, commit conventions, and hooks. It provides setup patterns for R, Node.js, and Python projects during initial version control configuration. Use it to establish a proper Git foundation or to add framework-specific ignores and automation to an existing project.

快速安装

Claude Code

推荐
主要方式
npx skills add pjt222/agent-almanac -a claude-code
插件命令备选方式
/plugin add https://github.com/pjt222/agent-almanac
Git 克隆备选方式
git clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/configure-git-repository

在 Claude Code 中复制并粘贴此命令以安装该技能

技能文档

Configure Git Repository

Set up Git repo w/ appropriate config for project type.

Use When

  • Init version control for new project
  • Add .gitignore for specific language/framework
  • Set up branch protection + conventions
  • Configure commit hooks

In

  • Required: Project dir
  • Required: Project type (R pkg, Node.js, Python, general)
  • Optional: Remote repo URL
  • Optional: Branch strategy (trunk-based, Git Flow)
  • Optional: Commit msg convention

Do

Step 1: Initialize Repo

cd /path/to/project
git init
git branch -M main

.git/ dir created. Default branch = main.

If err: git init fails → ensure Git installed (git --version). Dir already has .git/ → repo already init'd → skip step.

Step 2: Create .gitignore

R Package:

# R artifacts
.Rhistory
.RData
.Rproj.user/
*.Rproj

# Environment (sensitive)
.Renviron

# renv library (machine-specific)
renv/library/
renv/staging/
renv/cache/

# Build artifacts
*.tar.gz
src/*.o
src/*.so
src/*.dll

# Documentation build
docs/
inst/doc/

# IDE
.vscode/
.idea/

# OS
.DS_Store
Thumbs.db

Node.js/TypeScript:

node_modules/
dist/
build/
.next/
.env
.env.local
.env.*.local
*.log
npm-debug.log*
.DS_Store
Thumbs.db
.vscode/
.idea/
coverage/

Python:

__pycache__/
*.py[cod]
*.egg-info/
dist/
build/
.eggs/
.venv/
venv/
.env
*.log
.mypy_cache/
.pytest_cache/
htmlcov/
.coverage
.DS_Store
.idea/
.vscode/

.gitignore created w/ entries for project type. Sensitive files (.Renviron, .env) + generated artifacts excluded.

If err: Unsure which entries → use gitignore.io or GitHub's .gitignore templates as starting point, customize.

Step 3: Create Initial Commit

git add .gitignore
git add .  # Review what's being added first with git status
git commit -m "Initial project setup"

First commit w/ .gitignore + initial project files. git log shows one commit.

If err: "Nothing to commit" → ensure files staged w/ git add. Author identity err → set git config user.name + git config user.email.

Step 4: Connect Remote

# Add remote
git remote add origin [email protected]:username/repo.git

# Push
git push -u origin main

Remote origin config'd. git remote -v shows fetch + push URLs. Initial commit pushed.

If err: Push fails "Permission denied (publickey)" → configure SSH keys (see setup-wsl-dev-environment). Remote already exists → update w/ git remote set-url origin <url>.

Step 5: Set Up Branch Conventions

Trunk-based (rec'd for small teams):

  • main: prod-ready code
  • Feature branches: feature/description
  • Bug fixes: fix/description
# Create feature branch
git checkout -b feature/add-authentication

# After work is done, merge or create PR
git checkout main
git merge feature/add-authentication

Branch naming convention established + doc'd. Team knows which prefix to use for each work type.

If err: Branches already named inconsistent → rename w/ git branch -m old-name new-name + update any open PRs.

Step 6: Configure Commit Conventions

Conventional Commits format:

type(scope): description

feat: add user authentication
fix: correct calculation in weighted_mean
docs: update README installation section
test: add edge case tests for parser
refactor: extract helper function
chore: update dependencies

Commit msg convention doc'd + agreed. Future commits follow type: description format.

If err: Team not following → enforce w/ commit-msg hook validating format (see Step 7).

Step 7: Set Up Pre-Commit Hooks (Optional)

Create .githooks/pre-commit:

#!/bin/bash
# Run linter before commit

# For R packages
if [ -f "DESCRIPTION" ]; then
  Rscript -e "lintr::lint_package()" || exit 1
fi

# For Node.js
if [ -f "package.json" ]; then
  npm run lint || exit 1
fi
chmod +x .githooks/pre-commit
git config core.hooksPath .githooks

Pre-commit hook runs auto on each git commit. Lint errs block commit until fixed.

If err: Hook doesn't run → valid. core.hooksPath set (git config core.hooksPath) + hook file executable (chmod +x).

Step 8: Create README

# Minimal README
echo "# Project Name" > README.md
echo "" >> README.md
echo "Brief description of the project." >> README.md
git add README.md
git commit -m "Add README"

README.md committed. Project has minimal but informative landing page on GitHub.

If err: README.md already exists → update vs. overwrite. R projects → use usethis::use_readme_md() for template w/ badges.

Check

  • .gitignore excludes sensitive + generated files
  • No sensitive data (tokens, passwords) in tracked files
  • Remote repo connected + accessible
  • Branch naming conventions doc'd
  • Initial commit clean

Traps

  • Commit before .gitignore: Add .gitignore first. Files already tracked unaffected by later .gitignore entries.
  • Sensitive data in history: Secrets committed → remain in history even after deletion. Use git filter-repo or BFG to clean.
  • Large binary files: Don't commit large binaries. Use Git LFS for files > 1MB.
  • Line endings: Set core.autocrlf=input on Windows/WSL → prevent CRLF/LF issues.

  • commit-changes - staging + committing workflow
  • manage-git-branches - branch creation + conventions
  • create-r-package - Git setup as part of R pkg creation
  • setup-wsl-dev-environment - Git install + SSH keys
  • create-github-release - creating releases from repo
  • security-audit-codebase - check for committed secrets

GitHub 仓库

pjt222/agent-almanac
路径: i18n/caveman-ultra/skills/configure-git-repository
0
agentsagentskillsai-assisted-developmentclaude-codeskillsteams

相关推荐技能

llamaguard

其他

LlamaGuard是Meta推出的7-8B参数内容审核模型,专门用于过滤LLM的输入和输出内容。它能检测六大安全风险类别(暴力/仇恨、性内容、武器、违禁品、自残、犯罪计划),准确率达94-95%。开发者可通过HuggingFace、vLLM或Sagemaker快速部署,并能与NeMo Guardrails集成实现自动化安全防护。

查看技能

cost-optimization

其他

这个Claude Skill帮助开发者优化云成本,通过资源调整、标记策略和预留实例来降低AWS、Azure和GCP的开支。它适用于减少云支出、分析基础设施成本或实施成本治理策略的场景。关键功能包括提供成本可视化、资源规模调整指导和定价模型优化建议。

查看技能

quantizing-models-bitsandbytes

其他

这个Skill使用bitsandbytes库量化大语言模型,能在GPU内存有限时通过8位或4位量化减少50-75%内存占用,同时保持精度损失最小。它支持INT8、NF4、FP4等多种量化格式,可与HuggingFace Transformers无缝集成,适用于需要部署更大模型或加速推理的场景。还提供QLoRA训练和8位优化器支持,让开发者能轻松实现高效模型压缩。

查看技能

dispatching-parallel-agents

其他

该Skill用于并行处理3个以上无依赖关系的独立故障,可为每个问题域分派专属Claude代理同时执行调查修复。它通过并发处理多个独立问题显著提升故障排查效率,特别适用于测试文件、子系统等无共享状态的场景。

查看技能