UTA DevHub
Guides

AI-Assisted Development Guide

Team-wide AI prompt templates and guidelines for consistent code generation

AI-Assisted Development Guide

Overview

This guide helps you leverage AI assistants effectively while maintaining our codebase's consistency. By using standardized prompts and following these guidelines, AI-generated code will seamlessly integrate with our existing patterns, making it indistinguishable from human-written code.

Why standardized prompts? AI assistants are powerful but need proper context. Our templates provide the exact context needed to generate code that follows our patterns, uses our conventions, and integrates perfectly with existing code.

Getting Started with AI Assistance

Quick Start Guide

  1. Choose the right template from our Core Prompt Templates below
  2. Fill in the placeholders with your specific requirements
  3. Review and refine the generated code against our standards
  4. Run validation before committing: npx tsc --noEmit && npm run lint

Time saver: Using our templates typically reduces development time by 40% while maintaining 100% standard compliance.

Core Prompt Templates

Feature Implementation Template

Use this template when implementing complete features:

Context: Working on UTA DevHub React Native application
Tech Stack: React Native, TypeScript, React Query, Zustand
Standards: Follow patterns in /docs/standards/
Architecture: Three-layer UI (foundation/patterns/business), Domain-driven design

Task: Implement [feature description]

Requirements:
- Must follow existing patterns in features/[similar-feature]
- Use established error handling from core/shared/errors
- Include tests matching team coverage standards (90%+)
- Documentation must include usage examples
- Follow our exact file placement rules (see decision tree)

Constraints:
- No new dependencies without ADR
- Must maintain backward compatibility
- Performance budget: [specific metrics]
- Use design tokens from core/shared/styles/

Example to follow:
[Reference similar implemented feature]

Pro tip: The more specific your examples, the better the output. Always reference a similar feature that already exists in your codebase.

Component Generation Template

For creating new UI components:

Generate a React Native component for UTA DevHub following these specifications:

Component: [ComponentName]
Purpose: [Brief description]
Type: [foundation | pattern | business | feature-specific]
Location: [exact folder path based on type]

Requirements:
1. Use TypeScript with strict mode
2. Include proper error boundaries
3. Follow our naming convention: PascalCase for components
4. Import design tokens from '@/core/shared/styles'
5. Use our standard loading/error states
6. Include comprehensive JSDoc documentation
7. Export through index.ts barrel file
8. Follow our exact component structure (see example)

Component Structure:
// 1. Imports (in our specific order)
// 2. Type definitions (interfaces, not types for objects)
// 3. Component function declaration (not arrow function)
// 4. Hooks in order: state, context, custom
// 5. Event handlers
// 6. Render
// 7. Styles using StyleSheet

Example Pattern:
[Include code snippet from similar component]

Hook Generation Template

For custom React hooks:

Generate a custom React hook for UTA DevHub:

Hook: use[HookName]
Purpose: [What it manages/provides]
Location: [domain hooks or shared hooks based on scope]

Requirements:
1. Follow our hook structure pattern
2. Use React Query for server state
3. Use Zustand for client state if needed
4. Include proper TypeScript types
5. Export consistent return object
6. Handle loading, error, and success states
7. Include JSDoc with usage examples

Return Object Pattern:
{
  // State
  data: T | undefined;
  // Status
  isLoading: boolean;
  error: Error | null;
  // Actions
  refetch: () => void;
  // Mutations if applicable
  create: (data: T) => Promise<void>;
}

Reference: See similar hooks in core/domains/*/hooks.ts

Test Generation Template

For comprehensive test coverage:

Generate comprehensive tests for [ComponentName] following UTA DevHub standards:

Test Requirements:
1. Use Jest and React Testing Library
2. File name: [ComponentName].test.tsx
3. Achieve 90%+ coverage minimum
4. Test happy path, error states, and edge cases
5. Mock API calls using our apiClient mock
6. Follow AAA pattern (Arrange, Act, Assert)
7. Include accessibility tests
8. Test user interactions thoroughly

Test Structure:
describe('[ComponentName]', () => {
  // Setup and mocks
  
  describe('Rendering', () => {
    // Initial render tests
  });
  
  describe('User Interactions', () => {
    // Click, type, etc.
  });
  
  describe('Error States', () => {
    // Error handling
  });
  
  describe('Edge Cases', () => {
    // Boundary conditions
  });
});

Reference: See [SimilarComponent].test.tsx for patterns

Specific Use Case Templates

API Integration Template

Creating consistent API integrations:

Create an API integration for [resource] in UTA DevHub:

Domain: [domain name]
Resource: [resource name]
Endpoints needed: [list CRUD operations]

Requirements:
1. Add to core/domains/[domain]/api.ts
2. Use our configured apiClient from core/api/client
3. Follow RESTful conventions
4. Include proper TypeScript types in types.ts
5. Create corresponding React Query hooks
6. Handle all error scenarios

API Function Pattern:
export const get[Resource] = async (id: string): Promise<[Resource]> => {
  return apiClient.get(`/[resources]/${id}`);
};

export const create[Resource] = async (data: Create[Resource]DTO): Promise<[Resource]> => {
  return apiClient.post('/[resources]', data);
};

Hook Pattern:
export function use[Resource](id: string) {
  return useQuery({
    queryKey: [domain]QueryKeys.[resource](id),
    queryFn: () => get[Resource](id),
    staleTime: 5 * 60 * 1000,
  });
}

Remember: Always group API functions by domain, not by HTTP method. This keeps related logic together and makes the codebase more navigable.

AI Tool Configuration

GitHub Copilot Settings

Create .github/copilot-instructions.md in your project:

# UTA DevHub Coding Standards for GitHub Copilot
 
## CRITICAL: File Organization
- UI Components: ui/foundation/, ui/patterns/, ui/business/
- Features: features/[feature-name]/
- Business Logic: core/domains/[domain]/
- Shared Code: core/shared/
- ALWAYS follow our decision tree for file placement
 
## Naming Conventions (STRICTLY ENFORCED)
- Components: PascalCase (UserProfile.tsx)
- Hooks: camelCase starting with 'use' (useUserData.ts)
- Utilities: camelCase (formatDate.ts)
- Types: PascalCase interfaces, no 'I' prefix
- Files: Match component/function name exactly
 
## Required Patterns
- Function declarations for components (no arrow functions)
- Interfaces for objects, types for unions/primitives
- React Query for ALL server state
- Zustand for client state (no useState for shared state)
- Design tokens for ALL styling (no hardcoded values)
 
## Import Order (EXACT)
1. React/React Native
2. Third-party libraries
3. Absolute imports with @/
4. Relative imports (same folder only)
 
## Never Generate
- Any TypeScript 'any' types
- Direct API calls (use domain hooks)
- Inline styles or magic numbers
- Arrow function components
- Console.log statements

VS Code Settings

Add to .vscode/settings.json:

{
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true,
    "source.organizeImports": true
  },
  "typescript.preferences.importModuleSpecifier": "non-relative",
  "typescript.preferences.includePackageJsonAutoImports": "off",
  "ai-assistant.prompts": {
    "component": "Use UTA DevHub component template",
    "hook": "Use UTA DevHub hook template",
    "test": "Use UTA DevHub test template"
  }
}

Code Review with AI

Use AI to help review code for compliance:

AI Review Prompt

Review this UTA DevHub code for compliance:

Code to review:
[paste code here]

Check for:
1. File placement - does it follow our decision tree?
2. Naming conventions - exact compliance required
3. Import order - must match our standard
4. TypeScript usage - no 'any', proper types
5. Pattern consistency - matches similar features?
6. Error handling - all paths covered?
7. Performance - unnecessary re-renders?
8. Tests - 90%+ coverage included?

Compare against:
- Feature Implementation Decision Tree
- TypeScript & React Patterns
- Common Pitfalls guide

Output format:
- ✅ Compliant areas
- ❌ Issues found (with fixes)
- 💡 Suggestions for improvement
- 📚 Documentation updates needed

Working with AI Effectively

Before Using AI

Preparation is key to good outputs:

  1. Identify the pattern - Find similar code in your codebase
  2. Prepare context - Gather relevant files and documentation
  3. Choose template - Select the appropriate prompt template
  4. Set constraints - Specify performance/compatibility requirements

Example: Before asking AI to create a new modal component, find an existing modal in your codebase to use as a reference pattern.

During AI Generation

Guide the AI for better results:

  1. Provide examples - Include similar implemented features
  2. Be specific - Vague prompts lead to inconsistent code
  3. Iterate - Refine output to match standards exactly
  4. Verify imports - AI often gets import paths wrong

Common issue: AI often uses arrow functions for components. Always convert to function declarations as per our standards.

After Generation

Validate and refine the output:

  1. Run checks - npx tsc --noEmit && npm run lint
  2. Compare patterns - Ensure consistency with existing code
  3. Update tests - AI-generated tests often need refinement
  4. Document decisions - Add comments for non-obvious choices

Quality check: Good AI-generated code should be indistinguishable from human-written code following our standards.

Common AI Mistakes to Fix

Be aware of these frequent AI errors:

Import Issues

// ❌ AI often generates
import Button from '@/ui/Button';
import { useState } from 'react';
 
// ✅ Fix to our standard
import React, { useState } from 'react';
import { Button } from '@/ui/foundation/Button';

Component Structure

// ❌ AI often generates
const MyComponent: React.FC<Props> = ({ prop1 }) => {
  // implementation
};
 
// ✅ Fix to our standard
export function MyComponent({ prop1 }: Props) {
  // implementation
}

State Management

// ❌ AI might suggest
const [users, setUsers] = useState([]);
useEffect(() => {
  fetch('/api/users').then(/*...*/);
}, []);
 
// ✅ Fix to use React Query
const { data: users = [] } = useUsers();

Type Definitions

// ❌ AI might use 'any' or weak types
const handleData = (data: any) => {
  // process data
};
 
// ✅ Always use specific types
interface UserData {
  id: string;
  name: string;
  email: string;
}
 
const handleData = (data: UserData) => {
  // process data
};

Metrics and Continuous Improvement

Track these metrics to improve AI assistance:

  1. Code Review Cycles: Should decrease as prompts improve
  2. Pattern Violations: Target zero violations in AI-generated code
  3. Generation Time: Should decrease as you refine templates
  4. Developer Satisfaction: Survey team on AI tool effectiveness

Success indicator: When AI-generated code passes code review on first submission, your templates are working perfectly!

Sharing Knowledge

Contributing Back

When you discover improvements:

  1. Update templates - Refine prompts based on experience
  2. Share patterns - Document new patterns that work well
  3. Report issues - Note where AI consistently struggles
  4. Train the team - Share tips in team meetings

Template Evolution

Our templates should evolve with:

  • New patterns we adopt
  • Lessons learned from AI outputs
  • Changes in our architecture
  • Feedback from the team