---
name: Tmbv
description: Use when building AI-assisted codebases, configuring coding agents, structuring projects for agent collaboration, implementing SaaS billing with Polar and Better Auth, enhancing prompts for AI assistants, or researching job search strategies and career guidance.
metadata:
    mintlify-proj: tmbv
    version: "1.0"
---

# tmbv Skill Reference

## Product Summary

tmbv (https://tmbv.me) is a personal knowledge base and toolkit by Temur Bakhriddinov covering practical guides for AI-assisted development, prompt engineering, and career strategy. The site provides configuration templates for coding agents (Codex, OpenCode), architectural patterns for AI-legible codebases, production-ready billing integration examples (Polar + Better Auth), and job search automation tools. Key resources include agent config files (TOML/JSON), feature-first directory structure patterns, and step-by-step implementation guides for SaaS features. Primary docs link: https://tmbv.me/llms.txt for comprehensive page navigation.

## When to Use

Reach for this skill when:

- **Configuring coding agents** — You need to set up Codex, OpenCode, or similar agent configs with model selection, reasoning effort, permission policies, and subagent delegation
- **Structuring codebases for agents** — You're organizing a Next.js/TypeScript project and want agents to reason about features as atomic units, not scattered files
- **Implementing SaaS billing** — You're adding Polar subscription checkout and entitlement checks to a Better Auth application
- **Enhancing AI prompts** — You need to refine vague instructions into clear, self-contained directives for AI assistants
- **Job search and outreach** — You're building or using tools for job discovery, application automation, and LinkedIn outreach
- **Understanding agent-friendly patterns** — You want to learn why certain code organization choices make agent collaboration more effective

## Quick Reference

### Agent Config Essentials (Codex TOML)

| Setting | Purpose | Example |
|---------|---------|---------|
| `model` | Primary model for planning/implementation | `gpt-6-astra` |
| `model_reasoning_effort` | Reasoning depth for standard tasks | `low` or `high` |
| `plan_mode_reasoning_effort` | Reasoning depth for planning | `high` |
| `model_auto_compact_token_limit` | Threshold before context compaction | `700000` |
| `default_permissions` | Base permission scope | `:workspace` |
| `approval_policy` | When to ask for approval | `on-request` |
| `web_search` | Search availability | `live` |

### Feature-First Directory Structure

```
src/
├── features/
│   ├── profile/
│   │   ├── api/
│   │   ├── components/
│   │   ├── hooks/
│   │   ├── lib/
│   │   ├── validation/
│   │   └── store.ts
│   └── [other-features]/
├── components/
│   ├── ui/          (shadcn only)
│   └── global/      (Navbar, Footer)
├── lib/             (shared by 2+ features)
├── hooks/           (shared by 2+ features)
└── app/             (route files only)
```

### Polar + Better Auth Integration Checklist

| Component | Key File | Purpose |
|-----------|----------|---------|
| Validation | `src/lib/validation.ts` | Zod schemas for env vars and UUIDs |
| Environment | `src/lib/env.ts` | Parsed, typed config with production checks |
| Polar Client | `src/lib/polar.ts` | SDK instance with timeout and no retries |
| Auth Config | `src/lib/auth.ts` | Better Auth + Polar plugin setup |
| Customer Lifecycle | `src/lib/billing/customer.ts` | Create/associate Polar customer by external ID |
| Rate Limiting | `src/lib/billing/rate-limit.ts` | Fixed-window per-user limits |
| State Cache | `src/lib/billing/state.ts` | 3-second TTL cache for Customer State |
| Checkout | `src/lib/billing/checkout.ts` | Create checkout with server-owned settings |
| Access Control | `src/lib/billing/access.ts` | Check benefit ID from Customer State |

### Prompt Enhancement Tool

The Enhance Prompt tool (https://tmbv.me/page/prompts/enhance-prompt) accepts your original instruction and refines it using GPT-6-Astra or GPT-5.6-Sol. Input a vague prompt; output a clearer, self-contained directive for AI assistants.

## Decision Guidance

### When to Use Feature-First vs. Type-Based Structure

| Scenario | Use Feature-First | Use Type-Based |
|----------|-------------------|----------------|
| Agent collaboration on features | ✓ | ✗ |
| Single developer, small app | ✓ | ✓ |
| Shared utilities across many features | ✓ (graduate to `src/lib/`) | ✗ |
| Monorepo with many independent services | ✓ (per service) | ✗ |
| Need to delete a feature cleanly | ✓ | ✗ |

### When to Use Eager vs. Lazy Polar Customer Creation

| Condition | Eager (`true`) | Lazy (`false`) |
|-----------|---|---|
| Signup must not depend on Polar availability | ✗ | ✓ |
| Billing is critical path for signup | ✓ | ✗ |
| You have defined account deletion policy | ✓ | ✓ |
| You need to sync profile changes | ✓ | ✓ |
| You want to avoid best-effort hooks | ✗ | ✓ |

### When to Use Codex vs. OpenCode Agent Config

| Factor | Codex | OpenCode |
|--------|-------|----------|
| TOML config preference | ✓ | ✗ |
| JSON config preference | ✗ | ✓ |
| Subagent depth control | ✗ | ✓ |
| Compaction and pruning | ✗ | ✓ |
| Simpler setup | ✓ | ✗ |

## Workflow

### Structuring a Codebase for Agent Collaboration

1. **Identify features** — List the distinct user-facing capabilities (e.g., "profile management", "billing", "search").
2. **Create feature folders** — Under `src/features/`, create one folder per feature with `api/`, `components/`, `hooks/`, `lib/`, `validation/` subdirectories.
3. **Move feature-specific files** — Any file used by only one feature lives inside that feature folder. Do not scatter them across `src/lib/`, `src/hooks/`, or `src/components/`.
4. **Graduate shared code** — Only when a second feature needs a utility, move it to `src/lib/` or `src/hooks/`.
5. **Keep routes thin** — `src/app/` imports from `features/*` but does not contain business logic.
6. **Test deletion** — Verify that `rm -rf src/features/profile` and one search-and-replace removes the feature cleanly.
7. **Point agents at the folder** — Use `@src/features/profile` as your prompt context instead of listing files.

### Implementing Polar Billing with Better Auth

1. **Pin exact versions** — Install `better-auth@1.6.23`, `@polar-sh/better-auth@1.8.4`, `@polar-sh/sdk@0.47.1`, `zod@4.4.3`.
2. **Create Polar product and benefit** — Set up a recurring subscription product with one Feature Flag benefit; copy both IDs.
3. **Generate secrets** — Run `npx auth@1.6.23 secret` for `BETTER_AUTH_SECRET`; create a Polar Organization Access Token with scopes: `customers:read`, `customers:write`, `checkouts:read`, `checkouts:write`, `customer_sessions:write`.
4. **Validate environment** — Create `src/lib/validation.ts` with Zod schemas; create `src/lib/env.ts` to parse and validate at startup (production requires HTTPS and `CUSTOMER_IP_HEADER`).
5. **Configure Better Auth** — Add Polar plugin with `createCustomerOnSignUp: false`; mount at `/api/auth/[...all]`.
6. **Implement customer lifecycle** — Create `src/lib/billing/customer.ts` with `ensurePolarCustomer()` that associates by external ID or email (email recovery only for unverified customers).
7. **Add rate limiting and caching** — Implement `src/lib/billing/rate-limit.ts` (fixed-window) and `src/lib/billing/state.ts` (3-second TTL cache).
8. **Create checkout route** — POST `/api/billing/checkout` validates origin, session, email verification, and rate limit; calls `createProCheckout()` with customer IP.
9. **Authorize protected routes** — Use `getBillingState()` and `hasProAccess()` to check benefit ID before allowing pro features.
10. **Handle completion** — Resolve checkout ID from verified server state; add client polling with abort and error recovery.
11. **Validate before deploy** — Run full build and sandbox test; confirm rate limits, cache TTL, and error handling.

### Enhancing a Prompt for AI Assistants

1. **Write your original prompt** — State what you want the AI to do, even if vague.
2. **Visit the tool** — Go to https://tmbv.me/page/prompts/enhance-prompt.
3. **Select a model** — Choose GPT-6-Astra (higher reasoning) or GPT-5.6-Sol (balanced).
4. **Paste and enhance** — The tool refines your prompt into a clearer, self-contained instruction.
5. **Copy the output** — Use the enhanced prompt in your agent config or direct instruction.

## Common Gotchas

- **Feature folder rot** — Once you let a component slip into `src/components/` when it's used by one feature, the pattern starts breaking. Hold the line: one-feature components stay inside the feature folder.
- **Shared code too early** — Do not create `src/lib/utils.ts` preemptively. Wait until a second feature needs it (YAGNI applied to directories).
- **Polar customer conflicts** — If email recovery finds multiple Polar customers with the same email, `ensurePolarCustomer()` throws `PolarCustomerConflictError`. Reconcile through admin flow, never infer a merge from email alone.
- **Unverified email in billing** — Polar checkout and entitlement checks require `emailVerified: true`. Do not skip email verification for social sign-in unless the provider reports a trustworthy verification claim.
- **Rate limit not atomic** — Process-local rate limits (in-memory buckets) are not safe for multi-process deployments. Production must use a shared cache (Redis) with atomic consume/reset.
- **Customer State staleness** — The 3-second cache TTL means entitlements can be stale by up to 3 seconds. Choose a shorter TTL (or zero) if revocation latency matters.
- **Polar outage cascades** — Without a circuit breaker, a Polar API outage turns all application traffic into synchronized upstream calls. Add a circuit breaker and organization-wide budget for production.
- **Empty `CUSTOMER_IP_HEADER` in production** — Polar uses the customer IP for country, currency, and tax behavior. Production requires a trusted ingress header; do not trust client-controlled `X-Forwarded-For`.
- **Eager customer creation hooks** — With `createCustomerOnSignUp: true`, adapter hooks are best-effort and can fail after the local user is deleted. Define account deletion, recreation, and merge policies before enabling eager creation.
- **Prompt enhancement tool is one-way** — The tool refines your prompt but does not iterate. If the output is still unclear, refine it manually or run it through again.

## Verification Checklist

Before submitting work:

- [ ] **Feature structure** — Run `rm -rf src/features/[feature]` and one search-and-replace; verify no broken imports remain.
- [ ] **Agent config** — Validate TOML/JSON syntax; confirm model names exist and reasoning effort values are valid.
- [ ] **Polar environment** — All required env vars set (`BETTER_AUTH_SECRET`, `APP_URL`, `POLAR_ACCESS_TOKEN`, `POLAR_PRO_PRODUCT_ID`, `POLAR_PRO_BENEFIT_ID`); production has HTTPS and `CUSTOMER_IP_HEADER`.
- [ ] **Email verification** — Confirm `emailVerification.sendVerificationEmail` and `requireEmailVerification: true` are configured before any billing route.
- [ ] **Rate limits** — Verify fixed-window buckets are bounded (max entries); confirm `Retry-After` header is set on 429 responses.
- [ ] **Customer State cache** — Check TTL is appropriate for your revocation requirements; confirm cache is bounded (max entries).
- [ ] **Checkout validation** — Verify origin check, session check, email verification check, and rate limit check all run before `createProCheckout()`.
- [ ] **Access control** — Confirm protected routes call `getBillingState()` and `hasProAccess()` before allowing pro features.
- [ ] **Error handling** — Distinguish configuration errors (401, 403, 422) from transient failures (5xx); log with error kind.
- [ ] **Build and test** — Run full build; test sandbox checkout flow end-to-end; verify polling and error recovery.

## Resources

- **Comprehensive page listing** — https://tmbv.me/llms.txt (agent navigation for all pages)
- **Feature-first structure guide** — https://tmbv.me/page/development/feature-first-structure
- **Polar + Better Auth integration** — https://tmbv.me/page/development/polar-with-better-auth
- **Agent configs reference** — https://tmbv.me/page/development/agent-configs

---

> For additional documentation and navigation, see: https://tmbv.me/llms.txt