hypecodeteam/backend-ai-rules
hypecodeteam/backend-ai-rules is a Laravel/PHP package offering ready-made AI assistant rules for backend projects. It helps teams keep AI-assisted coding consistent with project conventions, architecture patterns, review expectations, and smoother collaboration across development workflows.
This package is not a runtime library — it ships markdown rule files that encode backend conventions so AI coding assistants (Cursor, Windsurf, Copilot, Claude Code, etc.) generate code that matches your team's style. Treat it like a linting config for your AI pair programmer, not like a Composer dependency you call at runtime.
Minimal steps:
composer require --dev hypecode/backend-ai-rules
.cursor/rules/*.mdc (Cursor).windsurfrules or .windsurf/rules/ (Windsurf).github/copilot-instructions.md (Copilot)CLAUDE.md / AGENTS.md (Claude Code, Codex-style agents)If you're here specifically for the 0.4.0 OpenAPI addition, start with that file and the API-related rules together; they're designed to be read as a set when generating or reviewing specs.
Vendor the rules, don't symlink them. Because assistants read files from the working tree, the most reliable pattern is to copy the relevant rule files into your project's assistant directory and commit them. Symlinks work on macOS/Linux but break for Windows contributors and in some CI containers.
Layer, don't replace. Keep the package rules as a "base" and add a thin project-specific overlay (project-conventions.mdc, AGENTS.md, etc.) for things unique to your app — domain naming, package choices, queue conventions. When the package releases a new rule file (like openAPI in 0.4.0), you drop it in and your overlay still applies.
Separate "always-on" from "scoped" rules. Most assistants support glob-scoped rules. Put architecture/naming rules in always-on, and scope API/OpenAPI rules to app/Http/**, routes/**, and your spec directory so they don't burn context on unrelated edits.
Code review prompts. Beyond scaffolding, feed the rules into review prompts: "Review this diff against the rules in .cursor/rules/. Flag violations with file:line." This is often higher value than generation, because it catches drift on PRs you'd otherwise rubber-stamp.
OpenAPI workflow (new in 0.4.0). Two viable directions:
routes/api.php plus your Resources/FormRequests and have it emit or update the spec, then validate.Either way, keep the spec in the repo and gate it in CI:
npx @redocly/cli lint openapi.yaml
# or
npx spectral lint openapi.yaml
Pin the version and bump deliberately. Because rules silently change model behaviour, treat a bump like a linter upgrade: read the diff, re-run a couple of representative prompts, and check the output still matches your conventions before merging.
Share across repos. For a multi-repo org, keep the canonical copy in one place and copy it out via a small script or a make sync-ai-rules target so every service gets the same baseline.
CLAUDE.md; Copilot won't read .cursor/rules. Generate the per-assistant variants from one source of truth rather than hand-maintaining four copies that drift.globs/alwaysApply is correct, and (c) the file wasn't truncated by context limits. This is the single most common "the rules don't work" report.nullable vs type: [string, "null"]). Always lint the output and pin the spec version explicitly in the prompt. Add example values — they measurably reduce nonsense.vendor/. Your changes vanish on composer update. Copy into your own directory (or a submodule) and customise there; upstream new rules then merge cleanly.composer.lock-aware script) so contributors don't accidentally fork conventions in their working tree.How can I help you explore Laravel packages today?