This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
hana-cli is a developer-centric CLI tool for SAP HANA database development with 183+ commands. It supports four operating modes: CLI, interactive menu, REST API server, and MCP server (for AI assistants). It runs on Node.js ≥20.19.0 and is a pure ESM project ("type": "module").
npm test # All tests (Mocha, 16 parallel jobs)
npm run test:cli # CLI command tests only
npm run test:utils # Utility tests only
npm run test:routes # Route/API tests only
npm run test:sequential # Non-parallel tests
npm run test:grep # Filter by test name
npm run test:e2e # End-to-end tests
npm run coverage # All tests with 80% threshold enforcement
npm run coverage:check # Check thresholds without re-running testsnpm run lint # ESLint
npm run lint:fix # Auto-fix
npm run types # Generate TypeScript declarations (.d.ts)# From docs/ subdirectory:
npm run docs:dev # VitePress dev server (localhost:5173)
npm run docs:build # Production buildnpm run validate:i18n # Validate i18n bundle completenessbin/— 183 CLI command files +cli.js(entry point with lazy loading),commandMap.js,commandMetadata.jsutils/— Core utilities:base.js(~2300 lines, core API),connections.js(connection resolution),database/(factory pattern),dbInspect.js,sqlInjection.js, and mass-operation helpersroutes/— Express REST API endpoints (served when runninghana-cli ui)mcp-server/src/— TypeScript MCP server (JSON-RPC over STDIO for AI tool use)app/— SAPUI5 web applications (Fiori Launchpad UI)_i18n/— i18n property files (en, de, es, fr, pt)tests/— Mocha test suite;helper.jsfor setup,appFactory.jsfor route testingdocs/— VitePress documentation site.github/instructions/— 25+ detailed development guides (authoritative reference for adding commands, routes, tests, etc.)
Database Abstraction (Factory Pattern)
utils/database/index.js selects between hanaDirect.js, hanaCDS.js, postgres.js, and sqlite.js based on environment profile. All commands go through this layer via utils/base.js.
Connection Resolution (6-step fallback)
utils/connections.js tries in order: default-env-admin.json (with --admin), .cdsrc-private.json (CAP dynamic binding), .env / VCAP_SERVICES, --conn parameter, default-env.json (current/parent dirs), ~/.hana-cli/default.json.
Lazy Loading for Performance
bin/cli.js defers heavy dependency imports until a command is actually invoked. --version and other fast-path commands bypass full initialization entirely (~60-77% startup improvement over v3).
Command Registration
Each bin/*.js file is a yargs command module. commandMap.js registers all commands dynamically; commandMetadata.js categorizes them into 16 groups.
i18n
All user-facing console output uses base.bundle.getText(key, [params]) backed by @sap/textbundle property files in _i18n/. Feature-specific strings go in separate property files (e.g., messages_dataProfile_en.properties).
Most commands share: --schema/-s (defaults to **CURRENT_SCHEMA**), --table/-t, --limit/-l, --output/-o (csv|json|table|excel), --dryRun/-dr, --admin/-a, --profile/-p (database profile), --debug/-d.
mcp-server/src/ exposes CLI commands as MCP tools for AI assistants. Build output goes to mcp-server/build/. It wraps the CLI's metadata from commandMetadata.js and executes commands via executor.ts.
- Test files:
tests/*.Test.js,tests/routes/*.Test.js,tests/utils/*.Test.js - Config:
tests/.mocharc.json(16 parallel jobs, 10s timeout) - Mocking:
sinon+esmockfor ESM mocking,mock-fsfor filesystem,supertestfor HTTP routes - Coverage threshold: 80% lines/functions/branches (enforced in CI via
npm run coverage:check) - Cross-platform CI: Windows/macOS/Ubuntu × Node 20/22/24 in
.github/workflows/cross-platform-tests.yml
Before adding a new command, route, or test, consult .github/instructions/ — it contains authoritative, detailed guides for every major development task:
cli-command-development.instructions.md— adding CLI commandstesting.instructions.md— test patterns and mockingroute-development.instructions.md— REST API endpointsmcp-server-development.instructions.md— MCP tool integrationi18n-translation-management.instructions.md— i18n patterns