Quick Start

Get up and running with the Persona SDK in just a few minutes. This guide covers installation, basic usage, and your first persona generation.

Installation

npm install @jamesaphoenix/persona-sdk

Or using other package managers:

pnpm add @jamesaphoenix/persona-sdk
yarn add @jamesaphoenix/persona-sdk

Your First Persona

Create a basic persona with required attributes:

basic-persona.ts
1import { Persona } from '@jamesaphoenix/persona-sdk';
2
3// Create a persona with required attributes
4const persona = new Persona('Alice Johnson', {
5 age: 28,
6 occupation: 'UX Designer',
7 sex: 'female'
8});
9
10console.log(persona.toObject());
11// Output:
12// {
13// id: 'persona_1234567890_abcdef',
14// name: 'Alice Johnson',
15// attributes: {
16// age: 28,
17// occupation: 'UX Designer',
18// sex: 'female'
19// }
20// }

Adding Custom Attributes

Extend personas with any custom attributes you need:

custom-attributes.ts
1const persona = new Persona('Bob Wilson', {
2 age: 35,
3 occupation: 'Software Engineer',
4 sex: 'male',
5 // Custom attributes
6 salary: 95000,
7 skills: ['JavaScript', 'Python', 'React'],
8 location: 'San Francisco',
9 yearsExperience: 8,
10 isRemote: true,
11 hobbies: ['photography', 'hiking']
12});
13
14// Access attributes
15console.log(persona.age); // 35
16console.log(persona.attributes.salary); // 95000
17console.log(persona.attributes.skills); // ['JavaScript', 'Python', 'React']

Using the Builder Pattern

Use PersonaBuilder for a more fluent API:

builder-pattern.ts
1import { PersonaBuilder } from '@jamesaphoenix/persona-sdk';
2
3const persona = PersonaBuilder.create()
4 .withName('Sarah Chen')
5 .withAge(32)
6 .withOccupation('Product Manager')
7 .withSex('female')
8 .withAttribute('department', 'Engineering')
9 .withAttribute('teamSize', 12)
10 .withAttribute('budget', 500000)
11 .build();
12
13console.log(persona.getSummary());
14// "Sarah Chen is a 32-year-old Product Manager"

🎯 Next Steps