open source first
Prefer Open Source First (MANDATORY)
Moved from CLAUDE.md to reduce context size. Rules are mandatory.
Limit custom code; use open source tools. In Drupal: use api_normalization (OpenAPI import, gateway, Tools), ECA (flows), drupal/tool, key, http_client_manager, migrate_plus, ai/ai_agents. Do not build custom GitLab clients, validators, or ORMs. See AGENTS.md "Limit custom code, use open source tools (mandatory)".
Before building ANY custom solution:
- Search for existing solutions - GitHub/GitLab, npm, Packagist, Drupal.org
- Use official SDKs - Anthropic SDK, OpenAI SDK, GitLab SDK, Tailscale SDK
- Evaluate using scoring system - See wiki:
policies/tool-evaluation-checklist.md(80-point system) - NEVER build custom without approval - Lead Architect approval + GitLab issue required
Absolute Prohibitions (Zero Tolerance)
NEVER build custom implementations of:
- HTTP clients (use
axios,got,node-fetch) - Validation libraries (use
zod,joi,yup) - Auth/JWT handlers (use
jsonwebtoken,passport, official OAuth SDKs) - CLI frameworks (use
commander,yargs,oclif) - Testing frameworks (use
vitest,jest,playwright) - Logging libraries (use
winston,pino,bunyan) - Date/time libraries (use
date-fns,luxon,dayjs) - UUID generators (use
uuidpackage) - Crypto utilities (use Node.js
crypto,bcrypt) - File upload handlers (use
multer,formidable) - Email clients (use
nodemailer,sendgrid) - Database ORMs (use
prisma,drizzle,typeorm) - Cache clients (use
ioredis,node-cache)
Quick Reference: Use These, Don't Build Custom
| Need | Official Tool/SDK | Install Command |
|---|---|---|
| HTTP Client | axios, got | npm install axios |
| Validation | Zod (already in use) | npm install zod |
| Auth/JWT | jsonwebtoken | npm install jsonwebtoken |
| CLI Framework | commander | npm install commander |
| Testing | Vitest, Playwright | npm install vitest |
| Logging | winston, pino | npm install winston |
| LLM - Anthropic | @anthropic-ai/sdk | npm install @anthropic-ai/sdk |
| LLM - OpenAI | openai | npm install openai |
| GitLab API | @gitbeaker/rest | npm install @gitbeaker/rest |
| Tailscale API | tailscale-api (official) | npm install tailscale-api |
| MCP | @modelcontextprotocol/sdk | npm install @modelcontextprotocol/sdk |
| Docker | dockerode | npm install dockerode |
| Kubernetes | @kubernetes/client-node | npm install @kubernetes/client-node |
Decision Framework
Ask these questions BEFORE writing custom code:
-
Search Phase (MANDATORY):
- Searched npm registry for relevant packages
- Searched GitHub for existing implementations
- Checked official SDK availability
- Reviewed Drupal.org contrib (for Drupal)
- Checked @bluefly/* packages (for platform services)
-
Evaluation Phase (MANDATORY):
- Scored using tool-evaluation-checklist.md (80-point system)
- Tool scores <60 points? → STOP, do NOT use
- Tool scores 60-79? → Requires justification
- Tool scores 80+? → Approved for use
-
Approval Phase (if custom code needed):
- Created GitLab issue with justification
- Documented why existing tools don't work
- Lead Architect approved custom implementation
- Added justification docblock to custom code
AI Assistant Enforcement
AI assistants (Claude, Cursor, etc.) MUST:
- Suggest open source FIRST - Always search for existing solutions before suggesting custom code
- Provide reasoning - Explain why suggested tool is better than custom implementation
- Block custom code - Refuse to write custom implementations without GitLab issue + approval
- Use scoring system - Evaluate tools using 80-point checklist before suggesting
Drupal-Specific: Configuration > Code
CRITICAL for Drupal development:
- Configuration FIRST - Use YAML config files (
config/install/*.yml) - Contrib modules SECOND - Search Drupal.org for existing modules
- Recipes THIRD - Use Drupal recipes for reusable config patterns
- Custom PHP LAST RESORT - Only if above options don't work + approval
Enforcement Mechanisms
-
Pre-commit Hooks -
.lefthook.ymlblocks:- Custom HTTP clients (detects
class.*HttpClient,function.*fetch) - Custom validators (detects
class.*Validatorwithout Zod import) - Custom auth (detects
class.*Authwithout official SDK) - Drupal PHP without justification docblock
- Custom HTTP clients (detects
-
CI Pipeline Gate -
gitlab_components/templates/compliance-check.yml:- Runs
@bluefly/compliance-engine check-open-source-policy - Fails build if violations found
- Requires Lead Architect override to merge
- Runs
-
Code Review Checklist:
- No custom HTTP clients (use axios/got)
- No custom validation (use Zod)
- No custom auth (use official SDKs)
- All Drupal code justified (see drupal/README.md)
- All custom code has GitLab issue + approval
See Wiki:
policies/prefer-open-source-first.md- Complete policypolicies/build-vs-buy-decision-tree.md- Decision flowchartpolicies/tool-evaluation-checklist.md- 80-point scoring systempolicies/drupal-config-first-code-last.md- Drupal-specific rules