---
id: daily-hygiene
name: "hygiene"
url: https://skills.yangsir.net/skill/daily-hygiene
author: microsoft
domain: ai-code-generation-quality
tags: ["code-quality", "pre-commit", "git-hooks", "code-review", "automation"]
install_count: 2200
rating: 4.30 (20 reviews)
github: https://github.com/microsoft/vscode
---

# hygiene

> VS Code 预提交卫生检查工具，在提交前自动执行代码质量检查，卫生检查失败则阻止提交，确保代码库质量标准

**Stats**: 2,200 installs · 4.3/5 (20 reviews)

## Before / After 对比

### 代码质量保障

**Before**:

手动检查代码质量和格式规范，容易遗漏问题，不合格代码提交后需要反复修改和推送，影响团队协作效率

**After**:

自动执行预提交卫生检查，零遗漏拦截不合格代码，确保每次提交都符合质量标准

| Metric | Before | After | Change |
|---|---|---|---|
| 代码返工率 | 25% | 2% | -92% |

## Readme

# hygiene

# Hygiene Checks

VS Code runs a hygiene check as a git pre-commit hook. Commits will be rejected if hygiene fails.

## Running the hygiene check

**Always run the pre-commit hygiene check before declaring work complete.** This catches issues that would block a commit.

To run the hygiene check on your staged files:

```
npm run precommit

```

This executes `node --experimental-strip-types build/hygiene.ts`, which scans only **staged files** (from `git diff --cached`).

To check specific files directly (without staging them first):

```
node --experimental-strip-types build/hygiene.ts path/to/file.ts

```

## What it checks

The hygiene linter scans staged files for issues including (but not limited to):

- **Unicode characters**: Non-ASCII characters (em-dashes, curly quotes, emoji, etc.) are rejected. Use ASCII equivalents in comments and code. Suppress with `// allow-any-unicode-next-line` or `// allow-any-unicode-comment-file`.

- **Double-quoted strings**: Only use `"double quotes"` for externalized (localized) strings. Use `'single quotes'` everywhere else.

- **Copyright headers**: All files must include the Microsoft copyright header.

- **Indentation**: Tabs only, no spaces for indentation.

- **Formatting**: TypeScript files must match the formatter output (run `Format Document` to fix).

- **ESLint**: TypeScript files are linted with ESLint.

- **Stylelint**: CSS files are linted with stylelint.

Weekly Installs437Repository[microsoft/vscode](https://github.com/microsoft/vscode)GitHub Stars183.5KFirst SeenFeb 20, 2026Security Audits[Gen Agent Trust HubPass](/microsoft/vscode/hygiene/security/agent-trust-hub)[SocketPass](/microsoft/vscode/hygiene/security/socket)[SnykPass](/microsoft/vscode/hygiene/security/snyk)Installed onkimi-cli436amp436github-copilot436opencode436cursor436gemini-cli436

---
*Source: https://skills.yangsir.net/skill/daily-hygiene*
*Markdown mirror: https://skills.yangsir.net/api/skill/daily-hygiene/markdown*