netalertx-code-standards
It enforces architectural patterns, database helper usage, and testing procedures while requiring implementation plans before coding.
Install
mkdir -p .claude/skills/netalertx-code-standards && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/4544" && unzip -o skill.zip -d .claude/skills/netalertx-code-standards && rm skill.zipInstalls to .claude/skills/netalertx-code-standards
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
NetAlertX coding standards and conventions. Use this when writing code, reviewing code, or implementing features.Key capabilities
- →Enforce architectural patterns and DRY principles
- →Validate and normalize MAC addresses
- →Manage database interactions via helper functions
- →Standardize time operations using UTC
- →Sanitize user input before storage
- →Reuse shared test mocks and factories
How it works
The skill enforces repository standards by requiring implementation plans, validating code against architectural patterns, and providing specific helper functions for database, time, and MAC address operations.
Inputs & outputs
When to use netalertx-code-standards
- →Reviewing code against repository standards
- →Implementing new features via helper functions
- →Creating new tests using shared mocks
- →Validating MAC addresses and timestamps
About this skill
Code Standards
- ask me to review before going to each next step (mention n step out of x) (AI only)
- before starting, prepare implementation plan (AI only)
- ask me to review it and ask any clarifying questions first
- add test creation as last step - follow repo architecture patterns - do not place in the root of
/test - code has to be maintainable, no duplicate code
- follow DRY principle - maintainability of code is more important than speed of implementation
- code files should be less than 500 LOC for better maintainability
- DB columns must not contain underscores, use camelCase instead (e.g., deviceInstanceId, not device_instance_id)
- treat DB as temporary storage for stats, long-term configuration should be stored in the
/configfolder, the/configfolder should allow you to restore most of your functionality (excluding historical data) - never access DB directly from application layers, always use helper functions in
server/db/db_helper.pyand implement new functionality in handlers (e.g.,DeviceInstanceinserver/models/device_instance.py) - always validate and normalize MAC addresses before writing to DB (use
normalize_macfromplugin_helper.py) - all subprocess calls must set explicit timeouts
- use
timeNowUTCfromutils.datetime_utilsfor all time-related operations and DB timestamps (store all timestamps in UTC) - use sanitizers from
server/helper.pyfor user input before storing in DB - reuse shared mocks and factories from
test/db_test_helpers.pyfor tests, never redefine them locally - use environment variables for runtime paths, never hardcode paths or use relative paths
- follow existing code style and structure, and ensure backward compatibility with existing installations when submitting PRs
- all code needs to be scalable to handle large networks with thousands of devices (10k+) without performance degradation
- no inline imports, all imports must be at the top of the file
File Length
Keep code files under 500 lines. Split larger files into modules.
DRY Principle
Do not re-implement functionality. Reuse existing methods or refactor to create shared methods.
Database Access
- Never access DB directly from application layers
- Use
server/db/db_helper.pyfunctions (e.g.,get_table_json) - Implement new functionality in handlers (e.g.,
DeviceInstanceinserver/models/device_instance.py)
MAC Address Handling
Always validate and normalize MACs before DB writes:
from plugin_helper import normalize_mac
mac = normalize_mac(raw_mac)
Subprocess Safety
MANDATORY: All subprocess calls must set explicit timeouts.
result = subprocess.run(cmd, timeout=60) # Minimum 60s
Nested subprocess calls need their own timeout—outer timeout won't save you.
Time Utilities
from utils.datetime_utils import timeNowUTC
timestamp = timeNowUTC()
This is the ONLY function that calls datetime.datetime.now() in the entire codebase.
⚠️ CRITICAL: ALL database timestamps MUST be stored in UTC This is the SINGLE SOURCE OF TRUTH for current time in NetAlertX Use timeNowUTC() for DB writes (returns UTC string by default) Use timeNowUTC(as_string=False) for datetime operations (scheduling, comparisons, logging)
String Sanitization
Use sanitizers from server/helper.py before storing user input. MAC addresses are always lowercased and normalized. IP addresses should be validated.
Devcontainer Constraints
- Never
chmodorchownduring operations - Everything is already writable
- If permissions needed, fix
.devcontainer/scripts/setup.sh
Test Helpers — No Duplicate Mocks
Reuse shared mocks and factories from test/db_test_helpers.py. Never redefine DummyDB, make_db, or inline DDL in individual test files.
import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from db_test_helpers import make_db, DummyDB, insert_device, minutes_ago
If a helper you need doesn't exist yet, add it to db_test_helpers.py — not locally in the test file.
Path Hygiene
- Use environment variables for runtime paths
/datafor persistent config/db/tmpfor runtime logs/api/nginx state- Never hardcode
/data/dbor use relative paths
When not to use it
- →When implementing logic that requires direct database access
- →When creating tests that require custom, non-shared mocks
Limitations
- →Code files must remain under 500 lines
- →Database columns must use camelCase instead of underscores
- →Subprocess calls must include explicit timeouts
How it compares
Unlike manual coding, this skill mandates specific helper usage and architectural constraints to ensure maintainability and scalability across large networks.
Compared to similar skills
netalertx-code-standards side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| netalertx-code-standards (this skill) | 1 | 2mo | Review | Intermediate |
| property-based-testing | 1 | 2mo | No flags | Advanced |
| review-implementation | 0 | 5mo | Review | Intermediate |
| test | 0 | 1mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by netalertx
View all by netalertx →You might also like
property-based-testing
trailofbits
Provides guidance for property-based testing across multiple languages and smart contracts. Use when writing tests, reviewing code with serialization/validation/parsing patterns, designing features, or when property-based testing would provide stronger coverage than example-based tests.
review-implementation
karrioapi
Perform a fresh-context review of completed work against PRD, tests, and conventions.
test
FalkorDB
Run FalkorDB's test suites - Rust unit tests, Python e2e/function/MVCC/concurrency tests, openCypher TCK compliance tests, and flow tests. Use when asked to run, narrow down, or debug a failing test, or to decide which suite covers a change.
caching-strategies
dadbodgeoff
Implement multi-layer caching with Redis, in-memory, and HTTP caching. Covers cache invalidation, stampede prevention, and cache-aside patterns.
api-test-generator
mikopbx
Генерация полных Python pytest тестов для REST API эндпоинтов с валидацией схемы. Использовать при создании тестов для новых эндпоинтов, добавлении покрытия для CRUD операций или валидации соответствия API с OpenAPI схемами.
moai-domain-backend
modu-ai
Backend development specialist covering API design, database integration, microservices architecture, and modern backend patterns.