Code Quality Skill
Relevant source files
The following files were used as context for generating this wiki page:The code-quality skill is a comprehensive tool designed to enforce code standards by running a series of checks, including type-checking, linting, formatting, and markdown validation. Its primary purpose is to ensure that code is clean, consistent, and correct before it is committed to the repository. This skill is typically used by AI agents or developers before finalizing work, after making changes, or as part of a continuous integration (CI) pipeline.
This skill integrates with other development workflow skills, such as docs-check and git-commit, to form a complete pre-commit validation process. By automating these checks, it helps maintain a high standard of code health and consistency across the project.
Sources: skills/code-quality/SKILL.md:1-4, skills/README.md:11, AGENTS.md:25
Core Functionality
The skill performs several automated checks to validate the codebase. These checks are executed sequentially to catch a wide range of potential issues.
Sources: skills/code-quality/SKILL.md:10-15
| Check | Description |
|---|---|
| Typecheck | Runs TypeScript type checking to catch type-related errors without compiling. |
| Lint | Uses ESLint to analyze code for stylistic issues and potential bugs based on configured rules. |
| Format | Checks code formatting against Prettier rules to ensure a consistent style. |
| Markdown | Validates Markdown files for correctness and consistency. |
Sources: skills/code-quality/SKILL.md:11-14, INSTALL.md:100-123
Execution Flow
The core logic is contained within the finalize.sh script. This script is designed to be flexible, with different modes of operation and automatic detection of the project's package manager.
Sources: skills/code-quality/scripts/finalize.sh, skills/README.md:11
Operating Modes
The script can be run in two primary modes, determined by the first argument passed to it.
| Mode | Argument | Description |
|---|---|---|
| Agent Mode | agent | An interactive mode designed for use by an AI agent or developer. If formatting errors are found, it prompts the user to automatically fix them by running the format:write command. |
| CI Mode | ci | A non-interactive mode for use in CI/CD pipelines. It runs all checks and reports errors without attempting to fix them automatically. This is the default mode if no argument is provided. |
Sources: skills/code-quality/scripts/finalize.sh:22-26, 73-86
Script Logic
The finalize.sh script follows a clear sequence of operations to perform its checks. It first determines the correct package manager and then executes the validation steps.
The diagram below illustrates the execution flow of the finalize.sh script.
Dependencies and Configuration
To function correctly, the code-quality skill relies on several project-specific dependencies and a corresponding configuration in package.json.
Sources: INSTALL.md:98-128
Required Dependencies
The project must have the following npm packages installed, typically as development dependencies.
| Dependency | Purpose |
|---|---|
typescript | For the typecheck step. |
eslint | For the lint step. |
prettier | For the format:check and format:write steps. |
Sources: INSTALL.md:102-123
Required package.json Scripts
The finalize.sh script expects the following scripts to be defined in the project's package.json file.
| Script | Example Command | Purpose |
|---|---|---|
typecheck | tsc --noEmit | Executes TypeScript type checking. |
lint | eslint . | Runs the linter on the codebase. |
format:check | prettier --check . | Checks for formatting violations. |
format:write | prettier --write . | Automatically fixes formatting violations. |
Sources: INSTALL.md:125-131
Integration in Developer Workflow
The code-quality skill is a key step in the pre-commit workflow, ensuring that only validated code is saved to the repository's history. It is typically run after other checks like docs-check and immediately before creating a commit with git-commit.
Sources: skills/code-quality/SKILL.md:31-33, skills/git-commit/SKILL.md:173-175
The following diagram shows a typical developer workflow incorporating the code-quality skill.
Summary
The code-quality skill acts as an automated gatekeeper for the codebase. By bundling type-checking, linting, and formatting into a single, easy-to-use script (finalize.sh), it standardizes code validation and simplifies the process for both developers and AI agents. Its integration into the pre-commit workflow is essential for maintaining a high-quality, consistent, and error-free codebase.
Sources: skills/code-quality/SKILL.md, README.md:20