Not loaded · from tec-knowledge-base
When writing tests for any TEC app — enforce TDD patterns, payment test setup (C-76 backend-first), coverage targets, and proper mock patterns for Pi SDK and gateway.
Claude Code won't load this skill
It ships in tec-knowledge-base at skills/, but Claude Code only loads skills/<name>/SKILL.md and folders listed under skills in plugin.json. Installing the plugin doesn't add it.
| Repo | Target | Critical Files |
|---|---|---|
| tec-auth (service) | ≥ 95% stmt, ≥ 92% branch | All auth flows |
| tec-auth (npm package) | ≥ 80% | getStoredUser, ssoRedirect, usePiAuth |
| tec-ecommerce | ≥ 60% | pi-payment.ts, BFF routes, useCart |
| tec-commerce | ≥ 60% | merchant auth, payment handler, order BFF |
| tec-assets | ≥ 60% | payment handler, asset BFF |
// ⚠️ ALWAYS mock /api/.../payment/create FIRST
// Without this, test gets 422 and throws before Pi.createPayment
const mockCreateSuccess = () =>
vi.spyOn(globalThis, 'fetch').mockImplementation(async (url) => {
const u = String(url);
if (u.includes('payment/create'))
return { ok: true, status: 200,
json: async () => ({ data: { id: 'internal-id' } }) } as Response;
if (u.includes('payment/approve'))
return { ok: true, status: 200, json: async () => ({}) } as Response;
if (u.includes('payment/complete'))
return { ok: true, status: 200,
json: async () => ({ success: true, status: 'completed', txid: 'tx-1' }) } as Response;
return { ok: false, status: 404, json: async () => ({}) } as Response;
});
// createU2APayment RESOLVES with PaymentResult — NEVER rejects
// Commerce-aligned pattern (all TEC apps)
// ✅ CORRECT:
const result = await createU2APayment(...);
expect(result.status).toBe('error');
expect(result.message).toBe('Pi SDK not ready');
// ❌ WRONG (old pattern — causes CI failure):
await expect(createU2APayment(...)).rejects.toThrow('...');
const setupPiWindow = (mockCreatePayment = vi.fn()) => {
(window as any).__TEC_PI_READY = true;
(window as any).Pi = {
authenticate: vi.fn().mockResolvedValue({}),
createPayment: mockCreatePayment,
};
return mockCreatePayment;
};
afterEach(() => {
delete (window as any).__TEC_PI_READY;
delete (window as any).Pi;
});
// Must cover all edge cases:
it('returns null when tec_user cookie missing', ...)
it('returns null when tec_user JSON is malformed', ...)
it('returns user when cookie is valid JSON', ...)
it('returns null when required fields missing', ...)
it('handles URL-encoded cookie value', ...)
// Test auth, CSRF, validation, gateway error, success
describe('POST /api/bff/payment/create', () => {
it('returns 401 when no tec_access_token cookie', ...)
it('returns 403 when CSRF cookie present but header mismatches', ...)
it('returns 400 when amount is not positive', ...)
it('returns 401 when tec_user cookie missing userId', ...)
it('returns 503 when gateway unreachable', ...)
it('returns gateway response on success', ...)
});
// ALWAYS test that merchantId never comes from request body
it('rejects when body.merchantId used instead of session', ...)
it('derives merchant from tec_user cookie', ...)
it('returns 401 when tec_user cookie missing', ...)
// vitest.config.ts
export default defineConfig({
test: {
environment: 'jsdom', // required for document.cookie
globals: true,
coverage: {
provider: 'v8',
reporter: ['text', 'json', 'html'],
thresholds: { statements: 60, branches: 60 },
},
},
});
What SKILL.md sets; muted values are Claude Code's defaults
16 skills in this plugin
/bff-patternsWhen writing or modifying any BFF route (/api/bff/*) in any TEC app — enforce BFF-first rule, createHandler pattern, auth cookie reading, CSRF protection, and proper gateway proxying./charter-advisorWhen working on any app within the TEC ecosystem — before modifying code, architecture, or CLAUDE.md — load the app's Institutional Charter (C-100→C-115 infra apps + C-124→C-131 user-layer apps) to understand its engineering authority, security model, and P0/P1/P2 gaps./community-marketingWhen building or growing the TEC community on Pi Network channels (Pi Chat, Pi Forum, Telegram, Discord) — apply community-first growth, ambassador programs, and trust-building frameworks.Other plugins' skills for the same job
Claude Code refuses to install this plugin
.claude-plugin/plugin.json: commands: Invalid input, agents.0: Invalid string: must start with "./", agents.0: Invalid string: must end with ".md", agents.1: Invalid string: must start with "./", agents.1: Invalid string: must end with ".md", agents.2: Invalid string: must start with "./", agents.2: Invalid string: must end with ".md", skills: Invalid input, author: Invalid input: expected object, received string
.claude-plugin/plugin.json: commands: Invalid input, agents.0: Invalid string: must start with "./", agents.0: Invalid string: must end with ".md", agents.1: Invalid string: must start with "./", agents.1: Invalid string: must end with ".md", agents.2: Invalid string: must start with "./", agents.2: Invalid string: must end with ".md", skills: Invalid input, author: Invalid input: expected object, received string
Checked against Claude Code 2.1.332's install rules. The listing below is what the repository ships; Claude Code cannot install it as published.