naravid19/ai-project-rules-generator
generating-project-rules
VerifiedMake 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 21.0 KB |
| assets/i18n/README.md | markdown | 2.9 KB |
| assets/images/logo.png | binary | 14.1 KB |
| assets/templates/README.md | markdown | 3.1 KB |
| assets/templates/mcp_registry.yaml | config | 1.2 KB |
| assets/templates/rulesrc-template.yaml | config | 7.3 KB |
| scripts/audit.py | script | 6.5 KB |
| scripts/config_runtime.py | script | 4.0 KB |
| scripts/discover-skills.py | script | 26.4 KB |
| scripts/extract-capabilities.py | script | 2.0 KB |
| scripts/indexer.py | script | 15.3 KB |
| scripts/lib/__init__.py | script | 74 B |
| scripts/lib/confidence.py | script | 1.8 KB |
| scripts/lib/config_runtime.py | script | 1.1 KB |
| scripts/lib/design_tokens.py | script | 4.7 KB |
| scripts/lib/semantic_matcher.py | script | 2.1 KB |
| scripts/log_viewer.py | script | 2.7 KB |
| scripts/memory_manager.py | script | 4.6 KB |
| scripts/project_rules_runtime.py | script | 27.3 KB |
| scripts/remote_source.py | script | 2.1 KB |
| scripts/rules_config.py | script | 5.7 KB |
| scripts/skill_metadata.py | script | 7.2 KB |
| scripts/traceability.py | script | 2.9 KB |
| scripts/validate-output.ps1 | script | 24.5 KB |
| scripts/validate-output.sh | script | 19.9 KB |
| scripts/wizard.py | script | 18.1 KB |
scripts/lib/design_tokens.py
View on GitHubfrom __future__ import annotations
import re
import subprocess
import json
import tempfile
from pathlib import Path
from typing import Any
class DesignTokenEngine:
def __init__(self, project_root: Path):
self.project_root = project_root
def extract(self) -> dict[str, Any]:
tokens = {"colors": {}, "fonts": {}, "spacing": {}}
# 1. Tailwind
tailwind_files = list(self.project_root.glob("tailwind.config.*"))
for tf in tailwind_files:
tw_tokens = self._extract_tailwind_via_node(tf)
if not tw_tokens["colors"]:
tw_tokens = self._extract_tailwind_fallback_regex(tf)
self._deep_update(tokens, tw_tokens)
# 2. CSS
css_files = []
for ext in ["*.css", "*.scss"]:
css_files.extend(list(self.project_root.glob(ext)))
css_files.extend(list((self.project_root / "src").glob(f"**/{ext}")))
for cf in css_files:
if "node_modules" in cf.parts:
continue
try:
content = cf.read_text(encoding="utf-8", errors="ignore")
css_tokens = self._parse_css_content(content)
self._deep_update(tokens, css_tokens)
except Exception:
pass
return tokens
def _extract_tailwind_fallback_regex(self, config_path: Path) -> dict[str, Any]:
tokens = {"colors": {}, "fonts": {}, "spacing": {}}
try:
content = config_path.read_text(encoding="utf-8", errors="ignore")
# Simple regex for colors: "primary": "#hex"
color_matches = re.findall(r'[\'"]([a-zA-Z0-9-]+)[\'"]\s*:\s*[\'"](#[a-fA-F0-9]{3,8}|(?:rgb|hsl)a?\([^)]+\))[\'"]', content)
for name, value in color_matches:
tokens["colors"][name] = value
# Fonts: "sans": ["Inter", "sans-serif"]
font_matches = re.findall(r'[\'"]([a-zA-Z0-9-]+)[\'"]\s*:\s*\[\s*([^\]]+)\s*\]', content)
for name, value_list in font_matches:
items = [v.strip().strip("'\"") for v in value_list.split(",")]
tokens["fonts"][name] = items
except Exception:
pass
return tokens
def _deep_update(self, base: dict[str, Any], update: dict[str, Any]):
for key, value in update.items():
if key in base and isinstance(base[key], dict) and isinstance(value, dict):
base[key].update(value)
else:
base[key] = value
def _parse_css_content(self, content: str) -> dict[str, Any]:
tokens = {"colors": {}, "fonts": {}, "spacing": {}}
# Match --var: value; patterns
matches = re.findall(r'(--[a-zA-Z0-9-]+)\s*:\s*([^;]+);', content)
for name, value in matches:
v = value.strip()
if v.startswith("#") or v.startswith("rgb") or v.startswith("hsl"):
tokens["colors"][name] = v
elif "font" in name.lower():
tokens["fonts"][name] = v
elif any(k in name.lower() for k in ["spacing", "gap", "padding", "margin"]):
tokens["spacing"][name] = v
return tokens
def _extract_tailwind_via_node(self, config_path: Path) -> dict[str, Any]:
if not config_path.exists(): return {"colors": {}, "fonts": {}, "spacing": {}}
js_helper = f"""
try {{
const config = require('{config_path.resolve().as_posix()}');
let theme = config.theme || config;
// Try to resolve if tailwindcss is present
try {{
const resolveConfig = require('tailwindcss/resolveConfig');
const fullConfig = resolveConfig(config);
theme = fullConfig.theme;
}} catch (e) {{}}
console.log(JSON.stringify({{theme}}));
}} catch (e) {{
process.exit(1);
}}
"""
with tempfile.NamedTemporaryFile(mode='w', suffix='.js', delete=False) as f:
f.write(js_helper)
temp_js = Path(f.name)
try:
res = subprocess.run(['node', str(temp_js)], capture_output=True, text=True, timeout=5)
if res.returncode == 0:
data = json.loads(res.stdout)
theme = data.get("theme", {})
return {
"colors": theme.get("colors", {}),
"fonts": theme.get("fontFamily", {}),
"spacing": theme.get("spacing", {})
}
except Exception:
pass
finally:
temp_js.unlink(missing_ok=True)
return {"colors": {}, "fonts": {}, "spacing": {}}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 471k | Updated | Claude CodeCodex | Verified | Install |
| 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: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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 available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |