Implement Windsurf reference architecture with best-practice project layout. Use when designing new Windsurf integrations, reviewing project structure, or establishing architecture standards for...
Complete project architecture optimized for Windsurf AI. Covers workspace configuration, rules hierarchy, workflow organization, and team standardization patterns that maximize Cascade's effectiveness.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Windsurf Workspace β
β βββββββββββββββββ ββββββββββββββββββββββββββββββ β
β β .devin/rules/project.mdβ β .windsurf/ β β
β β (AI context) β β βββ rules/ (trigger rules)β β
β β β β βββ workflows/ (automation)β β
β β β β βββ settings.json β β
β βββββββββββββββββ ββββββββββββββββββββββββββββββ β
β βββββββββββββββββ ββββββββββββββββββββββββββββββ β
β β .codeiumignoreβ β ~/.codeium/ β β
β β (index rules) β β βββ global_rules.md β β
β β β β βββ windsurf/memories/ β β
β β β β βββ windsurf/mcp_config β β
β βββββββββββββββββ ββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Cascade AI Engine β
β βββββββββββββ βββββββββββββ βββββββββββββββββββ β
β β Super- β β Cascade β β Command β β
β β complete β β Write/Chatβ β (Inline Edit) β β
β β (Tab) β β (Cmd+L) β β (Cmd+I) β β
β βββββββββββββ βββββββββββββ βββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Context Layers β
β Rules > Memories > @Mentions > Open Files > Index β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Read to inspect only the repository files and configuration needed for the request.Grep to locate relevant settings, rules, logs, or code without broad collection.my-project/
βββ .devin/rules/project.md # AI context (stack, patterns, constraints)
βββ .codeiumignore # Indexing exclusions
βββ .windsurf/
β βββ settings.json # IDE settings (committed)
β βββ rules/
β β βββ testing.md # trigger: glob **/*.test.ts
β β βββ api-routes.md # trigger: glob src/routes/**
β β βββ security.md # trigger: model_decision
β β βββ migrations.md # trigger: manual
β βββ workflows/
β βββ new-feature.md # /new-feature
β βββ deploy-staging.md # /deploy-staging
β βββ review-pr.md # /review-pr
β βββ quality-check.md # /quality-check
βββ src/
β βββ routes/ # API route handlers
β βββ services/ # Business logic
β βββ repositories/ # Data access
β βββ types/ # Shared types
βββ tests/
β βββ fixtures/ # Test data factories
β βββ services/ # Service unit tests
βββ docs/
βββ architecture.md # Architecture decisions
# Priority order (highest to lowest):
rules_hierarchy:
1_global_rules:
path: ~/.codeium/windsurf/memories/global_rules.md
limit: 6000 chars
scope: All workspaces
use_for: "Personal coding preferences, universal standards"
2_workspace_rule:
path: .devin/rules/project.md (project root)
limit: 12000 chars
scope: Current workspace
use_for: "Project stack, architecture, conventions"
3_location_scoped_rules:
path: .devin/rules/*.md or AGENTS.md in subdirectories
limit: 12000 chars each
scope: Triggered by glob, model_decision, or manual
use_for: "File-type-specific patterns, conditional rules"
4_memories:
path: ~/.codeium/windsurf/memories/
scope: Workspace-specific (auto-generated)
use_for: "Decisions, discoveries (supplement, don't replace rules)"
# Total active chars: 12000 max (global + workspace rules combined)
# If exceeded: global rules take priority, workspace rules truncated
// .windsurf/settings.json (committed to git)
{
"codeium.indexing.excludePatterns": [
"node_modules/**", "dist/**", ".next/**",
"coverage/**", "*.min.js", "**/*.map"
],
"codeium.autocomplete.enable": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "biomejs.biome",
"typescript.tsdk": "node_modules/typescript/lib",
"files.associations": { "*.css": "tailwindcss" }
}
monorepo/
βββ .devin/rules/project.md # Shared conventions (brief)
βββ .codeiumignore # Broad exclusions
βββ apps/
β βββ web/
β β βββ .devin/rules/project.md # Next.js-specific rules
β βββ mobile/
β βββ .devin/rules/project.md # React Native rules
βββ packages/
β βββ api/
β β βββ .devin/rules/project.md # Express/Fastify rules
β βββ shared/
β βββ .devin/rules/project.md # Library conventions
βββ .windsurf/
βββ workflows/ # Cross-package workflows
# BEST PRACTICE: Open apps/web/ or packages/api/ directly
# NOT the monorepo root
# Cascade gets focused context per workspace window
## What to Pin in Cascade
Pin files that provide essential context:
- Type definition files (types/*.ts)
- Architecture decision records (docs/adr/)
- API schema files (openapi.yaml)
- Database schema (prisma/schema.prisma, drizzle/schema.ts)
How to pin:
- Click the pin icon next to a file in the Cascade context area
- Pinned files are always included in Cascade's context window
- Limit: pin 3-5 files max (more = diluted context)
Deliver a repository-grounded architecture showing Rules, AGENTS.md, Workflows, Skills, Hooks, MCP boundaries, ignore files, CI gates, ownership, and validation commands. Explain why each customization mechanism was chosen and how it activates.
| Issue | Cause | Solution |
|---|---|---|
| Cascade ignores project patterns | Missing/empty .devin/rules/project.md | Add stack and architecture details |
| Rules truncated | Over 12,000 combined chars | Split into workspace rules with triggers |
| Wrong patterns for file type | No glob-triggered rules | Add .devin/rules/ with glob triggers |
| Team inconsistency | No shared config | Commit .windsurf/ directory to git |
| Slow indexing in monorepo | Root workspace open | Open specific package/app directory |
# Project: Inventory API
Stack: TypeScript, Fastify, and PostgreSQL.
Testing: Run Vitest unit tests and the repository integration suite.
Conventions:
- Validate external input at the route boundary.
- Keep database access behind repository modules.
- Add or update a regression test with every bug fix.
Avoid:
- Writing secrets, production data, or generated output into source files.
- Bypassing protected migrations or deployment approval.
set -euo pipefail
echo "=== Windsurf Architecture Check ==="
echo "Rules: $([ -f .devin/rules/project.md ] && wc -c < .devin/rules/project.md || echo 'MISSING') chars"
echo "Ignore: $([ -f .codeiumignore ] && wc -l < .codeiumignore || echo 'MISSING') patterns"
echo "Rules dir: $(ls .devin/rules/ 2>/dev/null | wc -l || echo 0) files"
echo "Workflows: $(ls .windsurf/workflows/ 2>/dev/null | wc -l || echo 0) files"
Continue with windsurf-architecture-variants to adapt this baseline to monorepos, multi-service workspaces, polyglot stacks, and large organizations.