Skip to content

Add Pre-commit Hooks for Code Quality #15

@haroon0x

Description

@haroon0x

Summary

As the docs-agent project continues to mature, we should introduce automated code quality checks to ensure a consistent and professional codebase. Implementing pre-commit hooks will help us catch common issues - like formatting inconsistencies, trailing whitespace, and unused imports- before they are committed to the repository.

While we can look to projects like Kubeflow Pipelines for inspiration, a simple lightweight configuration that provides immediate value without over-complicating the development workflow would suffice initially.

Proposed Solution

We should implement a .pre-commit-config.yaml file with a foundational set of hooks.

Recommended Initial Hooks:

  • Essential Sanitization: trailing-whitespace, end-of-file-fixer, and check-yaml.
  • Code Formatting: black or yapf to ensure consistent Python style across all components.
  • Import Optimization: isort to automatically sort imports (referencing the Google profile used in other Kubeflow projects).
  • Linting: A basic flake8 setup to catch obvious syntax errors or technical debt.

Implementation Plan

  1. Initialize a minimal .pre-commit-config.yaml in the repository root.
  2. Focus on the most impactful Python hooks (formatting and linting).
  3. Ensure the configuration is easy for new contributors to install (pip install pre-commit && pre-commit install).
  4. Run an initial pass on the existing codebase to normalize the current files.

Motivation

Adding even a basic pre-commit setup now will prevent mechanical "nitpicks" in code reviews and ensure that the project maintains a high standard of quality as it scales.

Checklist

  • Add a simple .pre-commit-config.yaml to the root.
  • Include standard hooks for whitespace, formatting, and imports.
  • Verify the hooks run successfully on current files.
  • Add basic instructions for contributors in the README.md or CONTRIBUTING.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions