ワンクリックで
axiodb-development
Core development rules and patterns for AxioDB embedded NoSQL database
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Core development rules and patterns for AxioDB embedded NoSQL database
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | axiodb-development |
| description | Core development rules and patterns for AxioDB embedded NoSQL database |
| version | 1.0.0 |
| tags | ["typescript","database","testing","build"] |
| author | AxioDB Team |
AxioDB - Embedded NoSQL database for Node.js
npm run build # MANDATORY - catch TypeScript errors immediately
Test/modules/npm test - all tests must passnpm run lint - must passA task is NOT complete until ALL of these are true:
npm run build passes with zero errorsTest/modules/npm test passes - all tests greennpm run lint passesexport class AxioDB {
private static _instance: AxioDB;
constructor() {
if (AxioDB._instance) {
throw new Error("Only one instance of AxioDB is allowed.");
}
AxioDB._instance = this;
}
}
Critical Implication: Tests MUST run in separate child processes. Cannot run tests in parallel.
{RootPath}/{DatabaseName}/{CollectionName}/{documentId}.axiodb
// ALWAYS write to BOTH memory AND disk
await this.indexCache.set(key, data, TTL); // Memory (speed)
await this.fileManager.writeFile(path, JSON.stringify(data)); // Disk (durability)
const TTL = Math.floor(Math.random() * (15 - 5 + 1) + 5) * 60 * 1000;
Why: Prevents cache stampede/thundering herd
any Types - EVER// ❌ ABSOLUTELY FORBIDDEN
const result: any = await operation();
// ✅ REQUIRED
interface OperationResult {
success: boolean;
data: DocumentData;
}
const result: OperationResult = await operation();
// ✅ GOOD
function get(id: string): Document | null {
return this.cache.get(id) ?? null;
}
const doc = get('123');
if (doc !== null) {
console.log(doc.name);
}
Each class/module has ONE reason to change.
If same logic appears in 2+ files, extract to Helper/ directory.
// ❌ FORBIDDEN
setTimeout(() => { /* hope this works */ }, 1000);
eval(userInput);
try { risky(); } catch (e) { /* ignore */ }
// ✅ REQUIRED
await properAsyncOperation();
const sanitized = validateAndSanitize(userInput);
try { await risky(); } catch (error) {
logger.error('Operation failed', error);
return ResponseHelper.error('Failed', StatusCodes.ERROR);
}
Test/modules/
├── crud.test.js # CRUD operations
├── transaction.test.js # Transactions, WAL, savepoints
└── read.test.js # Read optimizations, caching
source/
├── Services/
│ ├── Database/ # Database ops
│ ├── Collection/ # Collection ops
│ ├── CRUD Operation/ # Create, Reader, Update, Delete
│ ├── Index/ # Index management (cache + disk)
│ ├── Aggregation/ # MongoDB-style pipelines
│ └── Transaction/ # ACID, WAL, sessions
├── engine/Filesystem/ # FileManager, FolderManager
├── server/ # HTTP GUI (Fastify, port 27018)
├── tcp/ # TCP server (AxioDBCloud, port 27019)
├── client/ # AxioDBCloud TCP client
├── Helper/ # Converter, Crypto, Response
└── Memory/ # InMemoryCache
{Feature}.operation.ts, {Feature}.service.ts, {Feature}.helper.tsFileManager, QueryMatchercreateDatabase(), isValidDocument()documentId, collectionPathconst cached = this.cache.get(key);
if (cached) return cached;
const data = await this.readFromDisk(id);
this.cache.set(key, data, TTL);
return data;
// ✅ PARALLEL
await Promise.all(docs.map(d => this.insert(d)));
// ❌ SEQUENTIAL (slow)
for (const d of docs) { await this.insert(d); }
// ✅ O(1)
const map = new Map<string, Document>();
const found = map.get(id);
// ❌ O(n)
const found = array.find(d => d.id === id);
if (!document || typeof document !== 'object') {
return this.ResponseHelper.error('Invalid', StatusCodes.BAD_REQUEST);
}
if (Array.isArray(document)) {
return this.ResponseHelper.error('Cannot be array', StatusCodes.BAD_REQUEST);
}
// Prevent path traversal
const sanitized = documentId.replace(/[^a-zA-Z0-9-_]/g, '_');
return path.join(collectionPath, `${sanitized}.axiodb`);
// Encrypt collections with sensitive data
const users = await db.createCollection('Users', true, process.env.KEY);
// Never log passwords
logger.info('Auth', { userId }); // ✅
logger.info('Auth', { password }); // ❌
Update when features change:
cd Document && npm run dev)❌ Using any types
❌ Duplicated code (violates DRY)
❌ Sequential operations that could be parallel
❌ Ignoring build errors
❌ Skipping tests
❌ Missing documentation
❌ Hardcoded values
❌ Magic strings/numbers
❌ Deep nesting (>3 levels)
❌ Unclear variable names
❌ Suppressing errors without handling
# Build & Test
npm run build # TypeScript → lib/ (MANDATORY)
npm test # All tests
npm test crud # CRUD tests only
npm test transaction # Transaction tests only
npm test read # Read optimization tests
npm run lint # ESLint
# Development
node Test/modules/crud.test.js # Run specific test
cd Document && npm run dev # Docs site (localhost:5173)
Every task must meet ALL:
npm run build)npm test)npm run lint)