Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    react native view architecture

    1

    Standardize React Native screens by separating JSX, logic, styling, and types into a strict four-file folder structure.

    Free

    1 useSecurity scanned
    react native view architecture

    react native view architecture

    Example session with this skill installed

    Refactor this Profile screen. It has inline styles, a direct setAge call, and checks if the user is a minor inside the JSX to show a warning. Use the folder architecture.

    • Read your context and instructions
    • Compiled the react native view
    • Generated the UI component

    I have refactored the Profile screen into the requested four-file architecture. The business logic for checking age status is now encapsulated in the viewmodel, and all styling has been moved to a dedicated styles file.

    Profile View Refactor

    // src/views/Profile/types.ts
    export type AgeStatus = 'minor' | 'adult';
    
    export interface ProfileProps {
      initialAge: number;
      userName: string;
    }
    
    // src/views/Profile/viewmodel.ts
    import { useState } from 'react';
    import { AgeStatus } from './types';
    
    export const useViewModel = ({ initialAge }: { initialAge: number }) => {
      const [age, setAge] = useState(initialAge);
    
      const ageStatus: AgeStatus = age < 18 ? 'minor' : 'adult';
      const ageLabel = `Age: ${age}`;
    
      return {
        ageLabel,
        ageStatus,
        showWarning: ageStatus === 'minor',
        onIncrementAge: () => setAge(prev => prev + 1),
      };
    };
    
    // src/views/Profile/styles.ts
    import { StyleSheet } from 'react-native';
    import { AgeStatus } from './types';
    
    export const styles = StyleSheet.create({
      container: { padding: 20, backgroundColor: '#fff' },
      warningText: { color: '#E11D48', fontWeight: 'bold' },
      normalText: { color: '#1F2937' }
    });
    
    export const getTextStyle = (status: AgeStatus) => 
      status === 'minor' ? styles.warningText : styles.normalText;
    
    // src/views/Profile/index.tsx
    import React from 'react';
    import { View, Text, Button } from 'react-native';
    import { useViewModel } from './viewmodel';
    import { styles, getTextStyle } from './styles';
    import { ProfileProps } from './types';
    
    export const ProfileView = (props: ProfileProps) => {
      const { ageLabel, ageStatus, showWarning, onIncrementAge } = useViewModel(props);
    
      return (
        <View style={styles.container}>
          <Text style={getTextStyle(ageStatus)}>{ageLabel}</Text>
          {showWarning && <Text style={styles.warningText}>Parental consent required</Text>}
          <Button title="Birthday" onPress={onIncrementAge} />
        </View>
      );
    };
    

    Next steps

    • Move any global User types used in this view to your shared src/types folder.
    • Add a renderHook test for viewmodel.ts to verify the ageStatus logic.
    • Update your navigation config to point to the new Profile/index.tsx.

    index.tsx

    TSX · React component

    Generated

    Example file from a real run - the skill writes it into your workspace.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Stop your agent from writing 400-line React Native screens that mix state, effects, decisions and inline styles in one file.

    This skill structures every screen as a folder of up to four files, each with one job:

    • index.tsx: JSX only. It renders what the viewmodel returns and decides nothing
    • styles.ts: styling only, with theme tokens and no inline styles anywhere else
    • viewmodel.ts: a useViewModel() hook with the state, effects and every decision
    • types.ts: the view's own types, only when there are any

    Where each line goes is a question, not a judgement call: does it decide WHAT the user sees, or HOW it looks?

    What's included

    • The rules for each file, with the reasoning behind them
    • A "where does this line go?" table for the cases that are easy to get wrong
    • "Actions, not setters": viewmodels expose onIncrement, never setQuantity, so the view can't write invalid state
    • A complete example view, all four files, that compiles under strict TypeScript
    • A step-by-step guide to split an existing large component into the four files without changing behavior
    • Rules for reusable components and a checklist before delivering

    Works with styled-components, StyleSheet or NativeWind. If your project already follows this pattern, the agent copies your exact conventions; if it doesn't, it asks before restructuring anything.

    Pairs with react-native-design: one decides how a screen looks, the other where each line of code lives.

    Free and open source (MIT): github.com/brunoviews/agent-skills

    Focuses only on view-layer organization. Does not handle navigation setup, global services, or shared state logic. Only creates types.ts if necessary.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    1 use

    Times used to date

    Free forever

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 1 month ago

    • Free with an Agensi account

    Permissions

    Read Files
    Write Files

    File Scopes

    **/*.{ts
    tsx}
    package.json

    Read files: the agent reads one existing view and package.json to copy the project's conventions (folder location, hook name, styling library) before creating anything. Write files: the agent creates or edits the four files of the view it is building or refactoring (index.tsx, styles.ts, viewmodel.ts, types.ts). It asks before restructuring a project that doesn't already use this architecture. No scripts, no network access, no environment variables.

    Listed1 month ago

    What's inside

    Frequently Asked Questions

    This skill fixes 'mega-file' bloat by automatically refactoring your React Native screens into a strict four-file structure: Index (UI), ViewModel (Logic), Styles (Layout), and Types (Definitions).

    It is fully compatible with any AI agent that has file-system access, and it supports all major styling libraries including StyleSheet, NativeWind, and styled-components.

    The skill generates a standardized screen folder containing the UI component, a custom hook for business logic, a dedicated style sheet, and a TypeScript contract file.

    Yes, the skill is designed to analyze existing 'spaghetti code' components and extract the logic and styles into the new architecture without breaking your existing functionality.

    This skill focuses exclusively on the View layer architecture; it does not manage global state (like Redux or Zustand) or handle React Navigation configurations.

    Simply provide the skill to your AI agent and point it toward a component or a folder; it will automatically detect your project's naming conventions and apply the architecture.

    New in Frontend & Web Apps