betting-brain-v3 / rules
Cursor rule8 starsChanged 14 months agoMITView on GitHub
CI/CD integration patterns and automation
- Reads credentials
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,531 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository27 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .cursor/rules/99-floor.mdcCursor rule
- .cursor/rules/ai-friendly-testing.mdcCursor rule
- .cursor/rules/analytics-stub-api.mdcCursor rule
- .cursor/rules/analytics-testing.mdcCursor rule
- .cursor/rules/api-patterns.mdcCursor rule
- .cursor/rules/browser-extension.mdcCursor rule
- .cursor/rules/bun-runtime.mdcCursor rule
- .cursor/rules/cache-optimization.mdcCursor rule
- .cursor/rules/ci-patterns.mdcCursor rule
- .cursor/rules/cloudflare-infrastructure.mdcCursor rule
- .cursor/rules/cloudflare-workers.mdcCursor rule
- .cursor/rules/code-searchability.mdcCursor rule
- .cursor/rules/coverage-thresholds.mdcCursor rule
- .cursor/rules/database-patterns.mdcCursor rule
- .cursor/rules/documentation.mdcCursor rule
- .cursor/rules/endpoint-routing.mdcCursor rule
- .cursor/rules/file-naming.mdcCursor rule
- .cursor/rules/mcp-integration.mdcCursor rule
- .cursor/rules/process-management.mdcCursor rule
- .cursor/rules/production-security.mdcCursor rule
- .cursor/rules/quality-standards.mdcCursor rule
- .cursor/rules/root-organization.mdcCursor rule
- .cursor/rules/security-patterns.mdcCursor rule
- .cursor/rules/testing.mdcCursor rule
- .cursor/rules/testing-patterns.mdcCursor rule
- .cursor/rules/test-setup-patterns.mdcCursor rule
The file
We split this ci-integration.mdc into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 176
Use dual coverage thresholds
- Distinctive: line 178
Run nightly validation jobs
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
version: "1.1.0"
globs: "scripts/**/*.ts,.github/workflows/*.yml,package.json"
description: "CI/CD integration patterns and automation"
lastUpdated: "2025-10-08"
dependencies: ["quality-standards", "bun-runtime"]
---
# CI/CD Integration Rules
## Analytics Testing CI Patterns
### Main CI Pipeline
```typescript
// scripts/bun-ci.ts
private async runTests(): Promise<boolean> {
console.log('🧪 Running tests...');
// Enable AI-friendly output if in AI environment
if (this.isAIEnvironment()) {
console.log(' 🤖 AI environment detected - enabling quiet mode');
process.env.CLAUDECODE = '1';
}
// Run tests with coverage and randomization for analytics testing
return await this.runStep(
'Tests',
'bun',
['test', '--coverage', '--randomize', '--concurrent']
);
}
```
### Analytics-Specific CI
```json
{
"analytics:ci": "CI=true bun run analytics:test:coverage"
}
```
## Nightly Analytics Jobs
### GitHub Actions Workflow
```yaml
# .github/workflows/analytics-smoke.yml
name: analytics-smoke
on:
schedule: [cron: "0 12 * * *"]
jobs:
smoke:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install --frozen-lockfile
- run: wrangler deploy --dry-run
- run: bun test --test-name-pattern="analytics.*real"
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
NODE_ENV: staging
```
### Nightly Test Script
```typescript
// scripts/nightly-analytics-test.ts
export class NightlyAnalyticsTest {
async run(): Promise<boolean> {
console.log('🌙 Starting nightly analytics test...');
const dryRunResult = await this.runDryRunTests();
const smokeTestResult = await this.runSmokeTest();
return dryRunResult.success && smokeTestResult.success;
}
}
```
## Package.json Scripts
### Test Commands
```json
{
"test": "bun test --randomize",
"test:coverage": "bun test --coverage --randomize",
"analytics:test": "bun test tests/unit/analytics-testing-example.test.ts --randomize",
"analytics:test:coverage": "bun test --coverage --randomize tests/unit/analytics-testing-example.test.ts --config bunfig.analytics.toml",
"analytics:ci": "CI=true bun run analytics:test:coverage",
"analytics:nightly": "bun run scripts/nightly-analytics-test.ts",
"analytics:binding": "bun run scripts/test-analytics-binding.ts"
}
```
## Environment Detection
### AI Environment Detection
```typescript
private isAIEnvironment(): boolean {
return !!(
process.env.CLAUDECODE ||
process.env.REPL_ID ||
process.env.AGENT
);
}
```
### Quiet Mode for AI
```typescript
if (this.isAIEnvironment()) {
console.log(' 🤖 AI environment detected - enabling quiet mode');
process.env.CLAUDECODE = '1';
}
```
## Coverage Integration
### Dual Threshold System
- **Main CI**: Enforces 80% coverage threshold
- **Analytics CI**: Uses 0% coverage threshold
- **Nightly**: Validates both dry-run and real binding
### Coverage Commands
```bash
# Main suite - strict threshold
bun run test:coverage
# → exit 1 if < 80%
# Analytics suite - flexible threshold
bun run analytics:test:coverage
# → exit 0 (any coverage acceptable)
```
## Process Management
### Process Cleanup
```typescript
// Always use processManager for spawning
import processManager from './tests/utils/process-cleanup';
const proc = processManager.spawn(['command'], options);
```
### Timeout Handling
```typescript
// Set appropriate timeouts
const timeoutPromise = new Promise((_, reject) => {
setTimeout(() => reject(new Error('Timeout')), 5000);
});
```
## Error Handling
### CI Error Reporting
```typescript
try {
const result = await this.runStep('Tests', 'bun', ['test']);
return result;
} catch (error) {
console.error('❌ Test execution failed:', error);
return false;
}
```
### Exit Code Management
```typescript
// Analytics tests should exit 0
// Main tests should exit 1 if coverage < 80%
```
## Best Practices
### ✅ Do These
- Use dual coverage thresholds
- Enable AI-friendly output in CI
- Run nightly validation jobs
- Handle process cleanup properly
- Set appropriate timeouts
- Use environment detection
### ❌ Don't Do These
- Mix coverage thresholds
- Ignore process cleanup
- Skip nightly validation
- Use hardcoded paths
- Forget timeout handling
- Skip error reporting
## Related Rules
- [Analytics Testing](mdc:.cursor/rules/analytics-testing.mdc) - Core analytics testing patterns
- [Coverage Thresholds](mdc:.cursor/rules/coverage-thresholds.mdc) - Dual threshold system
- [Test Setup Patterns](mdc:.cursor/rules/test-setup-patterns.mdc) - Test configuration patterns
## Related Files
- [bun-ci.ts](mdc:scripts/bun-ci.ts) - Main CI pipeline
- [nightly-analytics-test.ts](mdc:scripts/nightly-analytics-test.ts) - Nightly validation
- [test-analytics-binding.ts](mdc:scripts/test-analytics-binding.ts) - Real binding test
- [analytics-smoke.yml](mdc:.github/workflows/analytics-smoke.yml) - Nightly workflow
- [package.json](mdc:package.json) - Script definitions
---
**Status:** Production Ready ✅
**Last Updated:** 2025-10-07
**Enforcement:** CI/CD Required
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

