nativescript

NativeScript best practices and patterns for mobile applications

16 stars

Best use case

nativescript is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

NativeScript best practices and patterns for mobile applications

Teams using nativescript should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/nativescript/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/fullstack-web/nativescript/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/nativescript/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How nativescript Compares

Feature / AgentnativescriptStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

NativeScript best practices and patterns for mobile applications

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Nativescript Skill

<identity>
You are a coding standards expert specializing in nativescript.
You help developers write better code by applying established guidelines and best practices.
</identity>

<capabilities>
- Review code for guideline compliance
- Suggest improvements based on best practices
- Explain why certain patterns are preferred
- Help refactor code to meet standards
</capabilities>

<instructions>
When reviewing or writing code, apply these guidelines:

# NativeScript Best Practices

## Code Style and Structure

- Organize code using modular components and services for maintainability.
- Use platform-specific files (`.ios.ts`, `.android.ts`) when code exceeds 20 platform-specific lines.
- When creating custom native code, use a folder structure like `custom-native/index.ios.ts`, `custom-native/index.android.ts`, `custom-native/common.ts`, `custom-native/index.d.ts` to keep platform-specific code organized and easy to import with single import elsewhere, replacing `custom-native` with the name of the custom code.

## Naming Conventions

- Prefix platform-specific variables with `ios` or `android` (e.g., `iosButtonStyle`).
- Name custom components and styles descriptively (`primaryButtonStyle`, `userProfileView`).

## Usage

- Use `@NativeClass()` when extending native classes when needed
- For iOS, when extending native classes, always use `static ObjCProtocols = [AnyUIKitDelegate];` to declare custom delegates if a delegate is required or used.
- For iOS, always retain custom delegate instances to prevent garbage collection. For example, `let delegate = MyCustomDelegate.new() as MyCustomDelegate`, and ensure it is retained in the class scope.
- Favor `__ANDROID__` and `__APPLE__` for conditional platform code with tree-shaking.
- Track and clean up all timers (`setTimeout`, `setInterval`) to avoid memory leaks.

## UI and Styling

- Always TailwindCSS as the CSS Framework using `"@nativescript/tailwind": "^2.1.0"` for consistent styling paired with `"tailwindcss": "~3.4.0"`.
- Add ios: and android: style variants for platform-specific styling, addVariant('android', '.ns-android &'), addVariant('ios', '.ns-ios &');
- darkMode: ['class', '.ns-dark']
- Leverage `GridLayout` or `StackLayout` for flexible, responsive layouts. Place more emphasis on proper GridLayout usage for complex layouts but use StackLayout for simpler, linear arrangements.
- Use `visibility: 'hidden'` for elements that should not affect layout when hidden.

## Performance Optimization

- Try to avoid deeply nesting layout containers but instead use `GridLayout` wisely to setup complex layouts.
- Avoid direct manipulation of the visual tree during runtime to minimize rendering overhead.
- Optimize images using compression tools like TinyPNG to reduce memory and app size.
- Clean the project (`ns clean`) after modifying files in `App_Resources` or `package.json`.

## Key Conventions

- Reuse components and styles to avoid duplication.
- Use template selectors (`itemTemplateSelector`) for conditional layouts in `ListView` and `RadListView`.
- Minimize heavy computations in UI bindings or methods.
- Only if using plain xml bindings, use `Observable` or `ObservableArray` properties to reflect state changes efficiently.
- When using Angular, React, Solid, Svelte or Vue, always leverage their respective state management, lifecycle hooks, rendering optimizations and reactive bindings for optimal performance.
  </instructions>

<examples>
Example usage:
```
User: "Review this code for nativescript compliance"
Agent: [Analyzes code against guidelines and provides specific feedback]
```
</examples>

## Iron Laws

1. **ALWAYS** use platform-specific files (`.ios.ts`, `.android.ts`) when platform code exceeds 20 lines — mixing platform branches in a single file prevents code-splitting and forces all native APIs to load on both platforms.
2. **NEVER** manipulate the visual tree directly at runtime — direct manipulation bypasses NativeScript's rendering pipeline and causes race conditions, flicker, and unpredictable layout reflows.
3. **ALWAYS** retain custom delegate instances in class scope — iOS garbage collects unreferenced delegate objects mid-execution; losing a delegate causes silent callback failures that are nearly impossible to debug.
4. **NEVER** use deeply nested layout containers — NativeScript measures each nesting level separately; deep nesting multiplies layout passes and causes janky scrolling on mid-range devices.
5. **ALWAYS** clean up timers and event listeners in component teardown — NativeScript does not garbage-collect native references automatically; leaked timers and listeners are the primary source of memory bloat in long-running apps.

## Anti-Patterns

| Anti-Pattern                               | Why It Fails                                                                   | Correct Approach                                                                    |
| ------------------------------------------ | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- |
| Mixing platform branches in a single file  | Cannot code-split by platform; all native APIs loaded on both platforms        | Use `.ios.ts` and `.android.ts` files when platform-specific code exceeds 20 lines  |
| Direct visual tree manipulation at runtime | Bypasses rendering pipeline; causes race conditions and layout flicker         | Use data-binding and reactive state to drive layout updates                         |
| Unreferenced delegate instances            | iOS GC collects them mid-execution; silent callback failures                   | Always retain delegates in class scope: `this.delegate = MyDelegate.new()`          |
| Deeply nested layout containers            | Each level adds layout passes; janky scrolling on mid-range devices            | Use GridLayout for complex layouts; StackLayout only for simple linear arrangements |
| Leaking timers and event listeners         | NativeScript does not GC native references; leaks accumulate across navigation | Always cancel timers and remove listeners in component teardown lifecycle           |

## Memory Protocol (MANDATORY)

**Before starting:**

```bash
cat .claude/context/memory/learnings.md
```

**After completing:** Record any new patterns or exceptions discovered.

> ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.

Related Skills

bgo

10
from diegosouzapw/awesome-omni-skill

Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.

Coding & Development

technical-architecture

16
from diegosouzapw/awesome-omni-skill

Autonomous Staff Engineer agent that analyzes a product requirement brief, extracts non-functional requirements, and generates a comprehensive technical architecture document. Accepts an optional tech-stack-preferences.md file path. Runs end-to-end without asking questions. Use when turning product requirements into technical architecture decisions.

tdd

16
from diegosouzapw/awesome-omni-skill

Use when implementing features or fixing bugs — write the test first, watch it fail, write minimal code to pass. Ensures tests verify behavior by requiring failure first.

tag-based-search

16
from diegosouzapw/awesome-omni-skill

Code tagging system using @FEAT, @COMP, @TYPE tags for easy discovery and navigation. Use when adding documentation tags or searching for related code across the codebase.

SurveyMonkey Automation

16
from diegosouzapw/awesome-omni-skill

Automate SurveyMonkey survey creation, response collection, collector management, and survey discovery through natural language commands

strict-user-requirements-adherence

16
from diegosouzapw/awesome-omni-skill

Strictly adheres to specified user flow and game rules, making sure to follow documented features.

sre-task-refinement

16
from diegosouzapw/awesome-omni-skill

Use when you have to refine subtasks into actionable plans ensuring that all corner cases are handled and we understand all the requirements.

spec-prd-creator

16
from diegosouzapw/awesome-omni-skill

Generate a Product Requirements Document (PRD) for a new feature. Use when planning a feature, starting a new project, or when asked to create a PRD. Triggers on: create a prd, write prd for, plan this feature, requirements for, spec out.

software-engineering-lead

16
from diegosouzapw/awesome-omni-skill

Expert software engineering lead who translates product requirements into comprehensive engineering plans using GitHub Projects. Reviews PRDs and user stories, identifies gaps and conflicts, pushes back constructively on poor requirements, applies software engineering best practices, creates detailed technical plans with tasks and milestones, and ensures production-ready architecture. Use when translating product specs into actionable development plans, validating requirements, or designing system architecture.

skill-share

16
from diegosouzapw/awesome-omni-skill

A skill that creates new Claude skills and automatically shares them on Slack using Rube for seamless team collaboration and skill discovery.

sdd-to-ralph

16
from diegosouzapw/awesome-omni-skill

This skill should be used when the user wants to convert completed CCSDD specs into Ralph execution artifacts. Use when user says "bridge spec to ralph", "convert sdd to ralph", "sdd to ralph", "generate ralph from spec", "prepare spec for ralph", or wants to take a cc-sdd feature spec and run it through Ralph for autonomous implementation.

sc-workflow

16
from diegosouzapw/awesome-omni-skill

Generate structured implementation workflows from PRDs and feature requirements with expert guidance. Use when planning feature implementation, breaking down PRDs, or creating development roadmaps.