Star
READY TO SHIP v1.0.0 • 6 Native Agent Dialects

Laravel 12/13 + AI Features (LLM Orchestration, Embeddings & RAG)

Production-ready enterprise Laravel kit for building generative AI applications. Features structured LLM outputs, function/tool calling, PostgreSQL pgvector embeddings, semantic search, prompt injection defense, and asynchronous queue workers.

{'name': 'PHP', 'version': '^8.3 || ^8.4', 'registry': 'packagist'} {'name': 'Laravel', 'version': '^11.0 || ^12.0 || ^13.0', 'registry': 'packagist'} {'engine': 'PostgreSQL', 'version': '>= 16.0', 'features': ['pgvector Extension', 'vector(1536) Dimension', 'HNSW Cosine Distance Index', 'Zero-Downtime Migrations']}
$ git clone https://github.com/Umar-444/Techtalks-stack-kits.git
01 / STARTER & ARCHITECTURE
docker compose up -d
File / Subsystem Architecture Role Status
01 docker-compose.yml
Rootless isolated application & database runtime PRE-WIRED
02 starter/app/
Model layer, authorization policies, admin resources RBAC ENFORCED
03 starter/tests/
Pest / PHPUnit architectural and feature test suite AUTOMATED
04 .env.example
Zero plaintext secrets, strict dummy placeholders GITLEAKS READY
02 / NATIVE RULES (6 DIALECTS)
Source: kits/laravel-ai-features/CLAUDE.md • Token footprint: ~350 tokens
# Laravel 12/13 + AI Features (LLM Orchestration, Embeddings & RAG) — Claude Code Guidelines (CLAUDE.md)
# Auto-generated from rules/source/*.md by tools/transpiler.py. Do NOT edit directly.

## Quick Reference & Non-Negotiable Standards
### Framework and AI Architecture Conventions
> Architecture standards for Laravel 12/13 AI integrations.

# Framework and AI Architecture Conventions

## 1. Strict Typing and Contracts
- Always declare `declare(strict_types=1);` at the top of every PHP file.
- Code against abstract contracts (`AiServiceInterface`, `EmbeddingServiceInterface`) to enable swapping providers and mock testing.
- Return explicit types and typed DTOs from all service methods.

## 2. Directory Layout
- **AI Services**: `app/Services/Ai/` (LLM communication, prompt builders, tool executors).
- **Embeddings**: `app/Services/Embeddings/` (text chunking, vector generation).
- **DTOs**: `app/DTOs/` (typed request and response structures).
- **Jobs**: `app/Jobs/` (asynchronous embedding generation and index updates).

## 3. Never-List
- Never make synchronous LLM API calls during user-facing write mutations; dispatch to Redis queues.
03 / SKILLS & WORKFLOWS
01first-feature
SANDBOXED
02install-and-verify
SANDBOXED
03laravel-ai-features-core
SANDBOXED
04llm-structured-output
SANDBOXED
05pgvector-semantic-search
SANDBOXED
06prompt-injection-defense
SANDBOXED
04 / DESIGN TOKENS & COMPONENTS
Design Token Specification Standard Enforcement
color.brand #e85d26 (Orange status accent) Status lights, active tabs, focus rings, primary CTA
color.surface.dark #0A0A0B (Base) • #131316 (Raised) • #26262C (Hairline) Dark-first showcase theme, hairline borders, no shadows
font.family.ui Instrument Sans (14px base, tight scale) Small and dense dashboard typography, zero AI slop
focus.ring 2px #e85d26 outline, 2px offset Universal high-visibility focus ring, WCAG 2.2 AA compliant
05 / SECURITY SCANS & CI GATES
01 Gitleaks Secret Scanning
Scans commits, branches, and PRs for API keys & tokens ✓ ACTIVE
02 Semgrep AST Security Rules
Detects SQLi, CSRF omission, insecure deserialization ✓ ACTIVE
03 OWASP Automated Test Suite
Functional tests validating session fixation & XSS filtering ✓ ACTIVE
04 Static Type Checking
PHPStan Level 8 / Strict TypeScript compilation ✓ ACTIVE
06 / STEP-BY-STEP PROCEDURE
01

Clone and Inspect

Clone repository, navigate to kits/laravel-ai-features, and start container services via docker compose.

02

Anchor AI Agent

Feed the Agent Bootstrap Prompt into Claude Code, Cursor, Codex, or Copilot. Agent consumes native rules and skills.

03

Verify Security Gates

Run automated CI evaluation. Security scanners assert zero vulnerabilities before merging features to production.

SECTION 3 • INSTALLATION GUIDE

7-Part Installation & Setup Standard

✓ VERIFIED INSTALL

1. Prerequisites Table

Tool Minimum Version Check Command Where to Get
Docker Engine24.0+docker --versiondocker.com
Docker Composev2.20+docker compose versionBundled with Docker
Git2.40+git --versiongit-scm.com

2. Quickstart Execution

git clone https://github.com/Umar-444/Techtalks-stack-kits.git
cd Techtalks-stack-kits/kits/laravel-ai-features/starter
cp .env.example .env
docker compose up --build -d

3. Multi-Agent Rule Placement

Claude Code
CLAUDE.md
Cursor
.cursor/rules/*.mdc
Codex
CODEX.md / AGENTS.md
Copilot
copilot-instructions.md
Cline
.clinerules
Antigravity
.agents/rules/*.md

4. Post-Install Verification Probes

curl -s http://localhost:8000/healthz ✓ HTTP 200 OK
docker compose ps ✓ ALL SERVICES UP
SECTION 4 • FREQUENTLY ASKED QUESTIONS

Kit FAQ & Operational Details

14 QUESTIONS
How does PostgreSQL pgvector integrate with Eloquent in this Laravel kit? ↓

The kit defines an Eloquent model Document using a custom VectorCast attribute and a dedicated scopeCosineSimilarity() query builder method using the <=> operator, enabling native vector distance calculations in Eloquent without raw string concatenation.

How are structured outputs guaranteed from LLMs? ↓

The AiService utilizes JSON Schema definitions passed to the model's response_format parameter. The returned payload is then validated against typed PHP DTOs using Laravel's Validator before returning to the caller.

What defenses are in place against Prompt Injection and Jailbreaks? ↓

Input prompts are scanned against known adversarial patterns (instruction overrides, system prompt leak attempts, character smuggling), enclosed in explicit XML delimiters (...), and verified with canary token leak detection.

Can this kit run fully offline without third-party LLM APIs? ↓

Yes. The kit provides a MockAiProvider for offline development and testing, and includes configuration bridges to connect directly to local Ollama or vLLM instances via standard OpenAI-compatible endpoints.

What embedding dimensions and vector index types are supported? ↓

The default migration configures vector(1536) for OpenAI text-embedding-3-small, indexed with an HNSW (Hierarchical Navigable Small World) index for sub-millisecond nearest neighbor retrieval.

How does asynchronous document ingestion and embedding work? ↓

Large text documents are chunked and dispatched to Redis-backed Laravel Queues via ProcessDocumentEmbedding jobs, preventing HTTP request timeouts during embedding generation.

How is multi-tenant isolation enforced in semantic vector searches? ↓

Every vector query incorporates an explicit WHERE tenant_id = ? constraint within the Eloquent query scope, ensuring users can never retrieve vector embeddings belonging to other organizations.

Does the kit support Server-Sent Events (SSE) for streaming AI responses? ↓

Yes. The AiChatController exposes a streaming route using response()->stream() that flushes token chunks to the client with text/event-stream headers in real time.

What is the token consumption benchmark tier for this kit? ↓

The kit is benchmarked at Tier A (16,400 median build tokens) due to clean separation of AI service interfaces and reusable Eloquent pgvector scopes.

How are API rate limits and token budgets enforced? ↓

Laravel Redis rate limiters enforce sliding-window quotas per user ID, restricting both total requests per minute and cumulative daily completion token usage.

What PHP extensions are required for pgvector and AI workloads? ↓

The Dockerfile packages pdo_pgsql, mbstring, intl, bcmath, opcache, and phpredis, running strictly as non-root UID 10001:10001.

How are Pest architectural tests configured for AI services? ↓

Pest ArchTest asserts that all AI services declare strict types, implement dedicated contracts, and avoid any hardcoded API credentials or raw debug calls.

How does function/tool calling work in this kit? ↓

Tools are defined as standard PHP classes implementing an AiToolInterface with name, description, and jsonSchema() methods. The AiService automatically formats these into OpenAI tools declarations and dispatches matching calls.

What automated security scans run in CI for this kit? ↓

GitHub Actions executes Gitleaks for secret detection, Semgrep with OWASP Top 10 rules, and manifest schema validation before any production deployment.

eval-transcript • laravel-ai-features
GATES PASSED
$ aautomated test suite --kit laravel-ai-features
✓ 01-manifest-integrity ............. PASS
✓ 02-agent-dialects .................. PASS (6/6 compiled)
✓ 03-skills-sandbox .................. PASS (Sandboxed tools)
✓ 04-owasp-scanners .................. PASS (0 vulnerabilities)
✓ 05-runtime-smoke ................... PASS (HTTP 200 OK)
Ready for immediate agent execution with zero configuration.
AGENT BOOTSTRAP PROMPT

Paste this exact prompt into Claude Code, Cursor, Copilot, or Antigravity to anchor the agent in the kit's rules and invariants:

You are building with the Laravel 12/13 + AI Features (LLM Orchestration, Embeddings & RAG) kit. Adhere strictly to rules in CLAUDE.md / .cursor/rules, design tokens in DESIGN.md, and steps/agent-build-steps.md.