Skip to content

naravid19/ai-project-rules-generator

generating-project-rules

Verified

Make sure to use this skill WHENEVER the user mentions creating, generating, or updating project rules files (.cursorrules, AGENTS.md, CLAUDE.md, GEMINI.md, or equivalent) for any software project. This is essential when a user wants to integrate AI skills into their development workflow, or when they need cross-platform AI tool configuration. Skip this for general code generation, refactoring, or tasks unrelated to AI agent configuration files.

scripts/traceability.py

View on GitHub
from __future__ import annotations

import re
from dataclasses import dataclass
from pathlib import Path

from rules_config import load_confirmed_skill_sources, load_skill_sources

SKILL_SOURCE_PATH_PATTERN = re.compile(r"<!--\s*Skill_Source_Path:\s*(?P<path>.+?)\s*-->")
CONFIRMED_SOURCE_PATTERN = re.compile(
    r"<!--\s*Confirmed_Skill_Source:\s*(?P<value>true|false)\s*-->",
    re.IGNORECASE,
)


@dataclass(frozen=True)
class TraceabilityMetadata:
    skill_source_path: str = ""
    confirmed_skill_source: bool = False


def extract_traceability_metadata(content: str) -> TraceabilityMetadata:
    path_match = SKILL_SOURCE_PATH_PATTERN.search(content)
    confirmed_match = CONFIRMED_SOURCE_PATTERN.search(content)
    return TraceabilityMetadata(
        skill_source_path=(path_match.group("path").strip() if path_match else ""),
        confirmed_skill_source=bool(
            confirmed_match and confirmed_match.group("value").lower() == "true"
        ),
    )


def validate_traceability_file(project_root: Path, file_path: Path) -> list[str]:
    content = Path(file_path).read_text(encoding="utf-8")
    metadata = extract_traceability_metadata(content)
    return validate_traceability_metadata(project_root, metadata)


def validate_traceability_metadata(
    project_root: Path,
    metadata: TraceabilityMetadata,
) -> list[str]:
    root = Path(project_root).resolve()
    errors: list[str] = []

    if not metadata.skill_source_path:
        errors.append("Missing Skill_Source_Path metadata comment.")
        return errors

    resolved_path = _resolve_metadata_path(root, metadata.skill_source_path)
    if not resolved_path.exists():
        errors.append("Traceability path does not exist in the filesystem.")

    if not metadata.confirmed_skill_source:
        errors.append("Confirmed_Skill_Source metadata must be true.")

    configured_sources = load_skill_sources(root / ".rulesrc.yaml")
    if configured_sources and not _matches_configured_source(root, metadata.skill_source_path, configured_sources):
        errors.append("Traceability path is not listed in .rulesrc.yaml skill_sources.")

    confirmed_sources = load_confirmed_skill_sources(root / ".rulesrc.yaml")
    if confirmed_sources and not _matches_configured_source(root, metadata.skill_source_path, confirmed_sources):
        errors.append("Traceability path is not one of the confirmed skill sources.")

    return errors


def _resolve_metadata_path(project_root: Path, raw_path: str) -> Path:
    candidate = Path(raw_path)
    if candidate.is_absolute():
        return candidate
    return (project_root / candidate).resolve()


def _matches_configured_source(project_root: Path, raw_metadata_path: str, sources) -> bool:
    resolved_metadata = _resolve_metadata_path(project_root, raw_metadata_path)
    for source in sources:
        if source.path == raw_metadata_path:
            return True
        if source.resolved_path(project_root) == resolved_metadata:
            return True
    return False
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 321kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 321kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 321kUpdated Claude CodeCodexVerifiedInstall