-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Feature: Auto-translate AI assistant guidelines into pre-merge rules
Translate natural-language guidelines from Cursor, Claude, or Copilot Markdown files into enforceable pre-merge rules.
This is a high-impact, advanced task that plays to Watchflow's agentic strengths (LangGraph + GitHub events) and taps into the exploding trend of AI-agent hooks & governance. Perfect for someone wanting to ship real value and get deep into the codebase.
Goal
Build a feature that auto-detects Markdown files in repos containing AI-assistant instructions (e.g. .cursorrules, claude-guidelines.md, copilot-prompts.md), parses the rules using our agentic pipeline, translates them into .watchflow/rules.yaml format, and enforces them as pre-merge checks (PR comments / check runs).
Bonus: make it hook-driven so rules auto-update on relevant pushes.
Why this matters
- Teams using Cursor/Claude/Copilot often document rules in MD files — but those stay as "advice" instead of hard guards.
- This bridges that gap: AI-generated code gets auto-validated before merge.
- Aligns with the agentic hooks trend (reactive, self-improving workflows via webhooks + LangGraph).
Real-World Use Cases
When developers instruct their AI assistants using files like .cursorrules or .github/copilot-instructions.md, they often specify architectural or stylistic constraints. Here are examples of real rules we want to automatically enforce:
Case 1: Next.js Architecture Constraints
Instruction from .cursorrules: "Use React Server Components by default. Only use 'use client' directives at the leaf nodes of the component tree when interactivity (hooks like useState, useEffect) is strictly necessary."
Enforced as: A rule that flags PRs introducing 'use client' in high-level layout files or components that don't import React hooks.
Case 2: FastAPI Data Validation
Instruction from .github/copilot-instructions.md: "Never use raw dictionaries for API responses. Always define and return Pydantic models for data validation and OpenAPI schema generation."
Enforced as: A rule that blocks PRs where FastAPI route functions lack a response_model parameter or return raw dicts.
Case 3: Testing Standards
Instruction from .cursorrules: "Every new feature or bug fix must include corresponding tests using Pytest. Mock external API calls using responses or httpx-mock."
Enforced as: A rule requiring the PR to include modifications in the tests/ directory, specifically checking for pytest imports and mocking libraries.
Estimated Scope
Medium-hard. Start with an MVP (one AI tool + basic translation), then expand. A great first PR could be the parser + proof-of-concept agent chain.
Implementation Steps
1. Repo Scanning
- Hook into the existing analysis pipeline (extend
/api/v1/rules/recommendor add a new endpoint). - Use GitHub API to list files -> match patterns like
.cursorrules,*rules*.md,*guidelines*.md. - Keywords to detect: "Cursor rule:", "Claude:", "Always use", "Never commit", etc.
2. Agentic Parsing & Translation
Build a LangGraph chain/agent:
- Extractor Agent: Read MD content -> pull out rule-like statements (prompt engineering here is key).
- Translator Agent: Map to our YAML schema.
Example Translation:
# From .cursorrules: "Always use async/await for network calls"
- name: async-io-required
on: [pull_request]
condition: file:"*.py" AND has_io AND NOT uses_async_await
action: fail_check "Use async/await for I/O operations"
# From .github/copilot-instructions.md: "New features must have unit tests"
- name: tests-for-features
on: [pull_request]
require: linked_issue AND has_tests_for_changed_codeFallback: If ambiguous, post a PR comment asking for confirmation.
3. Pre-Merge Enforcement
- Trigger on
pull_request(opened/synchronize) webhook events. - Run translated rules -> create Check Run (success/failure) or comment with violations.
- Block merge if critical rules fail (configurable severity).
4. Agentic Hooks Bonus
- Add support for
pushevents: if an MD rules file changes -> auto-re-run translator -> suggest/commit updated.watchflow/rules.yaml. - Creates a self-improving loop: AI enforces rules that AI teams write.
Getting Started
- Look at existing LangGraph agents in the code for inspiration.
- Start small: prototype the MD -> YAML translation in a standalone script/notebook, then integrate.
- Tests: add cases with sample MD inputs (we can add fixtures together).
- Questions? Drop them here or open a draft PR / issue — happy to pair/review.
Stretch Goals
- Support multiple AI tools with different prompt styles.
- Add confidence scoring (e.g., "80% sure this is a rule — approve?").
- UI hint in watchflow.dev to scan for these MD files during repo analysis.