Skip to content

Create agent skill for writing bespoke prek hooks#1541

Merged
nathanjmcdougall merged 4 commits intomainfrom
copilot/create-agent-skill-for-git-hooks
Mar 25, 2026
Merged

Create agent skill for writing bespoke prek hooks#1541
nathanjmcdougall merged 4 commits intomainfrom
copilot/create-agent-skill-for-git-hooks

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

Adds guidance for agents writing custom project-specific prek hooks as Python scripts, prompted by review feedback on #1532 where a bash hook was rejected in favor of Python.

New skill usethis-prek-hook-bespoke-create covers:

  • Location/naming: .py scripts in hooks/ at project root, kebab-case filenames
  • Pure Python constraint: Standard library only, no subprocessing — if it needs an external tool, it's not a bespoke hook
  • Script structure: sys.exit conventions, stderr for errors, optional --fix flag via argparse
  • Performance: Targeted file reads, efficient glob patterns, avoid heavy imports
  • Wiring: Local system hook entry using uv run --frozen --offline hooks/<id>.py

Example hook config from the skill:

- repo: local
  hooks:
    - id: check-skills-documented
      name: check-skills-documented
      entry: uv run --frozen --offline hooks/check-skills-documented.py
      language: system
      always_run: true
      pass_filenames: false
      priority: 0

Defers to existing usethis-prek-add-hook skill for priority assignment and placement.

Original prompt

This section details on the original issue you should resolve

<issue_title>Create an agent skill for writing bespoke git hooks</issue_title>
<issue_description>Originally posted by @nathanjmcdougall in #1532 (comment)

Let's make an agent skill describing how to make bespoke prek hooks for custom checks.

We can write them as .py scripts in a hooks directory.

We should invoke them using uv run similar to some of the other system hooks.

They should never subprocess software, only use basically pure python. They should be performant.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/1b435395-e6f0-4957-95bf-375575447eec
Copilot AI changed the title [WIP] Add agent skill for writing bespoke git hooks Create agent skill for writing bespoke prek hooks Mar 25, 2026
Copilot AI requested a review from nathanjmcdougall March 25, 2026 19:53
Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/8c06382a-d966-4fca-8313-1f4cdfd86247
@nathanjmcdougall nathanjmcdougall merged commit bc459ef into main Mar 25, 2026
@nathanjmcdougall nathanjmcdougall deleted the copilot/create-agent-skill-for-git-hooks branch March 25, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create an agent skill for writing bespoke git hooks

2 participants