Automated summary
This skill lays out security best practices for TwinMind integrations: API key storage, environment variable configuration, webhook signature verification and encryption of sensitive data at rest.
Strengths
- Explicitly contrasts bad practice (hardcoded API keys) with environment variables or a secrets manager
- Ships an HMAC-SHA256 webhook verification using timing-safe comparison to prevent timing attacks
- Provides a working AES-256-GCM encryption example with IV and auth tag
- Also covers repo hygiene: committed .env.example and .gitignore rules for secrets
Limitations
- The decryption example is cut off in the SKILL.md and must be finished by the developer
- Only TypeScript/Node.js snippets are given, with no Python or Go equivalents
- Does not cover key rotation, IAM roles, or compliance requirements (GDPR, SOC2) beyond encryption
Use it when setting up or auditing a TwinMind integration and you need to secure keys, webhooks and stored meeting recordings.
Don't rely on it as the sole reference for a full compliance program or for integrations that don't use TwinMind.
Security analysis
SafeThe skill is purely defensive guidance: it recommends environment variables and secrets managers over hardcoded keys, shows HMAC webhook verification with timing-safe comparison, AES-256-GCM encryption at rest, and permission checks. There are no destructive commands, no data exfiltration, and no attempts to disable safety controls. Risk is limited to writing ordinary TypeScript files via Write/Edit.
- •No shell execution, network calls, or obfuscated payloads; tools limited to Read/Write/Edit
- •Contains an example placeholder API key ('tm_sk_abc123') used explicitly as a negative example, not a live credential
- •Encryption example stores the AES key in an environment variable rather than a KMS; acceptable but worth noting as a hardening opportunity
- •Timing-safe compare of hex HMACs can throw on length mismatch — a robustness bug, not a security hazard to the catalog
Examples
My TwinMind API key is hardcoded in our TypeScript client. Refactor it to load from environment variables with a clear error when missing, and add a .env.example plus .gitignore entries.Add Express middleware that verifies the x-twinmind-signature header on our TwinMind webhooks using HMAC-SHA256 and a timing-safe comparison.Write AES-256-GCM encrypt and decrypt helpers in TypeScript so we can store TwinMind meeting transcripts encrypted at rest.name: twinmind-security-basics description: | Implement security best practices for TwinMind integrations. Use when securing API keys, configuring privacy settings, or implementing data protection for meeting recordings. Trigger with phrases like "twinmind security", "secure twinmind", "twinmind privacy", "protect twinmind data", "twinmind api key security". allowed-tools: Read, Write, Edit version: 1.0.0 license: MIT author: Jeremy Longshore jeremy@intentsolutions.io
TwinMind Security Basics
Overview
Essential security practices for TwinMind integrations, focusing on API security, data privacy, and compliance.
Prerequisites
- TwinMind account configured
- Understanding of environment variables
- Basic security concepts
Instructions
Step 1: Secure API Key Management
// NEVER do this - hardcoded secrets
const TWINMIND_API_KEY = "tm_sk_abc123"; // BAD!
// DO this - use environment variables
const apiKey = process.env.TWINMIND_API_KEY;
if (!apiKey) {
throw new Error('TWINMIND_API_KEY environment variable required');
}
// Even better - use a secrets manager
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
async function getApiKey(): Promise<string> {
const client = new SecretManagerServiceClient();
const [version] = await client.accessSecretVersion({
name: 'projects/my-project/secrets/twinmind-api-key/versions/latest',
});
return version.payload?.data?.toString() || '';
}
Step 2: Environment Configuration
# .env file (gitignored)
TWINMIND_API_KEY=tm_sk_your_secret_key
TWINMIND_WEBHOOK_SECRET=whsec_your_webhook_secret
TWINMIND_ENCRYPTION_KEY=your_32_byte_encryption_key
# .env.example (committed to repo - no real values)
TWINMIND_API_KEY=tm_sk_xxx
TWINMIND_WEBHOOK_SECRET=whsec_xxx
TWINMIND_ENCRYPTION_KEY=xxx
# .gitignore
.env
.env.local
.env.*.local
*.pem
*.key
secrets/
Step 3: Validate Webhook Signatures
// src/twinmind/webhooks/verify.ts
import crypto from 'crypto';
export function verifyWebhookSignature(
payload: string | Buffer,
signature: string,
secret: string
): boolean {
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
const providedSignature = signature.replace('sha256=', '');
// Use timing-safe comparison to prevent timing attacks
return crypto.timingSafeEqual(
Buffer.from(expectedSignature),
Buffer.from(providedSignature)
);
}
// Express middleware
export function webhookMiddleware(req: Request, res: Response, next: NextFunction) {
const signature = req.headers['x-twinmind-signature'] as string;
const secret = process.env.TWINMIND_WEBHOOK_SECRET!;
if (!signature) {
return res.status(401).json({ error: 'Missing signature' });
}
const rawBody = (req as any).rawBody || JSON.stringify(req.body);
if (!verifyWebhookSignature(rawBody, signature, secret)) {
return res.status(401).json({ error: 'Invalid signature' });
}
next();
}
Step 4: Encrypt Sensitive Data at Rest
// src/twinmind/encryption.ts
import crypto from 'crypto';
const ALGORITHM = 'aes-256-gcm';
const IV_LENGTH = 16;
const TAG_LENGTH = 16;
export function encrypt(text: string, key: string): string {
const iv = crypto.randomBytes(IV_LENGTH);
const cipher = crypto.createCipheriv(
ALGORITHM,
Buffer.from(key, 'hex'),
iv
);
let encrypted = cipher.update(text, 'utf8', 'hex');
encrypted += cipher.final('hex');
const tag = cipher.getAuthTag();
// Return iv:tag:encrypted
return `${iv.toString('hex')}:${tag.toString('hex')}:${encrypted}`;
}
export function decrypt(encryptedData: string, key: string): string {
const [ivHex, tagHex, encrypted] = encryptedData.split(':');
const iv = Buffer.from(ivHex, 'hex');
const tag = Buffer.from(tagHex, 'hex');
const decipher = crypto.createDecipheriv(
ALGORITHM,
Buffer.from(key, 'hex'),
iv
);
decipher.setAuthTag(tag);
let decrypted = decipher.update(encrypted, 'hex', 'utf8');
decrypted += decipher.final('utf8');
return decrypted;
}
// Usage for storing transcripts
export function storeTranscript(transcript: string): string {
const key = process.env.TWINMIND_ENCRYPTION_KEY!;
return encrypt(transcript, key);
}
export function retrieveTranscript(encryptedTranscript: string): string {
const key = process.env.TWINMIND_ENCRYPTION_KEY!;
return decrypt(encryptedTranscript, key);
}
Step 5: Implement Access Control
// src/twinmind/auth/permissions.ts
export enum Permission {
READ_TRANSCRIPTS = 'transcripts:read',
WRITE_TRANSCRIPTS = 'transcripts:write',
DELETE_TRANSCRIPTS = 'transcripts:delete',
MANAGE_SETTINGS = 'settings:manage',
VIEW_ANALYTICS = 'analytics:view',
ADMIN = 'admin:*',
}
export interface User {
id: string;
email: string;
permissions: Permission[];
organizationId: string;
}
export function hasPermission(user: User, permission: Permission): boolean {
if (user.permissions.includes(Permission.ADMIN)) {
return true;
}
return user.permissions.includes(permission);
}
export function requirePermission(permission: Permission) {
return (req: Request, res: Response, next: NextFunction) => {
const user = req.user as User;
if (!user) {
return res.status(401).json({ error: 'Unauthorized' });
}
if (!hasPermission(user, permission)) {
return res.status(403).json({ error: 'Insufficient permissions' });
}
next();
};
}
// Usage in routes
app.get(
'/api/transcripts',
requirePermission(Permission.READ_TRANSCRIPTS),
getTranscripts
);
app.delete(
'/api/transcripts/:id',
requirePermission(Permission.DELETE_TRANSCRIPTS),
deleteTranscript
);
Step 6: Configure Privacy Settings
// src/twinmind/privacy.ts
export interface PrivacyConfig {
// Audio handling
storeAudio: boolean;
audioRetentionDays: number;
// Transcript handling
storeTranscripts: boolean;
transcriptRetentionDays: number;
encryptTranscripts: boolean;
// Processing
processLocally: boolean; // Use on-device processing when possible
// Sharing
allowSharing: boolean;
requireConsent: boolean;
// PII handling
redactPII: boolean;
piiPatterns: string[];
}
const defaultPrivacyConfig: PrivacyConfig = {
storeAudio: false, // TwinMind default - never store audio
audioRetentionDays: 0,
storeTranscripts: true,
transcriptRetentionDays: 90,
encryptTranscripts: true,
processLocally: true,
allowSharing: false,
requireConsent: true,
redactPII: true,
piiPatterns: [
'\\b\\d{3}-\\d{2}-\\d{4}\\b', // SSN
'\\b\\d{16}\\b', // Credit card
'\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b', // Email
],
};
export function redactPII(text: string, patterns: string[]): string {
let redacted = text;
for (const pattern of patterns) {
const regex = new RegExp(pattern, 'gi');
redacted = redacted.replace(regex, '[REDACTED]');
}
return redacted;
}
Step 7: Audit Logging
// src/twinmind/audit.ts
export interface AuditEvent {
timestamp: Date;
userId: string;
action: string;
resource: string;
resourceId?: string;
details?: Record<string, any>;
ipAddress?: string;
userAgent?: string;
}
export class AuditLogger {
private events: AuditEvent[] = [];
log(event: Omit<AuditEvent, 'timestamp'>): void {
const fullEvent: AuditEvent = {
...event,
timestamp: new Date(),
};
this.events.push(fullEvent);
this.persist(fullEvent);
// Log to console in development
if (process.env.NODE_ENV === 'development') {
console.log('[AUDIT]', JSON.stringify(fullEvent));
}
}
private async persist(event: AuditEvent): Promise<void> {
// Send to logging service (e.g., CloudWatch, Datadog)
// await logService.write(event);
}
async query(filters: Partial<AuditEvent>): Promise<AuditEvent[]> {
return this.events.filter(event => {
return Object.entries(filters).every(([key, value]) =>
event[key as keyof AuditEvent] === value
);
});
}
}
export const auditLogger = new AuditLogger();
// Usage
auditLogger.log({
userId: 'user_123',
action: 'TRANSCRIPT_ACCESSED',
resource: 'transcript',
resourceId: 'tr_abc123',
details: { method: 'GET', endpoint: '/api/transcripts/tr_abc123' },
});
Output
- Secure API key storage
- Webhook signature verification
- Data encryption at rest
- Access control implementation
- Privacy configuration
- Audit logging
Security Checklist
## Pre-Deployment Security Checklist
### API Security
- [ ] API keys stored in environment variables or secrets manager
- [ ] No hardcoded credentials in source code
- [ ] API key rotation process documented
- [ ] Rate limiting implemented
### Data Protection
- [ ] Transcripts encrypted at rest
- [ ] PII redaction enabled
- [ ] Data retention policies configured
- [ ] Backup encryption verified
### Authentication
- [ ] Webhook signatures verified
- [ ] JWT tokens validated properly
- [ ] Session timeout configured
- [ ] MFA enabled for admin accounts
### Access Control
- [ ] RBAC implemented
- [ ] Least privilege principle applied
- [ ] Regular permission audits scheduled
### Monitoring
- [ ] Audit logging enabled
- [ ] Failed auth attempts monitored
- [ ] Anomaly detection configured
- [ ] Incident response plan documented
Error Handling
| Scenario | Risk | Mitigation | |----------|------|------------| | API key exposed | Full account access | Rotate key immediately, audit logs | | Webhook unverified | Spoofed events | Always verify signatures | | PII leaked | Compliance violation | Enable redaction, encrypt data | | Unauthorized access | Data breach | Implement RBAC, audit logging |
TwinMind Privacy Features
TwinMind provides built-in privacy protection:
- No audio storage: Audio is processed in real-time and immediately deleted
- On-device processing: Transcription can run locally on device
- Encrypted backups: Optional cloud backups are encrypted
- Data residency: Choose data storage region (Enterprise)
- GDPR compliance: Data export and deletion support
Resources
Next Steps
For production deployment, see twinmind-prod-checklist.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/twinmind-security-basics-mm5t8c8z/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/twinmind-security-basics-mm5t8c8z' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/twinmind-security-basics-mm5t8c8z/download' --output '.skill-downloads/twinmind-security-basics-mm5t8c8z/SKILL.md.part' && mv '.skill-downloads/twinmind-security-basics-mm5t8c8z/SKILL.md.part' '.skill-downloads/twinmind-security-basics-mm5t8c8z/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Tools declared by the author (check availability in your agent): Read, Write, Edit
Original excerpt: Prerequisites
- TwinMind account configured
- Understanding of environment variables
- Basic security concepts
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/twinmind-security-basics-mm5t8c8z/SKILL.md' && test -s '.skill-downloads/twinmind-security-basics-mm5t8c8z/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/twinmind-security-basics' && cp -R '.skill-downloads/twinmind-security-basics-mm5t8c8z' '.claude/skills/twinmind-security-basics'Cursor
test -f '.skill-downloads/twinmind-security-basics-mm5t8c8z/SKILL.md' && test -s '.skill-downloads/twinmind-security-basics-mm5t8c8z/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/twinmind-security-basics' && cp -R '.skill-downloads/twinmind-security-basics-mm5t8c8z' '.cursor/skills/twinmind-security-basics'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/twinmind-security-basics-mm5t8c8z'openskills read 'twinmind-security-basics-mm5t8c8z'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/twinmind-security-basics-mm5t8c8z/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
DeFi AMM Security
Security
Security checklist for Solidity AMM contracts, liquidity pools, and swap flows. Covers reentrancy, donation attacks, oracle manipulation, slippage, and integer math.
Semgrep Rule Creator
Security
Creates custom Semgrep rules for detecting security vulnerabilities, bug patterns, and code patterns. Includes test-first methodology, taint mode support, and validation steps. Helps when building targeted static analysis detections.
Dev Toolbar Review Guide
Security
Safety rules for the dev toolbar, PostHog client, and feature flags. Use when reviewing changes to dev-tools and related files, covering environment guards, override cookies, and SSE stream safety.