<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sathish Paramasivam on Medium]]></title>
        <description><![CDATA[Stories by Sathish Paramasivam on Medium]]></description>
        <link>https://medium.com/@sathishparamasivam?source=rss-7373a5770278------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YB0xmimDrJrLGqO4</url>
            <title>Stories by Sathish Paramasivam on Medium</title>
            <link>https://medium.com/@sathishparamasivam?source=rss-7373a5770278------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 22:30:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sathishparamasivam/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building an AI-Ready Playwright CLI Workspace with Claude Code — Step 1]]></title>
            <link>https://medium.com/@sathishparamasivam/building-an-ai-ready-playwright-cli-workspace-with-claude-code-step-1-f2b0f146c51e?source=rss-7373a5770278------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2b0f146c51e</guid>
            <dc:creator><![CDATA[Sathish Paramasivam]]></dc:creator>
            <pubDate>Fri, 07 Aug 2026 12:29:03 GMT</pubDate>
            <atom:updated>2026-08-07T12:29:03.213Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>From an empty Node.js workspace to an AI-assisted browser automation foundation — understanding Playwright CLI, Playwright Test, Skills, TypeScript, and Claude Code</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*Pi4IFaOSBuUftE7K.png" /></figure><p>Modern web automation is moving beyond traditional test scripts. With AI coding agents such as Claude Code, developers can explore applications, inspect UI elements, generate automation code, and evolve test suites through natural-language interaction. However, making this workflow reliable requires more than installing Playwright — it requires a well-structured project workspace and a clear separation between browser exploration, test execution, and AI-agent guidance.</p><p>In this article, I will walk through <strong>Step 1: creating an AI-ready Playwright CLI project workspace from scratch</strong> using <strong>Playwright CLI, Playwright Skills, Claude Code, Playwright Test, and TypeScript</strong>.</p><p>The focus is not on building business-specific test scenarios yet. Instead, the goal is to establish a clean and scalable foundation that can later support complex end-to-end automation.</p><p>The article will also explain the reasoning behind commands such as npm init -ylocal development dependencies, Playwright browser installation, and Playwright Skills installation rather than simply presenting a list of commands to copy and paste.</p><p>A key theme will be understanding the difference between <strong>global tooling and project-local dependencies</strong>. The workspace will be designed so that the AI tools can be reused across projects while the test framework and project dependencies remain version-controlled and reproducible.</p><p>Before creating the project, it is important to understand what we are actually building.</p><p>The goal is not simply to install Playwright and write a few test scripts. The objective is to create an <strong>AI-ready browser automation workspace</strong> where an AI coding agent can interact with a web application, understand the application structure, and help us build maintainable Playwright tests.</p><p>The core components are</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-84BE6jjbje-J_ShKH9s7A.png" /></figure><h3><strong>1. Claude Code</strong></h3><p>Claude Code is the <strong>AI coding agent</strong>.</p><p>It can work with the project files, understand instructions, execute commands, and use browser automation capabilities to help develop the automation.</p><p>We invoke it with:</p><pre>claude</pre><p>Claude Code is installed globally because it is a developer tool that we may use across multiple projects.</p><h3>2. Playwright CLI</h3><p>Playwright CLI provides a command-line interface for interacting with browsers.</p><p>For example:</p><pre>playwright-cli open</pre><p>and:</p><pre><br>playwright-cli snapshot</pre><p>The CLI can be used for activities such as:</p><ul><li>Opening browser sessions</li><li>Navigating applications</li><li>Inspecting pages</li><li>Interacting with elements</li><li>Capturing screenshots</li><li>Exploring application behavior</li><li>Supporting AI-assisted browser workflows</li></ul><p>The important point is that <strong>Playwright CLI is not the same thing as Playwright Test</strong>.</p><h3>3. Playwright Test</h3><p>Playwright Test is the framework we use to build and execute repeatable automated tests.</p><p>It provides capabilities such as:</p><ul><li>Test cases</li><li>Assertions</li><li>Fixtures</li><li>Hooks</li><li>Configuration</li><li>Retries</li><li>Screenshots</li><li>Videos</li><li>Traces</li><li>Test reports</li><li>Parallel execution</li></ul><p>Tests will eventually be executed using:</p><pre>npx playwright test</pre><p>For this reason, Playwright Test will be installed <strong>locally inside the project</strong>.</p><h3>Global vs Local Installation</h3><p>One of the most important concepts in this setup is understanding what should be installed globally and what should belong to the project.</p><p>The approach used in this workspace is:</p><pre>GLOBAL TOOLS<br><br>Claude Code<br>     │<br>     └── claude<br>Playwright CLI<br>     │<br>     └── playwright-cli</pre><pre>PROJECT-LOCAL DEPENDENCIES<br>────────────────────────────<br><br>Playwright Test<br>TypeScript<br>Node.js type definitions<br><br><br>PROJECT CONFIGURATION<br>────────────────────────────<br><br>Playwright Skills<br>Claude instructions<br>Playwright configuration<br>TypeScript configuration</pre><p>The reason for this separation is simple.</p><p><strong>Developer tools</strong> can be reused across projects, while <strong>project dependencies</strong> should be version-controlled and isolated for each project.</p><p>For example:</p><pre>Project A<br>└── @playwright/test version X<br><br>Project B<br>└── @playwright/test version Y</pre><p>Each project can therefore use the version it requires without depending on a single globally installed test framework.</p><h3>Why Start With Architecture?</h3><p>It is tempting to run immediately:</p><pre>npm install ...</pre><p>and start writing tests.</p><p>However, an AI-assisted automation project has additional considerations.</p><p>We need to understand:</p><pre>Who controls the browser?<br>        │<br>        ▼<br>Playwright CLI</pre><pre>Who helps us build the automation?<br>        │<br>        ▼<br>Claude Code</pre><pre>Who executes the automated tests?<br>        │<br>        ▼<br>Playwright Test</pre><pre>Where should project dependencies live?<br>        │<br>        ▼<br>Local node_modules</pre><pre>Where should reusable AI tooling live?<br>        │<br>        ▼<br>Global CLI tools</pre><p>This separation becomes increasingly important as the project grows.</p><p>The first step, therefore, is not installation.</p><p>It is <strong>establishing the architecture and responsibilities of each component</strong>.</p><h3>Step 2 — Verify the Global Tooling</h3><p>Before creating the project, let’s verify that the global tools required for the AI-assisted workflow are available.</p><p>In my environment, the two primary global tools are:</p><pre>Claude Code<br>Playwright CLI</pre><h3>Check Claude Code</h3><p>Run:</p><pre>claude --version</pre><p>This verifies that the Claude Code command is available in the terminal.</p><p>We can also find the executable location:</p><pre>which claude</pre><p>For example, with an NVM-managed Node.js installation, the result may look similar to:</p><pre>/Users/i18n/.nvm/versions/node/v20.x.x/bin/claude</pre><p>The exact path will vary depending on the Node.js installation.</p><h3>Check Playwright CLI</h3><p>Run:</p><pre>playwright-cli --version</pre><p>This verifies that Playwright CLI is installed and available.</p><p>We can find its executable using:</p><pre>which playwright-cli</pre><p>Again, with NVM the path may look similar to:</p><pre>/Users/i18n/.nvm/versions/node/v20.x.x/bin/playwright-cli</pre><h3>Check Global npm Packages</h3><p>To see which packages are installed globally:</p><pre>npm list -g --depth=0</pre><p>A typical setup may contain:</p><pre>@anthropic-ai/claude-code<br>@playwright/cli<br>corepack<br>npm</pre><p>The exact list depends on the machine.</p><p>The important packages for this project are:</p><pre>@anthropic-ai/claude-code<br>@playwright/cli</pre><h3>Why Are These Global?</h3><p>The -g option in npm means <strong>global installation</strong>.</p><p>For example:</p><pre>npm install -g @playwright/cli@latest</pre><p>The package is installed into the global npm environment rather than the current project.</p><p>An important detail is that the current directory does not change the meaning of -g.</p><p>For example:</p><pre>cd /Users/i18n/development/pw-cli/demopw1</pre><pre>npm install -g @playwright/cli@latest</pre><p>Even though the terminal is currently insidedemopw1, the package is still installed globally.</p><p>The -g flag controls the installation scope.</p><h3>Global vs Local: A Simple Example</h3><p>Consider these two commands:</p><pre>npm install -g @playwright/cli</pre><p>and:</p><pre>npm install -D @playwright/test</pre><p>They have very different meanings.</p><h3>Global</h3><pre>npm install -g @playwright/cli</pre><p>means:</p><pre>Install Playwright CLI globally<br>        │<br>        ▼<br>Available from multiple projects</pre><h3>Local</h3><pre>npm install -D @playwright/test</pre><p>means:</p><pre>Install Playwright Test<br>        │<br>        ▼<br>Current project only<br>        │<br>        ▼<br>demopw1/node_modules/</pre><p>This distinction will be used throughout the rest of the project setup.</p><h3>Verify the Current Environment</h3><p>Before moving forward, the following commands provide a useful baseline:</p><pre>node --version<br>npm --version<br>claude --version<br>playwright-cli --version<br>which claude<br>which playwright-cli<br>npm list -g --depth=0</pre><p>These commands answer seven basic questions:</p><p>CommandPurposenode --versionIs Node.js available?npm --versionIs npm available?claude --versionIs Claude Code available?playwright-cli --versionIs Playwright CLI available?which claudeWhere is Claude Code installed?which playwright-cliWhere is Playwright CLI installed?npm list -g --depth=0What npm packages are installed globally?</p><p>If these commands work, the machine-level prerequisites are ready.</p><p>We can now move from <strong>global tooling</strong> to the <strong>project workspace</strong>.</p><h3>Important: Do Not Reinstall What Already Exists</h3><p>If Playwright CLI is already available:</p><pre>playwright-cli --version</pre><p>there is no need to install another copy locally simply because we are creating a new project.</p><p>Likewise, if Claude Code is already installed and available through:</p><pre>claude --version</pre><p>we can reuse the existing installation.</p><p>This keeps the environment clean and avoids unnecessary duplicate installations.</p><p>The next step is therefore to create the actual Node.js project:</p><pre>/Users/i18n/development/pw-cli/demopw1</pre><p>That brings us to the next stage: <strong>initializing the project with </strong><strong>npm init -y and understanding what </strong><strong>package.json actually does.</strong></p><p>Great. Based on your finalized <strong>Step 1 and Step 2</strong>, the next section should be <strong>Step 3 — Create the Node.js Project Workspace</strong>. This is where we move from machine-level tooling into the actual demopw1 project.</p><h3>Step 3 — Create the Node.js Project Workspace</h3><p>Now that the global tooling has been verified, the next step is to create the actual project workspace.</p><p>For this article, the project is created at:</p><pre>/Users/i18n/development/pw-cli/demopw1</pre><p>At this point, the directory is intentionally empty. We have not installed Playwright Test, TypeScript, or any project-specific dependency yet.</p><p>The purpose of this step is to turn the empty directory into a <strong>Node.js project</strong>.</p><h3>3.1 Navigate to the Project Directory</h3><p>Open the terminal and navigate to the project workspace:</p><pre>cd /Users/i18n/development/pw-cli/demopw1</pre><p>The cd command means <strong>change directory</strong>.</p><p>We can verify the current location using:</p><pre>pwd</pre><p>The expected output is:</p><pre>/Users/i18n/development/pw-cli/demopw1</pre><p>We can also check the contents:</p><pre>ls -la</pre><p>Initially, the directory may contain only:</p><pre>.<br>..</pre><p>This confirms that we are starting with a clean workspace.</p><h3>3.2 Initialize the Node.js Project</h3><p>Run:</p><pre>npm init -y</pre><p>This is one of the most important commands in the initial project setup.</p><p>Let’s understand what it means.</p><h3>What is npm?</h3><p>npm stands for <strong>Node Package Manager</strong>.</p><p>It is commonly used to:</p><ul><li>Install Node.js packages</li><li>Manage project dependencies</li><li>Define project scripts</li><li>Track package versions</li><li>Reproduce project environments</li></ul><p>For our project, npm will manage dependencies such as:</p><pre>@playwright/test<br>typescript<br>@types/node</pre><h3>3.3 What Does npm init Do?</h3><p>The init command means <strong>initialize</strong>.</p><p>Therefore:</p><pre>npm init</pre><p>means:</p><blockquote><em>Initialize a new Node.js project in the current directory.</em></blockquote><p>Normally, npm asks several questions:</p><pre>package name:<br>version:<br>description:<br>entry point:<br>test command:<br>git repository:<br>keywords:<br>author:<br>license:</pre><p>For example:</p><pre>package name: demopw1<br>version: 1.0.0<br>description:<br>entry point: index.js<br>test command:<br>git repository:<br>keywords:<br>author:<br>license:</pre><p>For this project, we don’t need to answer these interactively.</p><p>That is why we use:</p><pre>npm init -y</pre><h3>3.4 What Does -y Mean?</h3><p>The -y option means:</p><blockquote><em>Accept the default answers automatically.</em></blockquote><p>So:</p><pre>npm init</pre><p>asks questions, while:</p><pre>npm init -y</pre><p>accepts the default values and creates the project immediately.</p><p>After running the command, the directory changes from:</p><pre>demopw1/</pre><p>to:</p><pre>demopw1/<br>└── package.json</pre><h3>3.5 What Is package.json?</h3><p>package.json is the central configuration file for a Node.js project.</p><p>It describes the project and, more importantly for our automation workspace, records its dependencies and scripts.</p><p>The generated file will initially look similar to:</p><pre>{<br>  &quot;name&quot;: &quot;demopw1&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;&quot;,<br>  &quot;main&quot;: &quot;index.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;<br>  },<br>  &quot;keywords&quot;: [],<br>  &quot;author&quot;: &quot;&quot;,<br>  &quot;license&quot;: &quot;ISC&quot;<br>}</pre><p>The exact contents may vary slightly depending on the npm version.</p><p>At this stage, we don’t need to modify it manually.</p><p>As we install project dependencies, npm will automatically add them to this file.</p><h3>3.6 Why Is package.json Important?</h3><p>Think of package.json as the <strong>manifest of our automation project</strong>.</p><p>It will eventually contain information such as:</p><pre>Project<br>│<br>├── Name<br>├── Version<br>├── Scripts<br>├── Development dependencies<br>└── Project metadata</pre><p>For example, after installing Playwright Test and TypeScript, it will eventually contain something similar to:</p><pre>{<br>  &quot;name&quot;: &quot;demopw1&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;devDependencies&quot;: {<br>    &quot;@playwright/test&quot;: &quot;...&quot;,<br>    &quot;@types/node&quot;: &quot;...&quot;,<br>    &quot;typescript&quot;: &quot;...&quot;<br>  }<br>}</pre><p>The exact versions are intentionally omitted here because they depend on when the project is created.</p><h3>3.7 package.json vs package-lock.json</h3><p>At this stage, npm may create:</p><pre>package.json</pre><p>As dependencies are installed, npm will also create:</p><pre>package-lock.json</pre><p>These two files serve different purposes.</p><h3>package.json</h3><p>Defines what the project depends on.</p><p>For example:</p><pre>I need Playwright Test.<br>I need TypeScript.<br>I need Node.js type definitions.</pre><h3>package-lock.json</h3><p>Records the exact dependency resolution used by npm.</p><p>This helps ensure that different environments install a consistent dependency tree.</p><p>Conceptually:</p><pre>package.json<br>      │<br>      │ Defines dependencies<br>      ▼<br>package-lock.json<br>      │<br>      │ Locks resolved versions<br>      ▼<br>node_modules/<br>      │<br>      ▼<br>Installed packages</pre><p>For a team project, both package.json and package-lock.json should normally be committed to source control.</p><h3>3.8 Verify the Project Initialization</h3><p>After running:</p><pre>npm init -y</pre><p>run:</p><pre>ls -la</pre><p>You should now see something similar to:</p><pre>.<br>..<br>package.json</pre><p>We can inspect the project using:</p><pre>npm ls --depth=0</pre><p>Since we haven’t installed any project dependencies yet, the output should be similar to:</p><pre>demopw1@1.0.0 /Users/i18n/development/pw-cli/demopw1<br>└── (empty)</pre><p>This is expected.</p><p>It means:</p><blockquote><em>The Node.js project exists, but no local npm dependencies have been installed yet.</em></blockquote><p>This is an important distinction from the global installation we verified in Step 2.</p><h3>3.9 Global Packages vs Project Packages</h3><p>At this point, our environment has two different dependency scopes.</p><h3>Global environment</h3><pre>Global npm<br>│<br>├── @anthropic-ai/claude-code<br>│      └── claude<br>│<br>└── @playwright/cli<br>       └── playwright-cli</pre><p>These tools are available independently of the project.</p><h3>Project environment</h3><pre>demopw1/<br>│<br>└── package.json</pre><p>No project-specific packages have been installed yet.</p><p>This is intentional.</p><p>In the next step, we will install:</p><pre>@playwright/test</pre><p>locally.</p><h3>3.10 Why Don’t We Install Everything Globally?</h3><p>A common beginner mistake is to install every development tool globally.</p><p>For example:</p><pre>npm install -g @playwright/test<br>npm install -g typescript</pre><p>That is not the approach we want for this project.</p><p>Instead, project dependencies should generally be installed locally:</p><pre>npm install -D @playwright/test<br>npm install -D typescript</pre><p>This gives each project control over its own dependency versions.</p><p>For example:</p><pre>Project A<br>│<br>└── node_modules/<br>    └── @playwright/test 1.x<br></pre><pre>Project B<br>│<br>└── node_modules/<br>    └── @playwright/test 2.x</pre><p>The two projects can coexist without depending on the same globally installed test framework.</p><h3>3.11 The Workspace After Step 3</h3><p>At the end of this step, our project should look like:</p><pre>/Users/i18n/development/pw-cli/demopw1<br>│<br>└── package.json</pre><p>The overall environment now looks like:</p><pre>Development Machine<br>                                  │<br>                ┌─────────────────┴─────────────────┐<br>                │                                   │<br>          Global Tooling                       Project Workspace<br>                │                                   │<br>        ┌───────┴────────┐                    demopw1/<br>        │                │                        │<br>   Claude Code     Playwright CLI           package.json<br>        │                │<br>     claude       playwright-cli</pre><p>We have therefore completed the transition from:</p><p><strong>machine-level tooling</strong></p><p>to:</p><p><strong>project-level workspace</strong>.</p><h3>The next step is to add Playwright as a project dependency.</h3><p>We will install:</p><pre>npm install -D @playwright/test</pre><p>and examine why <strong>Playwright Test is installed locally even though Playwright CLI is already installed globally</strong>.</p><h3>Step 4 — Install Playwright Test Locally</h3><p>In Step 3, we initialized the Node.js project and created package.json.</p><p>At this point, the project has the structure:</p><pre>/Users/i18n/development/pw-cli/demopw1<br>│<br>└── package.json</pre><p>The next objective is to add the <strong>Playwright Test framework</strong> to this project.</p><p>Run:</p><pre>npm install -D @playwright/test</pre><p>This command installs Playwright Test as a <strong>local development dependency</strong>.</p><h3>4.1 Breaking Down the Command</h3><p>Let’s understand each part:</p><pre>npm install -D @playwright/test</pre><p>PartMeaningnpmNode Package ManagerinstallInstall a package-DInstall as a development dependency@playwright/testPlaywright&#39;s test framework</p><p>The -D option is shorthand for:</p><pre>--save-dev</pre><p>Therefore, these two commands are equivalent:</p><pre>npm install -D @playwright/test</pre><p>and:</p><pre>npm install --save-dev @playwright/test</pre><h3>4.2 What Is Playwright Test?</h3><p>It is important to distinguish <strong>Playwright CLI</strong> from <strong>Playwright Test</strong>.</p><p>We already have Playwright CLI installed globally:</p><pre>@playwright/cli<br>        │<br>        ▼<br>playwright-cli</pre><p>Playwright CLI provides an interactive, command-oriented interface for browser automation and is particularly useful when working with AI coding agents.</p><p>Playwright Test is the <strong>test automation framework</strong> used to create and execute repeatable test cases.</p><p>It provides capabilities such as:</p><ul><li>Test cases</li><li>Assertions</li><li>Test fixtures</li><li>Hooks</li><li>Browser contexts</li><li>Configuration</li><li>Retries</li><li>Parallel execution</li><li>Screenshots</li><li>Video recording</li><li>Tracing</li><li>Test reports</li></ul><h3>4.3 Why Is Playwright Test Installed Locally?</h3><p>A natural question at this point is:</p><blockquote><em>If Playwright CLI is already installed globally, why do we install </em><em>@playwright/test locally?</em></blockquote><p>Because they serve different purposes.</p><p>The global Playwright CLI is a <strong>developer/agent tool</strong>.</p><p>The local Playwright Test package is a <strong>project dependency</strong>.</p><p>Our architecture therefore looks like:</p><pre>GLOBAL<br>─────────────────────────────</pre><pre>Claude Code<br>     │<br>     └── claude</pre><pre>Playwright CLI<br>     │<br>     └── playwright-cli<br></pre><pre>PROJECT<br>─────────────────────────────</pre><pre>@playwright/test<br>     │<br>     └── npx playwright test</pre><p>This separation gives the project control over its test framework version.</p><h3>4.4 What Happens After Installation?</h3><p>When we run:</p><pre>npm install -D @playwright/test</pre><p>npm performs several operations.</p><h3>1. Downloads Playwright Test</h3><p>The package and its dependencies are downloaded from the npm registry.</p><h3>2. Creates node_modules</h3><p>The project will now contain:</p><pre>demopw1/<br>├── node_modules/<br>│   └── @playwright/<br>│       └── test/<br>└── package.json</pre><p>There will also be many transitive dependencies inside node_modules.</p><h3>3. Updates package.json</h3><p>The dependency is recorded under devDependencies.</p><p>It will look approximately like:</p><pre>{<br>  &quot;name&quot;: &quot;demopw1&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;devDependencies&quot;: {<br>    &quot;@playwright/test&quot;: &quot;^...&quot;<br>  }<br>}</pre><p>The exact version depends on the version available when the installation is performed.</p><h3>4. Creates or updates package-lock.json</h3><p>npm records the resolved dependency tree in:</p><pre>package-lock.json</pre><p>So our project now contains:</p><pre>demopw1/<br>│<br>├── node_modules/<br>├── package-lock.json<br>└── package.json</pre><h3>4.5 Why devDependencies?</h3><p>Playwright Test is required for <strong>developing and executing our automated tests</strong>.</p><p>It is not a runtime dependency of the web application being tested.</p><p>That is why it belongs under:</p><pre>{<br>  &quot;devDependencies&quot;: {<br>    &quot;@playwright/test&quot;: &quot;...&quot;<br>  }<br>}</pre><p>rather than:</p><pre>{<br>  &quot;dependencies&quot;: {<br>    &quot;@playwright/test&quot;: &quot;...&quot;<br>  }<br>}</pre><p>This distinction becomes useful when the project grows and we start managing application-specific libraries separately from testing and development tooling.</p><h3>4.6 Why Not Install @playwright/test Globally?</h3><p>We deliberately do <strong>not</strong> use:</p><pre>npm install -g @playwright/test</pre><p>Instead, we use:</p><pre>npm install -D @playwright/test</pre><p>The reason is version isolation.</p><p>Imagine two projects:</p><pre>Project A<br>└── @playwright/test 1.x<br></pre><pre>Project B<br>└── @playwright/test 2.x</pre><p>With local installation, each project controls its own Playwright Test version.</p><p>With a global installation, both projects could be affected by the same global version.</p><p>For an automation framework intended to be maintained over time, local dependencies provide a much more predictable environment.</p><h3>4.7 What Does npx Do?</h3><p>Once Playwright Test is installed locally, we can run it using:</p><pre>npx playwright test</pre><p>Here npx allows us to execute the locally installed Playwright command.</p><p>Conceptually:</p><pre>npx playwright test<br>        │<br>        ▼<br>Project-local executable<br>        │<br>        ▼<br>node_modules/.bin/<br>        │<br>        ▼<br>@playwright/test</pre><p>This means we don’t need to install Playwright Test globally.</p><h3>4.8 Verify the Installation</h3><p>After installation, run:</p><pre>npm ls --depth=0</pre><p>We should now see something similar to:</p><pre>demopw1@1.0.0<br>└── @playwright/test@...</pre><p>The exact version will depend on the version installed.</p><p>Next, verify Playwright:</p><pre>npx playwright --version</pre><p>This should display the installed Playwright version.</p><p>We can also verify the test runner itself:</p><pre>npx playwright test --help</pre><p>If the Playwright Test help information appears, the test framework is correctly installed.</p><h3>4.9 Local Playwright Test vs Global Playwright CLI</h3><p>At this stage, our environment now has two Playwright-related installations with different responsibilities:</p><pre>DEVELOPMENT MACHINE<br>                            │<br>              ┌─────────────┴─────────────┐<br>              │                           │<br>            GLOBAL                      LOCAL<br>              │                           │<br>      @playwright/cli              @playwright/test<br>              │                           │<br>              ▼                           ▼<br>      playwright-cli              npx playwright test<br>              │                           │<br>              │                           │<br>      Browser exploration          Test execution<br>      Browser interaction          Assertions<br>      Page inspection              Fixtures<br>      AI-agent workflows           Hooks<br>                                    Retries<br>                                    Reports</pre><p>This is intentional.</p><p>We are not installing the same thing twice.</p><p>We are using two related Playwright components for two different jobs.</p><h3>4.10 Why This Matters for an AI-Assisted Workspace</h3><p>Our eventual development workflow will look something like this:</p><pre>Claude Code<br>                              │<br>                              ▼<br>                       Playwright CLI<br>                              │<br>                    Explore application<br>                              │<br>                    Inspect page state<br>                              │<br>                    Identify elements<br>                              │<br>                    Understand workflow<br>                              │<br>                              ▼<br>                    Create / modify tests<br>                              │<br>                              ▼<br>                     Playwright Test<br>                              │<br>                       Execute tests<br>                              │<br>                              ▼<br>                    Application Under Test</pre><p>This gives us a clean separation:</p><p><strong>Playwright CLI</strong></p><p>→ Used while exploring and interacting with the application.</p><p><strong>Playwright Test</strong></p><p>→ Used to turn that knowledge into repeatable automated tests.</p><p><strong>Claude Code</strong></p><p>→ Helps us reason about the application, project files, automation code, and development workflow.</p><p>This separation will become especially valuable when we later introduce Page Objects, fixtures, reusable workflows, test data, reporting, and AI-assisted test generation.</p><h3>4.11 Current Workspace</h3><p>After completing Step 4, the workspace should look approximately like:</p><pre>/Users/i18n/development/pw-cli/demopw1<br>│<br>├── node_modules/<br>│   └── @playwright/<br>│       └── test/<br>│<br>├── package-lock.json<br>└── package.json</pre><p>And the broader environment is:</p><pre>GLOBAL<br>│<br>├── Claude Code<br>│      └── claude<br>│<br>└── Playwright CLI<br>       └── playwright-cli<br></pre><pre>LOCAL — demopw1<br>│<br>├── @playwright/test<br>├── package.json<br>├── package-lock.json<br>└── node_modules/</pre><h3>At the end of this step, the project has its <strong>test execution framework</strong>, but it is not yet ready to execute browser tests.</h3><p>The next step is to add <strong>TypeScript</strong>, which will become the language used to implement our Playwright automation.</p><h3>Step 5 — Install TypeScript and Node.js Type Definitions</h3><p>In Step 4, we installed <strong>Playwright Test</strong> as a local development dependency.</p><p>The project now has the basic test execution framework:</p><pre>demopw1/<br>├── node_modules/<br>├── package-lock.json<br>└── package.json</pre><p>The next decision is the language in which we will write our automation.</p><p>For this project, we will use <strong>TypeScript</strong>.</p><p>The installation is:</p><pre>npm install -D typescript @types/node</pre><p>This installs two development dependencies:</p><pre>typescript<br>@types/node</pre><p>Although both are installed together, they serve different purposes.</p><h3>5.1 What Is TypeScript?</h3><p>TypeScript is a programming language developed by Microsoft that extends JavaScript with <strong>static typing</strong>.</p><p>Playwright supports both JavaScript and TypeScript.</p><p>For a larger automation project, TypeScript provides useful features such as:</p><ul><li>Static type checking</li><li>Better IDE support</li><li>Autocomplete</li><li>Compile-time error detection</li><li>Safer refactoring</li><li>Explicit function and object types</li><li>Better maintainability for large test suites</li></ul><h3>5.2 Why TypeScript for Playwright?</h3><p>A small test may look simple:</p><pre>import { test, expect } from &quot;@playwright/test&quot;;</pre><pre>test(&quot;login page loads&quot;, async ({ page }) =&gt; {<br>  await page.goto(&quot;https://example.com&quot;);</pre><pre>  await expect(page).toHaveTitle(/Example/);<br>});</pre><p>But a real automation project can eventually contain:</p><pre>Tests<br>│<br>├── Authentication<br>├── Page Objects<br>├── Fixtures<br>├── API clients<br>├── Test data<br>├── Utilities<br>├── Workflows<br>├── Configuration<br>└── Reporting</pre><p>As the number of files and reusable components increases, static typing becomes increasingly valuable.</p><p>For an AI-assisted project, TypeScript also gives the coding agent a clearer structure to reason about.</p><p>Types provide additional information about:</p><ul><li>Function arguments</li><li>Return values</li><li>Object structures</li><li>Configuration objects</li><li>Page Object methods</li><li>Test data</li><li>Utility functions</li></ul><p>This can help reduce accidental inconsistencies as the project grows.</p><h3>5.3 What Does the Installation Command Mean?</h3><p>The command is:</p><pre>npm install -D typescript @types/node</pre><p>Let’s break it down.</p><p>PartMeaningnpmNode Package ManagerinstallInstall packages-DSave as development dependenciestypescriptTypeScript compiler and tooling@types/nodeType definitions for Node.js</p><p>The -D option is equivalent to:</p><pre>--save-dev</pre><p>Therefore:</p><pre>npm install -D typescript @types/node</pre><p>is equivalent to:</p><pre>npm install --save-dev typescript @types/node</pre><h3>5.4 Why Do We Need @types/node?</h3><p>This is an important detail.</p><p>Our project runs on the Node.js ecosystem, and Playwright’s tooling uses Node.js APIs.</p><p>TypeScript itself does not automatically know about all Node.js APIs.</p><p>For example, we may eventually write code involving:</p><pre>process.env.BASE_URL</pre><p>or:</p><pre>import path from &quot;path&quot;;</pre><p>or:</p><pre>import fs from &quot;fs&quot;;</pre><p>Without Node.js type definitions, TypeScript may not understand the types associated with these APIs.</p><p>Installing:</p><pre>@types/node</pre><p>provides TypeScript declarations for Node.js.</p><p>Conceptually:</p><pre>TypeScript<br>     │<br>     ├── Understand JavaScript<br>     │<br>     └── Understand Node.js APIs<br>                ▲<br>                │<br>          @types/node</pre><h3>5.5 What Are Type Definitions?</h3><p>TypeScript uses declaration files to understand the shape of existing JavaScript APIs.</p><p>These files commonly have the extension:</p><pre>.d.ts</pre><p>They provide information such as:</p><pre>This function exists.<br>This property exists.<br>This function expects a string.<br>This function returns a Promise.<br>This object has these properties.</pre><p>For example, when TypeScript sees:</p><pre>process.env.BASE_URL</pre><p>the Node.js type definitions help TypeScript understand what process and process.env represent.</p><p>This becomes increasingly useful when writing configuration and utility code.</p><h3>5.6 Why Are They Development Dependencies?</h3><p>Both packages are installed using:</p><pre>-D</pre><p>because they are development tools.</p><p>They are not part of the web application being tested.</p><p>Our project is an automation project, so these packages support:</p><pre>Development<br>     │<br>     ├── Write TypeScript<br>     ├── Check TypeScript<br>     ├── Develop Playwright tests<br>     └── Execute automation</pre><p>Therefore:</p><pre>{<br>  &quot;devDependencies&quot;: {<br>    &quot;@playwright/test&quot;: &quot;...&quot;,<br>    &quot;@types/node&quot;: &quot;...&quot;,<br>    &quot;typescript&quot;: &quot;...&quot;<br>  }<br>}</pre><h3>5.7 Verify the Installation</h3><p>Run:</p><pre>npm ls --depth=0</pre><p>The output should now contain something similar to:</p><pre>demopw1@1.0.0<br>├── @playwright/test@...<br>├── @types/node@...<br>└── typescript@...</pre><p>Again, the exact versions will depend on the packages installed.</p><p>Next, check the TypeScript compiler:</p><pre>npx tsc --version</pre><p>You should get output similar to:</p><pre>Version 5.x.x</pre><p>The exact version may be different.</p><h3>5.8 Why Use npx tsc?</h3><p>We could try to install TypeScript globally:</p><pre>npm install -g typescript</pre><p>but that is not necessary.</p><p>Since TypeScript is installed locally:</p><pre>demopw1/<br>└── node_modules/<br>    └── typescript/</pre><p>we can execute its compiler using:</p><pre>npx tsc</pre><p>This ensures that the project uses the version defined by its own dependencies.</p><p>The same principle applies to Playwright:</p><pre>npx playwright test</pre><p>rather than relying on a globally installed test framework.</p><h3>5.9 Create the TypeScript Configuration</h3><p>Now that TypeScript is installed, we can create its project configuration.</p><p>Run:</p><pre>npx tsc --init</pre><p>This creates:</p><pre>tsconfig.json</pre><p>The project now looks like:</p><pre>/Users/i18n/development/pw-cli/demopw1<br>│<br>├── node_modules/<br>├── package-lock.json<br>├── package.json<br>└── tsconfig.json</pre><h3>5.10 What Is tsconfig.json?</h3><p>tsconfig.json tells TypeScript how the project should be interpreted and checked.</p><p>It can control things such as:</p><pre>TypeScript configuration<br>│<br>├── Target JavaScript version<br>├── Module system<br>├── Strict type checking<br>├── Module resolution<br>├── Source directories<br>├── Output directories<br>├── Type definitions<br>└── Compiler behavior</pre><p>The generated tsconfig.json contains many options, most of which do not need to be changed immediately.</p><p>For a Playwright project, we will customize this file later.</p><h3>5.11 TypeScript Configuration vs Playwright Configuration</h3><p>At this point, it is useful to distinguish two important configuration files we will have:</p><pre>tsconfig.json<br>      │<br>      └── Controls TypeScript<br></pre><pre>playwright.config.ts<br>      │<br>      └── Controls Playwright Test</pre><p>They have different responsibilities.</p><h3>tsconfig.json</h3><p>Controls the TypeScript compiler and type checking.</p><h3>playwright.config.ts</h3><p>Controls Playwright Test behavior such as:</p><ul><li>Test directory</li><li>Browser projects</li><li>Base URL</li><li>Timeouts</li><li>Retries</li><li>Workers</li><li>Screenshots</li><li>Video</li><li>Trace</li><li>Reports</li></ul><p>We will create and configure the Playwright configuration in a later step.</p><h3>5.12 TypeScript in the AI-Assisted Workflow</h3><p>The architecture now becomes:</p><pre>Claude Code<br>                            │<br>                            ▼<br>                    Playwright CLI<br>                            │<br>                     Explore browser<br>                            │<br>                            ▼<br>                     TypeScript code<br>                            │<br>                            ▼<br>                    Playwright Test<br>                            │<br>                            ▼<br>                    Execute automation</pre><p>The AI agent can work with strongly structured TypeScript code such as:</p><pre>class LoginPage {<br>  constructor(private page: Page) {}</pre><pre>  async login(username: string, password: string) {<br>    // implementation<br>  }<br>}</pre><p>The types make the expected structure explicit.</p><p>For example:</p><pre>username → string<br>password → string<br>page     → Playwright Page</pre><p>As the project expands into Page Objects, reusable workflows, fixtures, and test data, this type information becomes increasingly useful.</p><h3>5.13 Current Workspace After Step 5</h3><p>After completing this step, the project should look approximately like:</p><pre>/Users/i18n/development/pw-cli/demopw1<br>│<br>├── node_modules/<br>│   ├── @playwright/<br>│   │   └── test/<br>│   ├── @types/<br>│   │   └── node/<br>│   └── typescript/<br>│<br>├── package-lock.json<br>├── package.json<br>└── tsconfig.json</pre><p>The package.json will contain the development dependencies:</p><pre>devDependencies<br>│<br>├── @playwright/test<br>├── @types/node<br>└── typescript</pre><p>However, Playwright Test still needs browser binaries to actually launch Chromium, Firefox, or WebKit.</p><p>That brings us to the next step:</p><p><strong>Step 6 — Install the Playwright Browsers.</strong></p><h3>Step 6 — Install the Playwright Browsers</h3><p>At the end of Step 5, our project has the essential development dependencies:</p><pre>demopw1/<br>├── node_modules/<br>├── package-lock.json<br>├── package.json<br>└── tsconfig.json</pre><p>We now have:</p><pre>@playwright/test<br>typescript<br>@types/node</pre><p>However, there is one more important component required before we can execute browser-based tests:</p><p><strong>the browser binaries.</strong></p><p>Playwright can automate browsers such as:</p><ul><li>Chromium</li><li>Firefox</li><li>WebKit</li></ul><p>These browser binaries are managed by Playwright rather than relying on whatever browser happens to be installed on the developer’s machine.</p><h3>6.1 Why Do We Need to Install Browsers?</h3><p>Installing:</p><pre>npm install -D @playwright/test</pre><p>Installs the <strong>Playwright Test framework</strong>.</p><p>It does not mean that all browser binaries required by Playwright are already available.</p><p>Think of the installation as two separate layers:</p><pre>Playwright installation<br>        │<br>        ├── Test framework<br>        │      │<br>        │      └── @playwright/test<br>        │<br>        └── Browser binaries<br>               │<br>               ├── Chromium<br>               ├── Firefox<br>               └── WebKit</pre><p>The first layer provides the automation framework.</p><p>The second layer provides the browsers that the framework controls.</p><h3>6.2 Install the Playwright Browsers</h3><p>From the project directory:</p><pre>cd /Users/i18n/development/pw-cli/demopw1</pre><p>run:</p><pre>npx playwright install</pre><p>This instructs Playwright to download the browser binaries required by the framework.</p><p>Depending on the Playwright version and environment, the installation will download browser components such as:</p><pre>Chromium<br>Firefox<br>WebKit</pre><p>The exact output and browser revision numbers may vary.</p><h3>6.3 Why Use npx Again?</h3><p>Notice that we are using:</p><pre>npx playwright install</pre><p>rather than:</p><pre>playwright install</pre><p>This is intentional.</p><p>Our Playwright Test installation is local to the project:</p><pre>demopw1/<br>└── node_modules/<br>    └── @playwright/<br>        └── test/</pre><p>npx allows us to execute the Playwright CLI associated with the project&#39;s installed Playwright package.</p><p>Conceptually:</p><pre>npx playwright install<br>          │<br>          ▼<br>Project-local Playwright<br>          │<br>          ▼<br>Browser management<br>          │<br>          ▼<br>Chromium / Firefox / WebKit</pre><p>This helps ensure that the browser versions correspond to the Playwright version used by the project.</p><h3>6.4 Why Not Use the System Browser?</h3><p>A common question is:</p><blockquote><em>Why doesn’t Playwright simply use the Chrome or Firefox already installed on my Mac?</em></blockquote><p>Playwright is designed to work with <strong>specific browser builds that it manages</strong>.</p><p>This provides a much more predictable automation environment.</p><p>For example:</p><pre>Developer Machine<br>│<br>├── Chrome installed by user<br>├── Safari<br>├── Firefox<br>│<br>└── Playwright-managed browsers<br>      ├── Chromium<br>      ├── Firefox<br>      └── WebKit</pre><p>The Playwright-managed browsers are the ones we normally use for automated testing.</p><p>This helps reduce differences between developer machines and CI environments.</p><h3>6.5 Why Does Browser Version Consistency Matter?</h3><p>Imagine one developer has:</p><pre>Chrome version A</pre><p>while another has:</p><pre>Chrome version B</pre><p>and the CI server has:</p><pre>Chrome version C</pre><p>A test could behave differently across those environments.</p><p>Playwright’s browser management helps establish a more controlled environment:</p><pre>Playwright Project<br>                         │<br>                         ▼<br>                  Playwright Version<br>                         │<br>                         ▼<br>             Compatible browser builds<br>                         │<br>          ┌──────────────┼──────────────┐<br>          ▼              ▼              ▼<br>      Chromium        Firefox         WebKit</pre><p>This is particularly important when the automation suite is executed in CI/CD.</p><h3>6.6 What Does the Installation Actually Download?</h3><p>When we execute:</p><pre>npx playwright install</pre><p>Playwright downloads browser binaries to a Playwright-managed cache location on the machine.</p><p>The browsers are not normally placed directly inside:</p><pre>demopw1/node_modules/</pre><p>Instead, Playwright maintains its own browser storage.</p><p>This is useful because multiple Playwright projects can share the appropriate browser installations rather than duplicating complete browser binaries inside every project.</p><h3>6.7 Install Only Chromium</h3><p>For development, we may not always need all three browsers.</p><p>If our initial goal is to work with Chromium-based testing, we can install only Chromium:</p><pre>npx playwright install chromium</pre><p>This can reduce installation time and disk usage.</p><p>The distinction is:</p><pre>npx playwright install<br>        │<br>        ├── Chromium<br>        ├── Firefox<br>        └── WebKit<br></pre><pre>npx playwright install chromium<br>        │<br>        └── Chromium only</pre><p>For a cross-browser project, we would normally install all required browsers.</p><p>For an initial AI-assisted workspace, Chromium is often a convenient starting point.</p><h3>6.8 Browser Installation vs Browser Testing</h3><p>It is useful to understand that:</p><pre>npx playwright install</pre><p>does <strong>not run a test</strong>.</p><p>It only prepares the browser environment.</p><p>The workflow is:</p><pre>Step 4<br>Install Playwright Test<br>        │<br>        ▼<br>Step 5<br>Install TypeScript<br>        │<br>        ▼<br>Step 6<br>Install browsers<br>        │<br>        ▼<br>Ready to execute browser tests</pre><p>The actual test execution comes later:</p><pre>npx playwright test</pre><h3>6.9 Verify the Browser Installation</h3><p>After the installation completes, we can verify the Playwright environment using:</p><pre>npx playwright --version</pre><p>We can also inspect the available Playwright commands:</p><pre>npx playwright --help</pre><p>The most useful verification, however, will be to run an actual Playwright test once we have created one.</p><p>We will do that after the project configuration and test structure are in place.</p><h3>6.10 What Happens in CI/CD?</h3><p>Browser installation becomes particularly important when we eventually move the project to a CI/CD environment.</p><p>A typical pipeline could look like:</p><pre>Git Repository<br>      │<br>      ▼<br>CI Runner<br>      │<br>      ├── npm ci<br>      │<br>      ├── npx playwright install<br>      │<br>      └── npx playwright test</pre><p>The important point is that node_modules and browser binaries are environment-specific.</p><p>We normally don’t commit:</p><pre>node_modules/</pre><p>or the Playwright browser cache to Git.</p><p>Instead, the CI environment installs the required dependencies and browsers as part of the pipeline.</p><h3>6.11 npm install vs npx playwright install</h3><p>These two commands have different responsibilities:</p><pre>npm install</pre><p>installs the project’s Node.js dependencies.</p><p>For example:</p><pre>@playwright/test<br>typescript<br>@types/node</pre><p>Whereas:</p><pre>npx playwright install</pre><p>installs the browser binaries required by Playwright.</p><p>Conceptually:</p><pre>npm install<br>     │<br>     ▼<br>Node.js dependencies<br>     │<br>     ├── Playwright Test<br>     ├── TypeScript<br>     └── Node types<br></pre><pre>npx playwright install<br>     │<br>     ▼<br>Browser binaries<br>     │<br>     ├── Chromium<br>     ├── Firefox<br>     └── WebKit</pre><p>This distinction is useful when troubleshooting a new environment.</p><h3>6.12 A Common Setup Mistake</h3><p>A common assumption is:</p><blockquote><em>“I installed </em><em>@playwright/test, so Playwright should already be able to launch Chrome.&quot;</em></blockquote><p>But the framework and browser binaries are separate components.</p><p>If the required browser is missing, Playwright may report that the executable is unavailable and recommend installing the browser.</p><p>The usual solution is:</p><pre>npx playwright install</pre><p>or, if only Chromium is needed:</p><pre>npx playwright install chromium</pre><h3>6.13 Current Project State</h3><p>After Step 6, our workspace has progressed considerably:</p><pre>/Users/i18n/development/pw-cli/demopw1<br>│<br>├── node_modules/<br>│   ├── @playwright/<br>│   │   └── test/<br>│   ├── @types/<br>│   │   └── node/<br>│   └── typescript/<br>│<br>├── package-lock.json<br>├── package.json<br>└── tsconfig.json</pre><p>And outside the project, Playwright has its browser environment available:</p><pre>Playwright Browser Environment<br>│<br>├── Chromium<br>├── Firefox<br>└── WebKit</pre><p>Our overall architecture is now:</p><pre>Development Machine<br>                                  │<br>             ┌────────────────────┼────────────────────┐<br>             │                    │                    │<br>        Claude Code         Playwright CLI       Playwright Project<br>             │                    │                    │<br>          claude           playwright-cli       @playwright/test<br>                                                      │<br>                                                      ▼<br>                                                 TypeScript<br>                                                      │<br>                                                      ▼<br>                                            Playwright Browsers<br>                                                      │<br>                                    ┌─────────────────┼─────────────────┐<br>                                    ▼                 ▼                 ▼<br>                                Chromium          Firefox            WebKit</pre><h3>6.14 Why This Step Matters for Our AI-Ready Workspace</h3><p>The objective of our project is not just to create conventional Playwright tests.</p><p>We are building a workspace where an AI coding agent can participate in the automation development lifecycle.</p><p>That requires the browser environment to be available before we ask the AI agent to explore the application.</p><p>Our workflow is gradually becoming:</p><pre>Claude Code<br>     │<br>     ▼<br>Playwright CLI<br>     │<br>     ▼<br>Browser<br>     │<br>     ▼<br>Application exploration<br>     │<br>     ▼<br>TypeScript + Playwright Test<br>     │<br>     ▼<br>Automated test suite</pre><p>This separation will become more important in the next step when we introduce <strong>Playwright Skills</strong>.</p><p>We now have the basic <strong>runtime foundation</strong> required for browser automation.</p><p>The next question is:</p><blockquote><em>How do we make the browser automation workflow easier for an AI coding agent such as Claude Code to understand and use?</em></blockquote><p>That leads us to the next step:</p><p><strong>Step 7 — Install Playwright Skills.</strong></p><h3>Step 7 — Install Playwright Skills for AI-Assisted Browser Automation</h3><p>Up to Step 6, we have prepared the traditional Playwright automation foundation:</p><pre>Playwright Test<br>TypeScript<br>Node.js types<br>Playwright browsers</pre><p>We have also verified the global AI and browser tooling:</p><pre>Claude Code<br>Playwright CLI</pre><p>The next step introduces an important component of our AI-assisted workflow:</p><p><strong>Playwright Skills.</strong></p><p>Run:</p><pre>playwright-cli install --skills</pre><p>This step is different from installing Playwright CLI itself.</p><h3>7.1 What Are Playwright Skills?</h3><p>A CLI provides commands.</p><p>A Skill provides <strong>guidance and reusable instructions about how those commands should be used to accomplish a particular task</strong>.</p><p>This distinction is particularly important when working with an AI coding agent.</p><p>Think about it this way:</p><pre>Playwright CLI<br>      │<br>      └── Provides capabilities<br>             │<br>             ├── Open browser<br>             ├── Navigate<br>             ├── Snapshot<br>             ├── Click<br>             ├── Fill<br>             └── Inspect<br>                   <br>Playwright Skills<br>      │<br>      └── Provides guidance<br>             │<br>             ├── How to use Playwright<br>             ├── How to explore pages<br>             ├── How to work with locators<br>             ├── How to generate tests<br>             └── How to use browser automation effectively</pre><p>The CLI gives the agent the <strong>tools</strong>.</p><p>The Skills provide additional <strong>knowledge and workflow guidance</strong>.</p><h3>7.2 Why Do We Need Skills?</h3><p>A human developer can learn Playwright by reading documentation and understanding what each command does.</p><p>An AI coding agent also needs contextual instructions to use tools effectively.</p><p>For example, simply giving an AI agent access to a browser does not automatically tell it:</p><pre>Which interaction strategy should be preferred?<br>How should page elements be identified?<br>How should browser state be inspected?<br>How should a discovered workflow be converted into maintainable tests?</pre><p>Skills help provide this additional context.</p><p>The overall AI-assisted workflow becomes:</p><pre>Claude Code<br>                              │<br>                              ▼<br>                       Playwright Skills<br>                              │<br>                  ┌───────────┴───────────┐<br>                  │                       │<br>             Knowledge / guidance     Playwright CLI<br>                                          │<br>                                          ▼<br>                                      Browser<br>                                          │<br>                                          ▼<br>                                    Application</pre><p>This is one of the key differences between a traditional Playwright setup and the AI-assisted workspace we are building.</p><h3>7.3 Install the Skills</h3><p>From the terminal, run:</p><pre>playwright-cli install --skills</pre><p>Unlike:</p><pre>npm install -D @playwright/test</pre><p>this is <strong>not installing an npm dependency into </strong><strong>node_modules</strong>.</p><p>It is configuring Playwright’s Skills for use with an AI coding environment.</p><p>This is an important distinction.</p><h3>7.4 Why Doesn’t the Command Use npm install?</h3><p>Compare the two commands:</p><pre>npm install -D @playwright/test</pre><p>and:</p><pre>playwright-cli install --skills</pre><p>They perform different jobs.</p><h3>npm installation</h3><pre>npm install -D @playwright/test<br>          │<br>          ▼<br>Node.js package<br>          │<br>          ▼<br>node_modules/<br>          │<br>          ▼<br>Project dependency</pre><h3>Skills installation</h3><pre>playwright-cli install --skills<br>          │<br>          ▼<br>Playwright Skills<br>          │<br>          ▼<br>AI-agent guidance</pre><p>Therefore, after installing Skills, we should <strong>not expect another package to appear in </strong><strong>npm ls --depth=0</strong>.</p><p>This is a useful distinction to understand when documenting the project.</p><h3>7.5 Skills vs Playwright CLI</h3><p>It is easy to confuse these two because they are installed through the same Playwright CLI.</p><p>They should be thought of as different layers.</p><pre>Playwright CLI<br>                           │<br>             ┌─────────────┴─────────────┐<br>             │                           │<br>       CLI capabilities              Skills<br>             │                           │<br>             ▼                           ▼<br>       Execute actions             Guide the agent<br>             │                           │<br>             ▼                           ▼<br>        Browser APIs               AI workflow</pre><p>For example, the CLI may provide a command for interacting with a browser.</p><p>The Skill layer can help the AI agent understand <strong>when and how that capability should be used</strong> during an automation workflow.</p><h3>7.6 Skills vs Claude Code</h3><p>Another important distinction is between <strong>Claude Code</strong> and <strong>Playwright Skills</strong>.</p><p>Claude Code is the AI coding agent.</p><p>Playwright Skills provide Playwright-specific guidance that the agent can use.</p><p>Conceptually:</p><pre>Claude Code<br>│<br>│  General software engineering intelligence<br>│<br>├── Understand project<br>├── Read source code<br>├── Write TypeScript<br>├── Modify files<br>├── Run commands<br>└── Work with development tools<br>       │<br>       ▼<br>Playwright Skills<br>│<br>│  Playwright-specific guidance<br>│<br>├── Browser exploration<br>├── Page inspection<br>├── Locators<br>├── Browser interaction<br>└── Test automation workflow<br>       │<br>       ▼<br>Playwright CLI<br>       │<br>       ▼<br>Browser</pre><p>This layered model is important for understanding our architecture.</p><h3>7.7 Skills vs .claude</h3><p>There is another distinction that becomes important as we build the workspace:</p><pre>Playwright Skills</pre><p>and:</p><pre>.claude/</pre><p>are not necessarily the same thing.</p><p>Playwright Skills provide <strong>Playwright-oriented capabilities and guidance</strong>.</p><p>The .claude directory is where we can maintain <strong>project-specific Claude configuration and instructions</strong>.</p><p>For example, our project may eventually contain:</p><pre>demopw1/<br>│<br>├── .claude/<br>│<br>├── tests/<br>├── pages/<br>├── workflows/<br>├── fixtures/<br>└── ...</pre><p>The .claude directory can be used to organize project-specific AI instructions and configuration.</p><p>This allows us to define rules specific to our own automation framework.</p><p>For example, our project instructions may eventually say:</p><pre>Use Playwright CLI when exploring the application.</pre><pre>Use Playwright Test for executable automated tests.</pre><pre>Prefer stable user-facing locators.</pre><pre>Do not hard-code credentials.</pre><pre>Keep test data separate from test implementation.</pre><pre>Reuse Page Objects instead of duplicating selectors.</pre><p>Those are <strong>our project’s rules</strong>.</p><p>They are different from general Playwright Skills.</p><h3>7.8 Three Layers of AI Guidance</h3><p>At this point, we can think about the AI-assisted environment as having three conceptual layers:</p><pre>Claude Code<br>                          │<br>                          ▼<br>                 Playwright Skills<br>                          │<br>                          ▼<br>               Project Instructions<br>                    (.claude / AGENTS.md)<br>                          │<br>                          ▼<br>                  Playwright CLI<br>                          │<br>                          ▼<br>                       Browser</pre><p>Each layer has a different purpose.</p><h3>Claude Code</h3><p>General AI coding and software engineering agent.</p><h3>Playwright Skills</h3><p>Playwright-specific guidance and workflows.</p><h3>Project instructions</h3><p>Our own rules for how automation should be implemented in this particular project.</p><h3>Playwright CLI</h3><p>The actual browser interaction interface.</p><h3>7.9 Why This Is Useful for AI-Assisted Test Development</h3><p>Without a structured workflow, an AI agent might generate tests based only on what it sees in the current conversation.</p><p>That can lead to inconsistent automation.</p><p>For example, one test might use:</p><pre>page.locator(&quot;#username&quot;)</pre><p>while another uses:</p><pre>page.getByRole(&quot;textbox&quot;, { name: &quot;Username&quot; })</pre><p>and another might use:</p><pre>page.locator(&quot;input&quot;).nth(0)</pre><p>A mature automation project should establish consistent locator and coding strategies.</p><p>The combination of:</p><pre>Playwright Skills<br>+<br>Project instructions<br>+<br>Playwright Test</pre><p>helps us establish a more predictable development process.</p><h3>7.10 Token Efficiency and AI-Assisted Automation</h3><p>One of the reasons we are exploring Playwright CLI rather than relying entirely on raw browser automation through an AI integration is the amount of information an AI agent needs to process.</p><p>A browser page can contain a large amount of information:</p><pre>DOM<br>HTML<br>CSS<br>JavaScript<br>Accessibility information<br>Hidden elements<br>Metadata<br>Images<br>Network information</pre><p>Sending all of this information to an AI model for every interaction can be inefficient.</p><p>A more focused workflow can be:</p><pre>Browser<br>   │<br>   ▼<br>Playwright CLI<br>   │<br>   ▼<br>Focused page state / snapshot<br>   │<br>   ▼<br>Claude Code<br>   │<br>   ▼<br>Reason about relevant elements<br>   │<br>   ▼<br>Next browser action</pre><p>The goal is not simply to minimize tokens at any cost.</p><p>The goal is to provide the AI agent with <strong>the right information at the right time</strong>.</p><p>This becomes particularly valuable when the application contains large pages, complex DOM structures, or many interactive elements.</p><h3>7.11 Skills and the Development Lifecycle</h3><p>Once Skills are available, our intended workflow becomes:</p><pre>1. Explore<br>     │<br>     ▼<br>2. Inspect<br>     │<br>     ▼<br>3. Understand<br>     │<br>     ▼<br>4. Generate<br>     │<br>     ▼<br>5. Review<br>     │<br>     ▼<br>6. Execute<br>     │<br>     ▼<br>7. Diagnose<br>     │<br>     ▼<br>8. Improve</pre><p>Playwright CLI can support the browser interaction portion.</p><p>Playwright Test provides the execution infrastructure.</p><p>Claude Code provides the AI development layer.</p><p>Skills provide Playwright-specific guidance.</p><p>Together:</p><pre>AI-Assisted Automation<br>                          │<br>       ┌──────────────────┼──────────────────┐<br>       │                  │                  │<br> Claude Code       Playwright Skills   Playwright Test<br>       │                  │                  │<br>       └──────────────────┼──────────────────┘<br>                          │<br>                    Playwright CLI<br>                          │<br>                          ▼<br>                      Browser<br>                          │<br>                          ▼<br>                    Application</pre><h3>7.12 Verify the Skills Installation</h3><p>After running:</p><pre>playwright-cli install --skills</pre><p>we should verify that the command completed successfully.</p><p>We can also verify the CLI itself:</p><pre>playwright-cli --version</pre><p>and:</p><pre>playwright-cli --help</pre><p>The exact location and files created by Skills installation can depend on the Playwright CLI version and the environment, so it is better to verify through the CLI’s supported commands rather than assuming a fixed filesystem location.</p><p>This is especially important when documenting a setup that may be used by readers on different operating systems.</p><h3>7.13 What We Have Now</h3><p>After Step 7, the workspace has evolved into a much more complete AI-ready environment:</p><pre>GLOBAL TOOLING<br>│<br>├── Claude Code<br>│      └── claude<br>│<br>└── Playwright CLI<br>       └── playwright-cli<br>              │<br>              └── Playwright Skills<br></pre><pre>PROJECT<br>│<br>├── node_modules/<br>│   ├── @playwright/test<br>│   ├── @types/node<br>│   └── typescript<br>│<br>├── package.json<br>├── package-lock.json<br>└── tsconfig.json<br></pre><pre>BROWSER ENVIRONMENT<br>│<br>├── Chromium<br>├── Firefox<br>└── WebKit</pre><p>The project is now ready for the next major part of the setup:</p><p><strong>connecting the AI agent’s behavior to our specific project.</strong></p><h3>7.14 Step 7 Summary</h3><p>The primary command is:</p><pre>playwright-cli install --skills</pre><p>The purpose of this step is to make Playwright-specific Skills available to the AI-assisted workflow.</p><p>The important distinction is:</p><pre>@playwright/test<br>       │<br>       └── Test framework<br></pre><pre>playwright-cli<br>       │<br>       └── Browser interaction<br></pre><pre>Playwright Skills<br>       │<br>       └── Playwright-specific AI guidance<br></pre><pre>Claude Code<br>       │<br>       └── AI coding agent<br></pre><pre>.claude / project instructions<br>       │<br>       └── Project-specific automation rules</pre><p>We now have the major building blocks of the AI-ready Playwright workspace.</p><p>The next step will be to introduce <strong>Claude Code project-level instructions and the </strong><strong>.claude workspace</strong>, so that the AI agent understands not just how to use Playwright, but <strong>how we want Playwright to be used within this particular project</strong>.</p><p>That brings us to:</p><p><strong>Step 8 — Configure Claude Code for the Playwright Project.</strong></p><h3>Step 8 — Configure Claude Code for the Playwright Project</h3><p>Up to Step 7, we have installed and prepared the major components of our AI-assisted Playwright environment.</p><p>We now have:</p><pre>Global<br>├── Claude Code<br>└── Playwright CLI</pre><pre>Playwright environment<br>├── Playwright Skills<br>├── Chromium<br>├── Firefox<br>└── WebKit</pre><pre>Local project<br>├── @playwright/test<br>├── TypeScript<br>├── @types/node<br>├── package.json<br>├── package-lock.json<br>└── tsconfig.json</pre><p>The next step is different.</p><p>We are going to configure <strong>Claude Code at the project level</strong>.</p><p>The objective is:</p><blockquote><em>Give Claude Code enough project-specific context and rules that it can work consistently within our Playwright automation workspace.</em></blockquote><h3>8.1 Why Project-Level AI Instructions?</h3><p>Claude Code is a general-purpose AI coding agent.</p><p>It can work with:</p><ul><li>JavaScript</li><li>TypeScript</li><li>Python</li><li>Java</li><li>Flutter</li><li>SQL</li><li>Playwright</li><li>APIs</li><li>Configuration files</li><li>Shell commands</li></ul><p>But our project has specific requirements.</p><p>For example, we may want Claude Code to follow rules such as:</p><pre>Use TypeScript.</pre><pre>Use Playwright Test for executable tests.</pre><pre>Use Playwright CLI for browser exploration.</pre><pre>Prefer stable locators.</pre><pre>Do not hard-code credentials.</pre><pre>Keep test data separate.</pre><pre>Reuse existing Page Objects.</pre><pre>Do not create duplicate utilities.</pre><pre>Run tests after meaningful changes.</pre><p>These are not generic Playwright requirements.</p><p>They are <strong>our project’s conventions</strong>.</p><p>This is why project-level instructions are useful.</p><h3>8.2 Global Claude Code vs Project Configuration</h3><p>There are two different scopes to keep in mind.</p><h3>Global</h3><p>Claude Code itself is installed globally:</p><pre>Global environment<br>│<br>└── Claude Code<br>       └── claude</pre><p>This allows us to launch Claude Code from different projects.</p><h3>Project</h3><p>Our project contains its own configuration and instructions:</p><pre>demopw1/<br>│<br>├── .claude/<br>├── tests/<br>├── pages/<br>└── ...</pre><p>The important concept is:</p><pre>Global installation<br>       │<br>       └── Makes Claude Code available<br></pre><pre>Project instructions<br>       │<br>       └── Tell Claude Code how to work here</pre><p>We don’t need a separate global Claude Code installation for every project.</p><h3>8.3 What Is .claude?</h3><p>.claude is a project-level directory that can be used for Claude Code-related configuration and project-specific resources.</p><p>We can create it from the project root:</p><pre>mkdir -p .claude</pre><p>Then verify:</p><pre>ls -la</pre><p>We should now see:</p><pre>.<br>..<br>.claude<br>node_modules<br>package-lock.json<br>package.json<br>tsconfig.json</pre><p>The leading . means that .claude is a hidden directory on Unix-like systems such as macOS and Linux.</p><h3>8.4 Why Keep .claude in the Project?</h3><p>The reason is project isolation.</p><p>Imagine that we have:</p><pre>Project A<br>└── .claude/<br></pre><pre>Project B<br>└── .claude/<br></pre><pre>Project C<br>└── .claude/</pre><p>Each project can define its own AI-assisted development conventions.</p><p>For example:</p><pre>Project A<br>→ Playwright automation<br></pre><pre>Project B<br>→ FastAPI + Python<br></pre><pre>Project C<br>→ Flutter</pre><p>Claude Code remains the same global tool, but the project context changes.</p><p>This is similar to the way:</p><pre>package.json</pre><p>defines Node.js project behavior.</p><p>The difference is that:</p><pre>package.json<br>→ Software dependencies and scripts<br></pre><pre>.claude<br>→ AI-assisted project configuration/resources</pre><h3>8.5 Project Instructions Are More Important Than Tool Installation</h3><p>Installing Claude Code doesn’t automatically make the agent understand our architecture.</p><p>Similarly:</p><pre>playwright-cli install --skills</pre><p>doesn’t automatically encode our project’s business rules.</p><p>We need a project-specific instruction layer.</p><p>For example:</p><pre>AI Agent<br>   │<br>   ├── General knowledge<br>   │<br>   ├── Playwright Skills<br>   │<br>   └── Project instructions<br>          │<br>          ▼<br>       demopw1</pre><p>This creates a hierarchy of context.</p><h3>8.6 What Should Our Project Instructions Contain?</h3><p>For our initial Playwright workspace, the instructions should establish rules around:</p><h3>Technology</h3><pre>Use TypeScript.<br>Use Playwright Test.<br>Use Playwright CLI for browser exploration.</pre><h3>Test design</h3><pre>Tests must be maintainable.<br>Prefer stable locators.<br>Avoid unnecessary hard-coded waits.<br>Use assertions.</pre><h3>Project structure</h3><pre>Tests belong under tests/.<br>Reusable page interactions belong in pages/.<br>Reusable workflows belong in workflows/.<br>Shared fixtures belong in fixtures/.</pre><h3>Security</h3><pre>Never commit passwords.<br>Never hard-code credentials.<br>Use environment variables for secrets.</pre><h3>AI behavior</h3><pre>Inspect the existing project before creating files.<br>Reuse existing code where possible.<br>Don&#39;t create duplicate utilities.<br>Run relevant tests after modifications.</pre><p>These rules will evolve as our project evolves.</p><h3>8.7 CLAUDE.md and .claude</h3><p>A useful distinction is that <strong>project instructions do not necessarily mean that every instruction must be placed inside </strong><strong>.claude/</strong>.</p><p>A common approach with Claude Code is to use a project-level:</p><pre>CLAUDE.md</pre><p>at the repository root.</p><p>For example:</p><pre>demopw1/<br>│<br>├── CLAUDE.md<br>├── .claude/<br>├── package.json<br>├── tsconfig.json<br>└── ...</pre><p>This gives the AI agent a clear project-level instruction file.</p><p>The .claude directory can then be used for additional Claude Code project resources/configuration as appropriate.</p><p>Conceptually:</p><pre>CLAUDE.md<br>   │<br>   └── What the agent should know about this project<br></pre><pre>.claude/<br>   │<br>   └── Claude-specific project resources/configuration</pre><p>This separation is useful because it keeps the <strong>main project instructions visible at the repository root</strong>.</p><h3>8.8 Create CLAUDE.md</h3><p>From the project root:</p><pre>touch CLAUDE.md</pre><p>Verify:</p><pre>ls -la</pre><p>The workspace should now contain:</p><pre>demopw1/<br>│<br>├── .claude/<br>├── CLAUDE.md<br>├── node_modules/<br>├── package-lock.json<br>├── package.json<br>└── tsconfig.json</pre><h3>8.9 Initial CLAUDE.md</h3><p>We can start with a relatively small instruction set.</p><p>The goal is <strong>not</strong> to write a huge document containing every possible rule.</p><p>Instead, we should provide the AI agent with the most important project constraints.</p><p>For example:</p><pre># Playwright Automation Project</pre><pre>## Technology</pre><pre>- TypeScript<br>- Playwright Test<br>- Playwright CLI<br>- Node.js</pre><pre>## Browser Automation</pre><pre>- Use Playwright CLI for browser exploration and inspection.<br>- Use Playwright Test for executable automated tests.<br>- Prefer stable user-facing locators.<br>- Avoid arbitrary hard-coded waits.</pre><pre>## Test Design</pre><pre>- Keep tests independent.<br>- Use assertions to validate expected behavior.<br>- Reuse Page Objects and fixtures where appropriate.<br>- Avoid duplicating selectors and workflows.</pre><pre>## Security</pre><pre>- Never hard-code credentials.<br>- Use environment variables for sensitive configuration.<br>- Do not commit secrets.</pre><pre>## Development Workflow</pre><pre>- Inspect existing files before creating new ones.<br>- Reuse existing utilities where possible.<br>- Keep the project structure consistent.<br>- Run relevant tests after making changes.</pre><p>This is enough to establish the initial behavior.</p><p>We can make the instructions more sophisticated later.</p><h3>8.10 Why Start Small?</h3><p>It is tempting to create a very large AI instruction document.</p><p>That can actually become counterproductive.</p><p>Our instructions should answer the most important questions:</p><pre>What technology are we using?</pre><pre>How should browser exploration be performed?</pre><pre>How should tests be written?</pre><pre>What should the agent avoid?</pre><pre>What project conventions should be followed?</pre><p>As the project develops, we can add rules based on real problems we encounter.</p><p>This gives us a living project contract rather than a huge theoretical document.</p><h3>8.11 The AI Context Architecture</h3><p>Our workspace can now be represented as:</p><pre>Claude Code<br>                              │<br>                              ▼<br>                       Project Context<br>                              │<br>            ┌─────────────────┼─────────────────┐<br>            │                 │                 │<br>        CLAUDE.md        Playwright Skills   Existing Code<br>            │                 │                 │<br>            │                 │                 │<br>            └─────────────────┼─────────────────┘<br>                              │<br>                              ▼<br>                       Project Decisions<br>                              │<br>                              ▼<br>                      Playwright CLI<br>                              │<br>                              ▼<br>                           Browser<br>                              │<br>                              ▼<br>                        Application</pre><p>This is the foundation for AI-assisted automation.</p><h3>8.12 Why Existing Code Matters</h3><p>An important principle for AI-assisted development is:</p><blockquote><em>The agent should understand what already exists before creating something new.</em></blockquote><p>For example, suppose we eventually have:</p><pre>pages/<br>└── LoginPage.ts</pre><p>and ask Claude Code to automate login.</p><p>The agent should inspect the existing Page Object rather than automatically creating:</p><pre>pages/<br>├── LoginPage.ts<br>└── LoginPageNew.ts</pre><p>Similarly, if we already have:</p><pre>fixtures/<br>└── auth.fixture.ts</pre><p>we should reuse it instead of creating another authentication mechanism.</p><p>This becomes increasingly important as the project grows.</p><h3>8.13 AI Instructions and the Automation Architecture</h3><p>Our eventual project may look something like:</p><pre>demopw1/<br>│<br>├── .claude/<br>│<br>├── tests/<br>│<br>├── pages/<br>│<br>├── fixtures/<br>│<br>├── workflows/<br>│<br>├── test-data/<br>│<br>├── utils/<br>│<br>├── reports/<br>│<br>├── CLAUDE.md<br>├── playwright.config.ts<br>├── tsconfig.json<br>├── package.json<br>└── package-lock.json</pre><p>The AI instructions can define how these directories should be used.</p><p>For example:</p><pre>tests/<br>    Test specifications</pre><pre>pages/<br>    Page Objects</pre><pre>fixtures/<br>    Shared Playwright fixtures</pre><pre>workflows/<br>    Business workflows</pre><pre>test-data/<br>    Test data</pre><pre>utils/<br>    Generic reusable utilities</pre><p>This makes the project easier for both humans and AI agents to navigate.</p><h3>8.14 Where Playwright Skills Fit</h3><p>We now have several components that can easily be confused.</p><p>Let’s put them together:</p><pre>┌──────────────────────────────────────────────┐<br>│                Claude Code                   │<br>│              AI coding agent                │<br>└──────────────────────┬───────────────────────┘<br>                       │<br>                       ▼<br>┌──────────────────────────────────────────────┐<br>│              Project Context                 │<br>│                                              │<br>│  CLAUDE.md                                   │<br>│  .claude/                                    │<br>│  Existing source code                        │<br>└──────────────────────┬───────────────────────┘<br>                       │<br>                       ▼<br>┌──────────────────────────────────────────────┐<br>│           Playwright Skills                  │<br>│                                              │<br>│  Playwright-specific AI guidance             │<br>└──────────────────────┬───────────────────────┘<br>                       │<br>                       ▼<br>┌──────────────────────────────────────────────┐<br>│             Playwright CLI                  │<br>│                                              │<br>│  Browser interaction and exploration         │<br>└──────────────────────┬───────────────────────┘<br>                       │<br>                       ▼<br>┌──────────────────────────────────────────────┐<br>│                  Browser                     │<br>│                                              │<br>│        Chromium / Firefox / WebKit           │<br>└──────────────────────┬───────────────────────┘<br>                       │<br>                       ▼<br>                 Application</pre><p>Each layer has a distinct responsibility.</p><h3>8.15 Global vs Local vs Project-Specific</h3><p>Our complete setup can now be categorized into three levels.</p><h3>Global tools</h3><p>Installed once on the development machine:</p><pre>Claude Code<br>Playwright CLI</pre><p>These are available across projects.</p><h3>Local project dependencies</h3><p>Installed into demopw1:</p><pre>@playwright/test<br>typescript<br>@types/node</pre><p>These belong to this Node.js project.</p><h3>Project-level AI configuration</h3><p>Specific to this project:</p><pre>CLAUDE.md<br>.claude/<br>Playwright Skills</pre><p>This is the layer that makes our AI-assisted workflow project-aware.</p><h3>8.16 Verify the Workspace</h3><p>Run:</p><pre>ls -la</pre><p>We should now see the major files and directories:</p><pre>.<br>..<br>.claude<br>CLAUDE.md<br>node_modules<br>package-lock.json<br>package.json<br>tsconfig.json</pre><p>Then verify the Node.js dependencies:</p><pre>npm ls --depth=0</pre><p>We should see:</p><pre>@playwright/test<br>@types/node<br>typescript</pre><p>And verify the global Playwright CLI:</p><pre>playwright-cli --version</pre><p>Our environment is now ready for the next stage.</p><h3>8.17 What We Have Accomplished</h3><p>We started with an empty directory:</p><pre>demopw1/</pre><p>and progressively built:</p><pre>Step 3<br>Node.js project<br>      │<br>      ▼<br>Step 4<br>Playwright Test<br>      │<br>      ▼<br>Step 5<br>TypeScript<br>      │<br>      ▼<br>Step 6<br>Playwright browsers<br>      │<br>      ▼<br>Step 7<br>Playwright Skills<br>      │<br>      ▼<br>Step 8<br>Claude Code project context</pre><p>This is more than a simple Playwright installation.</p><p>We are building an <strong>AI-ready browser automation workspace</strong>.</p><h3>8.18 Step 8 Summary</h3><p>The key commands introduced in this step are:</p><pre>mkdir -p .claude</pre><p>and:</p><pre>touch CLAUDE.md</pre><p>The main concepts are:</p><pre>Claude Code<br>    ↓<br>Project instructions<br>    ↓<br>Playwright Skills<br>    ↓<br>Playwright CLI<br>    ↓<br>Browser<br>    ↓<br>Application</pre><p>The most important lesson is:</p><blockquote><strong><em>Global installation makes the tool available; project configuration tells the AI agent how to use it within the project.</em></strong></blockquote><h3>Conclusion</h3><p>In this article, we started with an empty project directory and progressively built an <strong>AI-ready Playwright automation workspace</strong> using Playwright CLI and Claude Code.</p><p>We established the role of each component:</p><pre>Claude Code<br>     ↓<br>AI Coding Agent</pre><pre>Playwright Skills<br>     ↓<br>Playwright-specific AI guidance</pre><pre>Playwright CLI<br>     ↓<br>Browser interaction and exploration</pre><pre>Playwright Test<br>     ↓<br>Automated test execution</pre><pre>TypeScript<br>     ↓<br>Test implementation</pre><pre>Playwright Browsers<br>     ↓<br>Application under test</pre><p>More importantly, we separated the environment into three layers:</p><pre>Global Tools<br>├── Claude Code<br>└── Playwright CLI</pre><pre>Local Project Dependencies<br>├── @playwright/test<br>├── TypeScript<br>└── @types/node</pre><pre>Project-Level AI Context<br>├── CLAUDE.md<br>└── .claude/</pre><p>This separation gives us a clean foundation for scaling the automation project without mixing global tooling, project dependencies, and project-specific AI instructions.</p><p>Starting from an empty directory, we have reached a workspace that is ready for the next stage of AI-assisted test engineering.</p><p>The next challenge is no longer:</p><blockquote><strong><em>“How do I install Playwright?”</em></strong></blockquote><p>Instead, it becomes:</p><blockquote><strong><em>“How can Claude Code use Playwright CLI to explore an application, understand its workflows, generate reliable tests, execute them, and continuously improve the automation?”</em></strong></blockquote><p>That is where the real potential of <strong>AI-assisted Playwright automation</strong> begins.</p><p>In the next stage, we can build on this foundation and move from <strong>workspace creation to actual application exploration and test generation</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2b0f146c51e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CPU Time Profiling using Java Flight Recorder (JFR) -JEP 509 (Experimental)]]></title>
            <link>https://medium.com/@sathishparamasivam/cpu-time-profiling-using-java-flight-recorder-jfr-jep-509-experimental-6953435a2664?source=rss-7373a5770278------2</link>
            <guid isPermaLink="false">https://medium.com/p/6953435a2664</guid>
            <dc:creator><![CDATA[Sathish Paramasivam]]></dc:creator>
            <pubDate>Wed, 24 Dec 2025 13:31:21 GMT</pubDate>
            <atom:updated>2025-12-24T13:31:21.695Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*GBJu4gNDuh3m4i01RuiNfQ.jpeg" /></figure><h3><strong>Profiling a Program</strong></h3><p>To profile a program means to analyze its runtime behaviour to find performance bottlenecks,identifying which parts use the most CPU ,memory or time,So developers can optimize them for better speed or efficiency.</p><p>In another word Profiling, in software engineering, is a form of dynamic program analysis where data is collected on a program’s runtime behavior, such as memory usage, execution time, and CPU cycles.</p><p>This analysis is crucial for:</p><ul><li><strong>Identifying Bottlenecks:</strong> Locating the parts of the code that consume the most resources.</li><li><strong>Performance Optimization:</strong> Improving the efficiency and speed of the application by focusing optimization efforts on “hotspots” (frequently or long-running code sections).</li><li><strong>Resource Management:</strong> Understanding how the application interacts with system resources like the CPU and memory.</li></ul><h3>CPU-Time Vs Execution-Time</h3><p>At this juncture we must know the key difference between CPU Time and Execution time, aka Traditional profiling.</p><p><strong>Execution-Time (Traditional Profiling)</strong> Samples thread at fixed interval of elapsed real time. If a thread is waiting for network IO, event though if its not using the CPU ,it shows up as running.</p><p><strong>CPU-Time (CPU Time Profiling) </strong>only samples ,when a thread is actively consumes CPU cycles,making it easier to identify code that is genuinely wasting processor power.</p><h3>JFR CPU-Time Profiling Experimental by JEP — 509</h3><p>Profiling a program by JFR CPU time profiling” means using <strong>Java Flight Recorder (JFR)</strong> to analyze how a Java application consumes <strong>CPU time</strong>. This process involves measuring the exact amount of time the CPU spends executing specific methods and functions, which helps developers identify performance bottlenecks and optimize their code.</p><h4><strong>What is JFR CPU Time Profiling?</strong></h4><p><strong>JFR (Java Flight Recorder)</strong> is a built-in profiling and event collection framework within the JDK (Java Development Kit) that can continuously collect detailed, low-overhead runtime information.</p><p><strong>CPU Time Profiling</strong> (or on-CPU time profiling) specifically focuses on the time the CPU is actively executing program instructions, as opposed to time spent waiting for I/O operations or other processes.</p><p>The JFR CPU time profiling mechanism, introduced as an experimental feature (JEP 509) in later Java versions (e.g., JDK 25 on Linux), uses the operating system’s CPU timer to sample the call stack of threads at fixed intervals of CPU time consumed. This provides a highly accurate profile of which methods are responsible for the actual CPU usage, including native code calls, which traditional execution samplers might miss.</p><p>The results are typically visualized in command line JFR-view (I prefered to work for this article )even tools like JDK Mission Control (JMC) or flame graphs, where developers can see which functions are using the most CPU time and where the CPU cycles are being spent within the code’s call hierarchy.</p><h3>JFR’s Execution Sampler Mechanism</h3><p>JFR offers an approximation of CPU profiling through a mechanism called the execution sampler.</p><h4>What is execution sampler ?</h4><p><strong>Execution Sampler</strong> is JFR’s <strong>low-overhead, statistical CPU profiling mechanism</strong>.</p><p>It doesn’t measure <em>exact</em> CPU cycles; instead, it <strong>periodically samples where threads are executing</strong> and uses those samples to <strong>approximate</strong> CPU usage.</p><p>Instead of tracking every instruction (which is expensive), JFR:</p><ul><li>Wakes up at regular intervals (for example, every ~10 ms)</li><li>Looks at <strong>what each Java thread is executing right now</strong></li><li>Records the <strong>current stack trace</strong></li><li>Repeats this thousands of times</li></ul><p>Over time:</p><ul><li>Methods that appear <strong>more often in samples</strong> are the ones consuming <strong>more CPU</strong></li></ul><p>👉 This is <strong>statistical profiling</strong>.</p><h3>Why it’s called an approximation</h3><p>Execution sampler does <strong>not</strong>:</p><ul><li>Count CPU cycles</li><li>Measure exact execution time per method</li></ul><p>Instead, it assumes:</p><blockquote>“If a method shows up frequently when I sample, it must be using more CPU.”</blockquote><p>This is statistically accurate <strong>at scale</strong>, but not exact.</p><h3>What JFR samples exactly</h3><p>The execution sampler records events like:</p><ul><li>jdk.ExecutionSample</li><li>jdk.NativeMethodSample</li></ul><p>Each event contains:</p><ul><li>Thread name &amp; ID</li><li>Thread state (RUNNABLE, BLOCKED, etc.)</li><li>Java stack trace</li><li>Sometimes native frames</li></ul><p>Only threads that are <strong>running or runnable</strong> matter for CPU profiling.</p><h3>Why this is ideal for production 🔥</h3><p>JFR’s <strong>execution sampler</strong> is ideal for production use because it provides CPU profiling with <strong>very low overhead</strong>. Instead of instrumenting code or tracking exact CPU cycles — which can significantly slow down an application and distort its behavior — the execution sampler periodically takes lightweight snapshots of what threads are executing at that moment. By collecting these samples over time, JFR can statistically approximate where CPU time is spent without interfering with normal execution. This minimal impact (typically well under 1% CPU overhead) makes execution sampling safe to run continuously in production systems, allowing developers to identify CPU hot spots under real workloads without affecting performance or latency.</p><h4>Risk with async-profiler</h4><p>Third-party tools such as <strong>async-profiler</strong> can produce very accurate <strong>CPU-time profiles</strong> by using <strong>Linux’s CPU timers</strong> (for example, perf events or POSIX CPU clocks). These timers allow the tool to measure <em>actual CPU time</em> consumed by threads, which is very powerful for performance analysis. However, the Java Virtual Machine does <strong>not officially expose safe, supported APIs</strong> for this kind of low-level CPU sampling. To get the required information, these tools therefore reach into the JVM using <strong>unsupported internal interfaces</strong> — private HotSpot structures, JVM internals, or undocumented behaviors.</p><p>Because these interfaces are <strong>not part of the Java specification</strong>, the JVM makes <strong>no guarantees</strong> about their stability, correctness, or safety. They can change between Java versions, differ across vendors, or behave unexpectedly under certain GC or JIT conditions. As a result, using such tools can <strong>corrupt JVM state</strong>, interfere with GC or compilation, and in the worst case <strong>crash the entire Java process</strong>. This is why the approach is described as <em>inherently unsafe</em>, even though it may work well in practice on certain Linux/JDK combinations.</p><h4><strong>Improvement to JFR</strong></h4><p>The idea is to <strong>enhance Java Flight Recorder (JFR)</strong> so that it can use the <strong>Linux kernel’s CPU timer</strong> directly, instead of relying only on statistical execution sampling. The Linux CPU timer can measure <strong>actual CPU time and cycles consumed by a program</strong>, which makes profiling more precise. Importantly, this mechanism would allow JFR to account for CPU usage <strong>even when Java code is executing native code</strong> (such as JNI calls, cryptography libraries, compression, or system libraries), which current sampling-based approaches may underrepresent or miss.</p><p>more precisely Using Linux’s CPU timer inside JFR would make CPU profiling more accurate and safer, especially for Linux-based Java applications that spend significant time in native code.</p><h4>Scope Status &amp; Future Direction</h4><blockquote>Java Flight Recorder is being <strong>extended to support true CPU-time profiling</strong>, but <strong>only on Linux systems for now</strong>. This means JFR can measure <strong>actual CPU time consumed</strong> by Java programs (including time spent in native code) using Linux-specific kernel facilities.</blockquote><blockquote>Because this capability is new and relies on low-level OS integration, it is introduced as an <strong>experimental feature</strong>. Marking it experimental allows the JDK team to gather real-world feedback, fix issues, tune accuracy, and adjust the design <strong>without committing to a permanent API or behavior yet</strong>.</blockquote><p>Lets have a sample Java program to explain about the CPU Time profiling using JFR.</p><pre>class demoJFR<br> {<br>   public static void main(String asd[]) throws Exception<br>        {<br>          for(var i=0;i&lt;100;i++)<br>                {<br>                 process(i);<br>                }<br><br>        }<br><br>     static void process(int n) throws InterruptedException<br>        {<br>          Thread.sleep(50);<br>          System.out.println(n);<br><br>        }<br> }</pre><p>From the above simple program , I would like to explain CPU time and Wall clock time are very different. especially in the context of JFR.</p><p>From the above program the inner loop</p><pre>              for(var i=0;i&lt;100;i++)<br>                {<br>                 process(i);<br>                }</pre><p>call process() 100 times , runs on single thread , executes sequentially.</p><p>Inside process():</p><ol><li>Thread.sleep(50) → thread <strong>blocks for ~50 ms</strong></li><li>System.out.println(n) → small amount of CPU + I/O</li></ol><h3>Wall-clock time</h3><ul><li>Each iteration waits ~50 ms</li><li>Total time ≈ <strong>5 seconds</strong></li></ul><h3>CPU time</h3><ul><li>While sleeping, the thread:</li><li>is <strong>NOT running</strong></li><li>consumes <strong>zero CPU</strong></li><li>Only CPU usage is from:</li><li>loop control</li><li>println</li><li>JVM housekeeping</li></ul><p>👉 <strong>CPU time is tiny compared to elapsed time</strong></p><p>Inside the process method</p><p>Thread.sleep(50);<br>System.out.println(n);</p><h3>1️⃣ Thread.sleep(50)</h3><ul><li>The thread is put into <strong>TIMED_WAITING</strong></li><li>It is <strong>not running on the CPU</strong></li><li>The OS deschedules the thread</li><li>CPU is free to run other processes</li></ul><p>⏱ Wall-clock time increases<br> 🔥 CPU time does <strong>not</strong></p><h3>2️⃣ System.out.println(n)</h3><ul><li>Some <strong>actual CPU work</strong></li><li>Formatting the number</li><li>Writing to stdout</li></ul><p>This part <strong>does consume CPU</strong>, but only for a <strong>very short time</strong></p><h3>Total execution time (intuition)</h3><ul><li>100 × 50 ms sleep = <strong>~5 seconds</strong></li><li>Actual CPU execution time = <strong>tiny</strong> (milliseconds)</li></ul><p>So the program:</p><ul><li>Runs for ~5 seconds</li><li>Uses <strong>almost no CPU</strong></li></ul><p>After the compilation , let’s run this simple program with the command</p><blockquote><strong>java-XX:StartFlightRecording=filename=timed.jfr,duration=10s demoJFR</strong></blockquote><p><strong>High Level meaning of the above command is</strong>,Run the <strong>demoJFR</strong> program and start a Java Flight Recorder (JFR) session that measures how much time is spent in the method demoJFR.process, then save the recording to timed.jfr after 10 seconds.</p><h3>1️⃣ java</h3><p>Starts the Java Virtual Machine.</p><h3>2️⃣ -XX:StartFlightRecording:...</h3><p>tell the JVM to <strong>start a JFR recording immediately at JVM startup</strong>.</p><p>The recording starts <strong>as soon as the JVM begins execution</strong>.</p><p>You don’t need:</p><ul><li>jcmd</li><li>JDK Mission Control</li><li>Any extra tooling</li></ul><h3>3️⃣ filename=timed.jfr</h3><ul><li>Specifies the output file</li></ul><blockquote>JFR data will be written to: <strong>timed.jfr</strong></blockquote><p>This file can be opened in:</p><ul><li>jfr print</li><li><strong>JDK Mission Control (JMC)</strong></li></ul><h3>4️⃣ duration=10s</h3><ul><li>The recording runs for <strong>10 seconds</strong></li><li>After 10 seconds:</li><li>Recording automatically stops</li><li>Data is flushed to timed.jfr</li></ul><p>This is important for:</p><ul><li>Short-lived programs</li><li>Preventing unlimited recording growth</li></ul><h3>5️⃣ demoJFR</h3><p>This is the <strong>main class</strong> being executed:</p><h3>What this captures for your program</h3><p>Given your code:</p><pre>static void process(int n) throws InterruptedException {<br>    Thread.sleep(50);<br>    System.out.println(n);<br>}</pre><p>JFR will show:</p><ul><li>~100 invocations of process</li><li>Each invocation lasting ~50 ms</li><li>Time dominated by <strong>sleep (waiting)</strong>, not CPU</li></ul><p>This proves:</p><ul><li>Wall-clock time ≠ CPU time</li><li>Method timing includes <strong>waiting + I/O</strong></li></ul><blockquote><strong>java -XX:StartFlightRecording=filename=timed.jfr,duration=10s demoJFR</strong></blockquote><p>✔ This is <strong>valid</strong><br> ✔ JFR will start immediately<br> ✔ Recording will stop after 10 seconds<br> ✔ Output will be written to timed.jfr</p><p>After the execution of the above command , it yields the following</p><p>[0.774s][info][jfr,startup] Started recording 1. The result will be written to:</p><p>[0.774s][info][jfr,startup]</p><p>[0.774s][info][jfr,startup] /Users/x/y/javaupdates/j25/timed.jfr</p><p>Our Next step is to summary</p><blockquote><strong>jfr summary /Users/x/y/javaupdates/j25/timed.jfr</strong></blockquote><h3>Here, jfr is</h3><p>jfr is the <strong>Java Flight Recorder command-line tool</strong> that comes with the JDK.<br> It is used to <strong>inspect, analyze, and extract information</strong> from .jfr recording files.</p><p>Think of it as:</p><blockquote><em>a </em><strong><em>reader and analyzer</em></strong><em> for Flight Recorder data</em></blockquote><h3>Where, summary means</h3><p>summary tells the tool:</p><blockquote><em>“Give me a </em><strong><em>high-level overview</em></strong><em> of what is inside this recording.”</em></blockquote><p>It does <strong>not</strong> show details or stack traces. It shows <strong>metadata and counts only</strong>.</p><p>as follows</p><p>Version: 2.1</p><p>Chunks: 1</p><p>Start: 2025–12–24 12:51:50 (UTC)</p><p>Duration: 6 s</p><p>Event Type Count Size (bytes)</p><p>=============================================================</p><p>jdk.NativeLibrary 760 67028</p><p>jdk.SystemProcess 659 67338</p><p>jdk.ModuleExport 508 5437</p><p>jdk.BooleanFlag 486 14894</p><p>jdk.ActiveSetting 376 9718</p><p>jdk.ModuleRequire 156 1560</p><p>jdk.LongFlag 137 4400</p><p>jdk.ThreadSleep 100 1800</p><p>……………</p><p>=============================================================</p><p>this jfr summary output actually tells a <strong>very clear story</strong> about your program and why you’re seeing what you’re seeing. Let’s walk through it in a structured, meaningful way.</p><h3>1️⃣ Recording basics (sanity check)</h3><pre>Version: 2.1<br>Chunks: 1<br>Start: 2025-12-24 12:51:50 (UTC)<br>Duration: 6 s</pre><p>✔ JFR recording <strong>worked</strong><br> ✔ It ran for <strong>6 seconds</strong><br> ✔ Single continuous chunk (normal for short runs)</p><p>So your setup is correct.</p><h3>2️⃣ The most important events for your program</h3><h3>🔹 jdk.ThreadSleep — 100 events</h3><pre>jdk.ThreadSleep   100</pre><p>This matches your code perfectly:</p><p>✔ Each loop iteration → one sleep<br> ✔ 100 iterations → 100 sleep events</p><p>👉 This confirms:</p><blockquote><em>Your program is </em><strong><em>wall-clock bound</em></strong><em>, not CPU bound.</em></blockquote><h3>🔹 jdk.ExecutionSample — 1 event</h3><pre>jdk.ExecutionSample   1</pre><p>This is <strong>the key insight</strong>.</p><p>Execution samples are taken <strong>periodically</strong> (typically every ~10 ms).<br> But your thread:</p><ul><li>wakes up</li><li>prints a number</li><li>goes back to sleep almost immediately</li></ul><p>So:</p><ul><li>The JVM rarely “catches” it running</li><li>Almost no CPU samples are collected</li></ul><p>👉 This proves:</p><blockquote>process() does <strong>not consume CPU time</strong></blockquote><h3>Why CPU-time profiling shows nothing</h3><p>Notice:</p><pre>jdk.CPUTimeSample        0<br>jdk.CPUTimeSamplesLost  0</pre><p>This means:</p><ul><li>CPU-time profiling is <strong>not active</strong></li><li>Or there was <strong>no measurable CPU usage</strong></li></ul><p>Given your code:</p><pre>Thread.sleep(50);</pre><p>Even if CPU-time profiling were enabled:</p><p>CPU time would still be near zero</p><h4>What this summary tells us overall</h4><p>This program is intentionally idle. JFR is reporting exactly the truth.</p><p>Try the following to make JFR show “interesting” CPU data</p><pre>static void process(int n) {<br>    for (int i = 0; i &lt; 10_000_000; i++) {<br>        Math.sqrt(i);<br>    }<br>}</pre><p>You will then see:</p><ul><li>Many ExecutionSample events</li><li>CPU hotspots</li><li>Clear stack traces</li></ul><blockquote><strong>jfr print — events CPULoad,GarbageCollection timed.jfr</strong></blockquote><p>will provide the following as output</p><p>jdk.CPULoad {</p><p>startTime = 18:21:50.984 (2025–12–24)</p><p>jvmUser = 0.25%</p><p>jvmSystem = 0.00%</p><p>machineTotal = 5.72%</p><p>}</p><p>jdk.CPULoad {</p><p>startTime = 18:21:51.386 (2025–12–24)</p><p>jvmUser = 0.12%</p><p>jvmSystem = 0.12%</p><p>machineTotal = 7.10%</p><p>}</p><p>jdk.CPULoad {</p><p>startTime = 18:21:51.787 (2025–12–24)</p><p>jvmUser = 0.12%</p><p>jvmSystem = 0.00%</p><p>machineTotal = 5.75%</p><p>}</p><p>jdk.CPULoad {</p><p>startTime = 18:21:52.190 (2025–12–24)</p><p>jvmUser = 0.12%</p><p>jvmSystem = 0.00%</p><p>machineTotal = 3.25%</p><p>}</p><blockquote><strong>jfr print — categories ‘GC’ timed.jfr</strong></blockquote><p>this will give information over GC</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6953435a2664" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Community Process (JCP’s)-JSR & Open JDK’s -JEP.]]></title>
            <link>https://medium.com/@sathishparamasivam/java-community-process-jcps-jsr-open-jdk-s-jep-0e43b70f83c4?source=rss-7373a5770278------2</link>
            <guid isPermaLink="false">https://medium.com/p/0e43b70f83c4</guid>
            <category><![CDATA[jep]]></category>
            <category><![CDATA[jsr]]></category>
            <category><![CDATA[jcp]]></category>
            <category><![CDATA[jdk]]></category>
            <category><![CDATA[java25]]></category>
            <dc:creator><![CDATA[Sathish Paramasivam]]></dc:creator>
            <pubDate>Wed, 05 Nov 2025 05:26:09 GMT</pubDate>
            <atom:updated>2025-11-05T05:46:18.118Z</atom:updated>
            <content:encoded><![CDATA[<p>Managed by Stewardship from <strong>Oracle , Evolution of Java Standardization</strong></p><p>In this article I would like to present and talk about the feature development flow between Open JDK ‘s Java Enhanced Proposal (JEP) and Java Community Process (JCP) -JSR.</p><blockquote>Oracle officially released Java 25 on September 2025 , It is a colaborative effort led by Oracle and the Global Java Developer Community through Java Community Process (JCP) and Open JDK community.</blockquote><h3>Organization and Individuals</h3><p><strong>JDK 25</strong> is the reference Implementation of version 25 of the Java SE Platform, as specified by <a href="https://openjdk.org/projects/jdk/25/spec">JSR 400</a> in the Java Community Process.</p><p>Prior to look into the features of JAVA 25 listed in Java Enhanced Proposal (JEP) lets know the key organization and individuals involved.</p><h4><strong>Oracle Corporation</strong></h4><p>Oracle is the primary steward of the Java platform and the main developer behind the Oracle JDK, which uses the OpenJDK source code. Georges Saab, Senior Vice President, Oracle Java Platform and chair of the OpenJDK governing board, was a key spokesperson for the release.</p><p>Two more important entities <strong>Java Community Process (JCP) </strong>and the <strong>OpenJDK Community</strong> are two distinct but related parts of the Java ecosystem.</p><p>They <strong>both influence how Java evolves</strong>, but they operate at different levels, with different goals and governance.</p><h4>Java Community Process(JCP)</h4><p><strong>Java Community Process (JCP) </strong>is a official standards body that defines what Java is — meaning it governs the <em>Java specifications</em>, <em>APIs</em>, and <em>platform editions</em> (Java SE, EE, ME). The main purpose of the JCP is to create and maintain the official specifications for the Java platform, through document called <strong>Java Specifications Requests</strong>(JSR).</p><p><strong>Java Community Process (JCP)</strong> is managed under the stewardship of Oracle , which owns the Java trademark and the Java SE specification.</p><p><strong>Java Community Process (JCP)</strong> is Overseen by the <strong>JCP Executive Committee</strong>, which includes representatives from companies (like Oracle, Red Hat, IBM) and individuals.</p><p>When we say <strong>“members of the Java Community”</strong> (in the context of submitting a <strong>JSR</strong>, or <em>Java Specification Request</em>), we’re referring specifically to <strong>organizations and individuals who are official members of the JCP</strong> — not just <em>any</em> Java developer in the world.</p><p>In the <strong>JCP</strong>, <em>members</em> fall into three main categories:</p><h4>1. Corporate Members</h4><p>Companies and organizations that have joined the JCP to participate in the specification process.</p><p>Examples include:</p><ul><li><strong>Oracle</strong> (current steward of Java)</li><li><strong>Red Hat</strong></li><li><strong>IBM</strong></li><li><strong>SAP</strong></li><li><strong>Google</strong></li><li><strong>Eclipse Foundation</strong></li><li><strong>Azul Systems</strong></li><li><strong>Microsoft</strong></li><li><strong>JetBrains</strong></li></ul><p>These companies can submit JSRs, lead Expert Groups, and vote on proposals.</p><h4>2. Individual Members</h4><p>Independent developers, academics, or consultants who join the JCP <strong>as individuals </strong>they can,</p><ul><li>Propose or co-lead JSRs (if approved),</li><li>Join <em>Expert Groups</em> that define specifications,</li><li>Review and comment on JSRs.</li></ul><p>Example: Some well-known Java architects (like Doug Lea, Brian Goetz, etc.) have served as individual members or expert group participants in various JSRs.</p><h4>3. Affiliate Members</h4><p>These are individuals affiliated with <strong>JCP partner organizations</strong>, such as Java User Groups (JUGs).<br> Affiliate members may contribute to the JCP through community-driven efforts — for instance:</p><ul><li><strong>SouJava</strong> (Brazilian Java Users Group)</li><li><strong>London Java Community (</strong>LJC<strong>)</strong><br> Both are recognized JCP members that have participated in and co-led JSRs.</li></ul><p>Responsible for <strong>Java Specification Requests (JSR)</strong></p><h3>Open JDK</h3><p>Open JDK Community is a place to collaborate an open source implementation Java platform, Standard Edition (SE) and related projects , the main purpose it to develop and maintain the real implements of Java Platform.</p><p>The Open JDK Community is a worldwide association of developers who collaborate on open-source implementations of the Java Platform, Standard Edition, and related projects. It’s a community-driven project where individuals and organizations can contribute code, fix bugs, and develop new features for the Java platform under the GPLv2 license with a Classpath Exception.</p><p>It serves as a hub for developers to collaborate on the reference implementation of Java.</p><p>Managed openly under the <strong>OpenJDK project</strong> (sponsored by Oracle, but with contributions from Red Hat, Amazon, SAP, and many others).</p><p>Anyone can view the code, discuss proposals, and contribute under open-source licenses (GPL + Classpath Exception).</p><p>Responsible for <strong>Java Enhancement Proposal</strong> <strong>(JEP)</strong></p><h3>What is Java Enhancement Proposal (JEP) ?</h3><p>JEP is a design document , that describes a new feature, enhancement, or process change to the <strong>JDK</strong> (the Java Development Kit).</p><p>It’s <strong>less formal</strong> than a JSR and mainly targets OpenJDK contributors and developers.</p><p>The purpose of the JEP to provide a transparent way to track new features and implementation details,Facilitate discussion and coordination in the OpenJDK community.</p><h4>Example JEPs:</h4><ul><li><strong>JEP 286:</strong> Local-Variable Type Inference (var keyword, Java 10)</li><li><strong>JEP 355:</strong> Text Blocks (Java 13)</li><li><strong>JEP 378:</strong> Sealed Classes (Java 17)</li><li><strong>JEP 425:</strong> Virtual Threads (Java 19)</li></ul><h3>What is Java Specification Requests (JSR)?</h3><p>JSR is a Standardization proposal managed under Java Community Process(JCP). If the feature affects the Java language, core APIs, or platform specification, it’s formalized as a JSR, In another word , This means the feature <strong>changes the Java syntax or behavior</strong> — things the compiler or language itself must understand.<br> For example:</p><ul><li>Adding the var keyword ✅</li><li>Adding switch expressions ✅</li><li>Adding new keywords like record, sealed, etc. ✅</li></ul><p>Because these change how the language works, they must be part of the <strong>official Java specification</strong> so that <em>all</em> Java compilers and tools behave the same way. That’s why such features go through a <strong>JSR (Java Specification Request)</strong> in the <strong>Java Community Process (JCP)</strong>.</p><p>A JSR defines <em>what</em> the feature is and ensures all Java implementations behave the same.</p><p>This stage focuses on <em>defining the standard</em> so that all vendors (Oracle, Red Hat, Azul, etc.) can implement it consistently.</p><p>As you hear that JSR is a formal document submitted to <strong>Java Community Process (JCP)</strong> that proposes new features, specifications, or changes to the Java platform.</p><p>Each JSR is like a <strong>complete package</strong> that defines:</p><ul><li><em>What</em> the feature or standard is</li><li><em>How</em> it should behave</li><li><em>How it will be tested and verified</em></li></ul><h4>The following are the main Components of a JSR</h4><h4>1. General Information</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SLUlWjjCerbslXg9M7aLMA.jpeg" /></figure><h3>2. Specification</h3><p>This is the <strong>core technical content</strong> — the <em>“what”</em> of the JSR.</p><p>It defines:</p><ul><li>The new APIs, classes, or interfaces (if any)</li><li>The language syntax or semantics (if it’s a language feature)</li><li>How the new behavior fits into the existing Java platform</li><li>Dependencies on other specifications</li><li>Dependencies on other specifications</li></ul><blockquote><em>📘 Example: In </em><strong><em>JSR 376 (Java Module System)</em></strong><em>, the specification defined how </em><em>module-info.java works, the rules of module encapsulation, and how modules interact.</em></blockquote><h3>3. Reference Implementation (RI)</h3><ul><li>The <strong>working code</strong> that implements the specification.</li><li>Proves that the specification is implementable in real Java code.</li><li>In most modern JSRs, the <strong>OpenJDK</strong> provides this reference implementation.</li></ul><blockquote><em>💡 Example: For JSR 383 (Java SE 10), the </em><strong><em>OpenJDK 10 build</em></strong><em> was the reference implementation — it included the new </em><em>var feature.</em></blockquote><h3>4. Technology Compatibility Kit (TCK)</h3><ul><li>A <strong>set of tests</strong> that verify whether an implementation conforms to the specification.</li><li>Ensures consistency across all Java distributions (Oracle, OpenJDK, Eclipse Temurin, Azul, etc.)</li><li>Every vendor must pass the TCK to claim Java SE compliance.</li></ul><blockquote><em>🧪 Example: The TCK for Java SE tests that </em><em>var behaves correctly across all implementations.</em></blockquote><h3>5. Process Artifacts</h3><p>During its life cycle, a JSR also includes these public-facing documents:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q7EsbUhKpi8iupacBiJYPw.jpeg" /></figure><p>Finally considered the following</p><p>Example: <em>JSR 383 — Java SE 10 Platform</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w2F4oK5eDoUxFdPc9KYbcw.jpeg" /></figure><p>Let us considered the Java Evolution pipeline of how java new feature inearly moves through the <strong>JEP → JSR → Java Release</strong> pipeline.</p><h3><strong>☕️ The Java Evolution Pipeline</strong></h3><h3>🧱 1. JEP (JDK Enhancement Proposal) — Implementation Proposal</h3><ul><li>Managed under <strong>OpenJDK</strong>.</li><li>This is where a new feature or change is first proposed, discussed, and implemented.</li><li>It includes design, motivation, and prototype code.</li></ul><blockquote><em>🧩 Example:<br> </em><strong><em>JEP 286 — Local Variable Type Inference (</em></strong><strong><em>var)</em></strong></blockquote><p>This stage focuses on <em>how to build it</em> in the JDK.</p><h3>🧩 2. JSR (Java Specification Request) — Standardization Proposal</h3><ul><li>Managed under the <strong>Java Community Process (JCP)</strong>.</li><li>If the feature affects the Java language, core APIs, or platform specification, it’s formalized as a <strong>JSR</strong>.</li><li>A JSR defines <em>what</em> the feature is and ensures all Java implementations behave the same.</li></ul><blockquote><em>🧾 Example:<br> The module system (from JEP 261) was formalized as </em><strong><em>JSR 376 — Java Platform Module System.</em></strong></blockquote><p>This stage focuses on <em>defining the standard</em> so that all vendors (Oracle, Red Hat, Azul, etc.) can implement it consistently.</p><h3>🚀 3. Java Release (JDK version)</h3><ul><li>Once both implementation (via JEP) and specification (via JSR) are finalized, the feature ships in a new <strong>Java SE release</strong> — e.g., Java 9, 17, or 25.</li><li>The reference implementation is provided by <strong>OpenJDK</strong>, and it becomes part of the official Java SE platform.</li></ul><blockquote><em>📦 Example:</em></blockquote><blockquote>JEP 286 → implemented in OpenJDK</blockquote><blockquote>Integrated into Java 10</blockquote><blockquote>Specified in the Java SE 10 Platform JSR (JSR 383)</blockquote><h3><strong>The Java Evolution Pipeline</strong></h3><p>the var keyword (local-variable type inference) is one of the clearest examples of how a <strong>Java feature</strong> moves from <strong>idea → JEP → JSR → Java release</strong>.</p><p>Let’s walk through it step-by-step with <strong>JEP 286 (</strong><strong>var)</strong>.</p><h3>☕️ Example: The var Keyword — JEP 286</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ynl6VwrnYDk_adhRwMvx_Q.jpeg" /></figure><h3>🔹 Background</h3><p>Before Java 10, you always had to write the full type on both sides of a local variable declaration:</p><pre><br><br>class samplecount<br> {<br>   public static void main(String asd[])<br>        {<br>          <br>          for(int i=0;i&lt;10;i++)<br>                {<br>                  System.out.println(i);<br>                }<br>        }<br> }<br><br></pre><p>Developers wanted a shorter, cleaner way — like in other modern languages (C#, Kotlin, etc.).</p><p>So the idea was to let the <strong>compiler infer the type</strong> automatically from the initializer expression.</p><h3>🧱 1. Idea Stage</h3><ul><li><strong>Problem:</strong> Verbosity in local variable declarations.</li><li><strong>Goal:</strong> Introduce <strong>local-variable type inference</strong> to make code more concise and readable.</li></ul><p>Early discussions started on the <strong>OpenJDK mailing lists</strong>, then became an official proposal.</p><h3>🧩 2. JEP 286 — The Implementation Proposal</h3><ul><li><strong>Name:</strong> <em>Local-Variable Type Inference</em></li><li><strong>Author:</strong> <em>Reinhold, Brian Goetz, et al.</em></li><li><strong>JEP Number:</strong> <a href="https://openjdk.org/jeps/286">JEP 286</a></li><li><strong>Target:</strong> <em>Java 10</em></li><li><strong>Date Introduced:</strong> 2017</li></ul><p><strong>Summary of JEP 286:</strong></p><blockquote><em>“Enhance the Java language to extend type inference to declarations of local variables with initializers.</em></blockquote><p>Example from JEP:</p><pre>import java.util.*;<br><br>class samplecount<br> {<br>   public static void main(String asd[])<br>        {<br>          var numbers=List.of(1,2,3,4,5);<br><br>          for(var i:numbers)<br>                {<br>                  System.out.println(i);<br>                }<br>        }<br> }</pre><p>Here, the compiler infers that var element is int.</p><h3>⚙️ 3. Implementation via OpenJDK</h3><ul><li>The change was implemented in the <strong>OpenJDK compiler (javac)</strong>.</li><li>Discussions and testing were done in <strong>Project Amber</strong>, an OpenJDK subproject exploring smaller language improvements.</li><li>Once the implementation stabilized, it was included in the <strong>JDK 10</strong> build.</li></ul><h3>🧾 4. JSR Stage — Specification &amp; Standardization</h3><p>Even though JEP 286 defined <em>how</em> to implement the feature, the <strong>Java Community Process (JCP)</strong> had to formally specify <em>what</em> it means in the language spec.</p><p>That happened through:</p><ul><li><strong>JSR 383 — Java SE 10 Platform Specification</strong><br> → This JSR standardized everything included in Java 10, including var.</li></ul><p><strong>Spec Lead:</strong> Oracle (Brian Goetz and Mark Reinhold)<br> <strong>Expert Group:</strong> Oracle, Red Hat, IBM, JetBrains, and others.</p><p>The JSR ensures all Java implementations (Oracle JDK, OpenJDK, Eclipse Temurin, Azul Zulu, etc.) behave consistently with the new feature.</p><h3>🚀 5. Java 10 Release</h3><ul><li><strong>Release date:</strong> March 2018</li><li><strong>Official version:</strong> Java SE 10</li><li>var became part of the <strong>Java Language Specification (JLS)</strong> under section §14.4 (Local Variable Declarations).</li></ul><p>Developers could now write:</p><pre>import java.util.*;<br><br>class samplecount<br> {<br>   public static void main(String asd[])<br>        {<br>          var numbers=List.of(1,2,3,4,5);<br><br>          for(var i:numbers)<br>                {<br>                  System.out.println(i);<br>                }<br>        }<br> }<br><br></pre><h3>🧩 6. Post-Release Refinement</h3><ul><li>Later versions (Java 11+) extended var’s usability, e.g. var in lambda parameters (via <strong>JEP 323</strong>).</li><li>Community feedback ensured consistency and clarified edge cases (e.g., no var for fields or method params).</li></ul><p>The following shows the Integral representation of Feature Development flow by OpenJDK and JCP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1FVkHgSp56_8VOe-qVxfg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R-i2asAsSVIG1ROtKSCkLQ.jpeg" /></figure><p>The above table clearly shows the stages process artifacts with result from OpenJDK and JCP.</p><h3>References</h3><ul><li><a href="https://openjdk.org/">OpenJDK</a></li><li><a href="https://www.jcp.org/en/home/index">The Java Community Process(SM) Program</a></li><li><a href="https://openjdk.org/jeps/286">JEP 286: Local-Variable Type Inference</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0e43b70f83c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build With Gemini AI- Flutter UI]]></title>
            <link>https://medium.com/@sathishparamasivam/build-with-gemini-ai-flutter-ui-af2c5ee01913?source=rss-7373a5770278------2</link>
            <guid isPermaLink="false">https://medium.com/p/af2c5ee01913</guid>
            <dc:creator><![CDATA[Sathish Paramasivam]]></dc:creator>
            <pubDate>Fri, 17 Oct 2025 09:09:20 GMT</pubDate>
            <atom:updated>2025-10-17T09:09:20.880Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Integrating Gemini with Flutter using DashChat</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ppZFrMACzQEaIXWX3omhJA.png" /></figure><p>In this article we dwell into Integrating Google’s Gemini, a powerful generative AI model, with a Flutter-based chat application using the dash_chat package.</p><p>This integration aims to create an intelligent, responsive conversational interface that allows users to interact with the Gemini model through a user-friendly chat UI.</p><p>By leveraging Gemini&#39;s natural language processing capabilities and the simplicity of dash_chat for building chat interfaces, the project seeks to deliver a seamless AI-powered chat experience across platforms.</p><p>The implementation includes handling user input, generating AI responses through the Gemini API, and dynamically updating the chat interface in real-time, ultimately enabling the development of smart, cross-platform virtual assistants or chatbot applications.</p><h3>Dependencies</h3><p>Dependency Injection for the above task is acomplished with two packages from pub.dev</p><p><strong>flutter_gemini: ^3.0.0</strong></p><p><strong>dash_chat_2: ^0.0.21</strong></p><p>flutter_gemini acts as a bridge between your flutter applications and most intelligent AI model Gemini, which is used to empower your AI capabalities to your flutter applications.</p><p>dash_chat The most complete Chat UI for flutter ,Easy to use, highly customizable and fully featured.</p><p>In flutter terminal run the following command</p><p>&gt; flutter pub add flutter_gemini</p><p>&gt; flutter pub add dash_chat_2</p><p>this will added your package’s to pubspec.yaml as follows</p><p>once dependency is injected, enroute to the development stage of an application.</p><p>I would like to segregate the application into two part one is with chat ui through DashChat widget and another one is with the instance of Gemini.</p><h3>DashChat</h3><p>It is a <strong>Flutter package</strong> designed to simplify the creation of <strong>chat user interfaces (UI)</strong>. It provides a ready-to-use, customizable chat UI component that helps developers build modern chat screens quickly and efficiently without building everything from scratch.</p><h3>🎯 Why Use DashChat?</h3><p><strong>Saves development time</strong>: No need to design chat UIs from scratch.</p><ul><li><strong>Looks modern out-of-the-box</strong>: Good default design, similar to commercial chat apps.</li><li><strong>Ideal for prototyping</strong>: Quickly hook up your backend or AI models like Gemini for functional demos.</li><li><strong>Cross-platform</strong>: Works seamlessly on Android, iOS, and web with Flutter.</li></ul><p>We are going to make use of the constructor call DashChat() along with its parameter and values.</p><p>DashChat constructor call takes the arguments as follows</p><p><strong>DashChat</strong> ( {<br> <strong>required ChatUser</strong> currentUser,<br> <strong>required void Function</strong>(ChatMessage) <strong>onSend</strong>,<br> <strong>required List&lt;ChatMessage&gt;</strong> messages,<br> InputOptions inputOptions = const InputOptions(),<br> MessageOptions messageOptions = const MessageOptions(), } )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Qhwuqit_hjgiKEGo9m5gQ.png" /><figcaption>DashChat Constructor call along with Properties and Values</figcaption></figure><h3><strong>ChatUser</strong></h3><p><strong>ChatUser</strong> is a <strong>class from the </strong><strong>dash_chat_2 package</strong> that represents a user participating in the chat — basically, it holds the identity and info about who sent a message.</p><p>The following are the main parameters of the ChatUser class</p><p><strong>id </strong>-String A unique identifier for the user. Example “0” for the current user and “1” for Gemini user.</p><p><strong>firstName</strong>-String A name of the user display in the chatbubble</p><p><strong>lastName(</strong>Optional). lastName of the user</p><p><strong>profileImage</strong>- String optional URL to the user profile picture of avatar</p><p>we are going to have two users Currentuser and Geminiuser and the constructor call is as follows.</p><pre>final User = ChatUser(id: &quot;0&quot;, firstName: &quot;Currentuser&quot;);<br>final geminiUser = ChatUser(id: &quot;1&quot;, firstName: &quot;Geminiuser&quot;);</pre><h3>Why use ChatUser?</h3><ul><li>Each ChatMessage must have a user field, which is a ChatUser.</li><li>This helps DashChat know who sent the message and display names, pictures, and align messages properly.</li><li>Differentiates between the current user and other participants (like Gemini AI).</li></ul><h3><strong>ChatMessage</strong></h3><p>It’s the <strong>data model</strong> used by dash_chat_2 to represent each individual chat bubble (a message).</p><p>Each ChatMessage contains info like:</p><p>The user who sent it (User)</p><ul><li>The message text (text)</li><li>Timestamp (createdAt)</li><li>Optional fields like attachments, images, etc.</li></ul><pre>ChatMessage(<br>  user: geminiUser,<br>  createdAt: DateTime.now(),<br>  text: &quot;Gemini is typing&quot;,<br>);</pre><p>Here we can pass ChatUser instance <strong>geminiUser</strong> as a value for user parameter of the ChatMessage constrcutor call.</p><p>List&lt;ChatMessage&gt; bubbleMsg;</p><pre>List&lt;ChatMessage&gt; bubbleMsg = [];</pre><p>from the Scaffold body , we may call to the function , which return as Widget</p><pre>Widget _buildAi() {<br>  return DashChat(currentUser: User, onSend: _sendMsg, messages: bubbleMsg);<br>}</pre><p>where currentUser property might me tagged with ChatUser instance User,</p><h3>onSend()</h3><p>The onSend method in <strong>DashChat</strong> (from the dash_chat_2 Flutter package) is a <strong>callback function</strong> that gets triggered <strong>whenever the user sends a message</strong> from the chat input field.</p><p>it allow the developer to define what should happen when the user types a message and taps <strong>Send</strong>.</p><p>onSend: (ChatMessage message) {<br> // your logic here<br>}<br>message: This is a ChatMessage object containing:</p><p>message text</p><p>user who sent it</p><p>timestamp</p><h3>What happens behind the scenes</h3><p>User types “Hello” and presses Send</p><ul><li>DashChat creates a ChatMessage</li><li>onSend(ChatMessage) is called</li><li>You now control what happens next (update UI, send to backend, etc.)</li></ul><h3>Gemini Api</h3><p>Get your API key by signin with your google account from</p><p><a href="https://aistudio.google.com/app/api-keys">https://aistudio.google.com/app/api-keys</a></p><p>Click get API Key</p><p>🔐 Treat this key like a password — don’t commit it to public repositories!</p><p>Our next step is to initialize the Gemini with flutter application</p><h3>Step 1. <strong>Create a file called </strong><strong>keys.dart:</strong></h3><pre>const String GEMINI_API_KEY = &quot;AIz..................................&quot;;</pre><p>To keep your API key secure not hardcoded in your dart code Use a .env file in your Flutter project to store your <strong>Gemini API key</strong> is a best practice for security and clean code. Let’s go through how to do it step by step.</p><h3>Step 2. Initialize Gemini in main.dart or at app startup:</h3><pre>import &#39;keys.dart&#39;;</pre><pre>void main() {<br>  Gemini.init(apiKey: GEMINI_API_KEY);</pre><pre>  runApp(const MyApp());<br>}</pre><p>if you want not to entertain your API key hardcoded kindly do use .env</p><h3>✅ Why Use .env?</h3><ul><li>Keeps your <strong>API keys secure</strong> (not hardcoded in your Dart code)</li><li>Makes it easy to switch between dev and production keys</li><li>Prevents accidental commits of sensitive data to GitHub</li></ul><p><strong>🔧 Step-by-Step: Use </strong><strong>.env for API Keys in Flutter</strong></p><h3>✅ Step 1: Add flutter_dotenv Package</h3><p>In your pubspec.yaml:</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br><br>  # The following adds the Cupertino Icons font to your application.<br>  # Use with the CupertinoIcons class for iOS style icons.<br>  cupertino_icons: ^1.0.8<br>  flutter_gemini: ^3.0.0<br>  dash_chat_2: ^0.0.20<br>  flutter_dotenv: ^6.0.0</pre><h3>✅ Step 2: Create a .env File in Your Project Root</h3><p>Create a file named .env <strong>in the root of your Flutter project</strong> (same level as pubspec.yaml):</p><p>Add your API key in that file as follows</p><pre><br>GEMINI_API_KEY= AIz...............................;</pre><h3>✅ Step 3: Load .env in main.dart</h3><p>then update your main.dart as follows</p><pre>void main() async {<br>  // Gemini.init(apiKey: GEMINI_API_KEY);<br>  WidgetsFlutterBinding.ensureInitialized();<br>  await dotenv.load();<br>  String? apiKey = dotenv.env[&#39;GEMINI_API_KEY&#39;]!;<br>  Gemini.init(apiKey: apiKey);<br>  runApp(const MyApp());<br>}</pre><h3>✅ Step 4: Use Gemini in your UI as usual</h3><p>Now you can use Gemini.instance or gemini.text(...) in your UI logic without exposing the key.</p><h3>✅ Step 5: Prevent Committing .env to Git</h3><p><strong>Add </strong><strong>.env to your </strong><strong>.gitignore file</strong> so it’s not committed to GitHub:</p><h3>Use Gemini in your UI and Integration with ChatUI (dashChat2)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jFNkhYHq_FDCK1gxC_MOjA.png" /><figcaption>Gemini Api with its Methods &amp; Properties</figcaption></figure><pre>gemini<br>    .promptStream(<br>      parts: [Part.text(query)],<br>      model: &quot;gemini-pro&quot;,<br>      generationConfig: GenerationConfig(<br>        temperature: 0.8,<br>        maxOutputTokens: 100,<br>      ),<br>    )<br>    .listen((candidate) {<br>      var reply = candidate?.output.toString();<br>      buffer.write(reply.toString());<br><br>      final gMsg = ChatMessage(<br>        user: geminiUser,<br>        text: buffer.toString(),<br>        createdAt: DateTime.now(),<br>      );<br>      setState(() {<br>        bubbleMsg = [gMsg, ...bubbleMsg];<br>      });<br>    });</pre><h3>Reference</h3><ul><li><a href="https://deepmind.google/models/gemini/">Gemini</a></li><li><a href="https://pub.dev/packages/gemini_flutter">gemini_flutter | Flutter package</a></li><li><a href="https://pub.dev/packages/dash_chat_2">dash_chat_2 | Flutter package</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af2c5ee01913" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OPEN / CLOSED Principle - SOLID]]></title>
            <link>https://medium.com/@sathishparamasivam/software-entities-such-as-classes-modules-functions-etc-e2396b26d894?source=rss-7373a5770278------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2396b26d894</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[oops-concepts]]></category>
            <dc:creator><![CDATA[Sathish Paramasivam]]></dc:creator>
            <pubDate>Fri, 01 Aug 2025 13:54:55 GMT</pubDate>
            <atom:updated>2025-08-07T13:04:09.194Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*dbLnrtfnkSC0y--0y4aQDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s361OQwaGYK5BlOCG4c84g.jpeg" /><figcaption>Open for extension Closed for Modifications</figcaption></figure><p>Software Entities such as classes, modules, functions etc., should be open for extension but closed for Modification.</p><p>In simpler terms you should be able to add new functionality without affecting the existing code.</p><p>In order to understand the OCP of SOLID lets check with the OCP Violates version</p><p>Without OCP the following is the semantic design</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*rnlkQGrWkKZUo372uVQy8A.png" /><figcaption>Class diagram representing PaymentProcess class with single method processType</figcaption></figure><p>The following is the Java class <strong>paymentprocess</strong> ,which takes one method processType with two parameters paymentType of String and amount belongs to double type.</p><pre>class paymentprocess<br> {<br>  public void processType(String paymentType,double amount)<br>   {<br>      if(paymentType==&quot;creditcard&quot;)<br>      {<br>         System.out.println(&quot;Discount for creditcard&quot;+(amount*=.10));<br>      }<br>      else if(paymentType==&quot;debitcard&quot;)<br>      {<br>         System.out.println(&quot;Discount for debitcard&quot;+(amount*=.12));<br>      }<br>    }<br> }<br><br><br><br>class demowoocp<br> {<br>   public static void main(String asd[])<br>      {<br>         paymentprocess po=new paymentprocess();<br>         po.processType(&quot;debitcard&quot;,10000);<br>       }<br> }<br><br></pre><h3>What’s the Violation?</h3><ul><li>Every time you want to add a new payment type (like NetBanking or Crypto), you have to <strong>modify</strong> this class.</li><li>This <strong>breaks</strong> the “closed for modification” part of OCP.</li><li>Leads to <strong>tight coupling</strong> and a <strong>long </strong><strong>if-else chain</strong> or switch statements — error-prone and hard to maintain.</li></ul><h3>✅ How to Fix?</h3><p>You should use <strong>polymorphism </strong>: define a PaymentMethod abstract class and create separate classes for each payment type. Then the PaymentProcess uses the interface — <strong>open for extension, closed for modification</strong>.</p><p>✅ <strong>Applying OCP using Polymorphism</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Jx8Lc5cu1D438AfiiPOZg.png" /></figure><p>The following is the Java code with OCP complaint (Refactoring )</p><p>Step 1 Create an abstract class PaymentMethod as follows</p><pre> abstract class PaymentMethod<br>  {<br>     abstract public double paymentProcess(double amount);<br>  }</pre><p>Step 2 Create a class for each paymentType you are in need</p><pre>class creditcard extends PaymentMethod<br> {<br>     @Override<br>     public double paymentProcess(double amount)<br>     {<br>        return amount*=.10;<br>     }<br> }<br><br>class debitcard extends PaymentMethod<br> {<br>     @Override<br>     public double paymentProcess(double amount)<br>     {<br>        return amount*=.12;<br>     }<br> }<br><br> class UPI extends PaymentMethod<br> {<br>     @Override<br>     public double paymentProcess(double amount)<br>       {<br>          return amount*=.15;<br>       }<br> }<br><br></pre><p>Update the PaymentProcess class</p><pre>class paymentprocess<br> {<br>     public double processType(PaymentMethod method,double amount)<br>       {<br>            return method.paymentProcess(amount);  <br>       }<br>  }<br></pre><p>Now its our time to update the main class as follows</p><pre>class demowocp<br> {<br>   public static void main(String asd[])<br>     {<br>        PaymentMethod cc=new creditcard();<br>        PaymentMethod dc=new debitcard();<br>        PaymentMethod upi=new UPI();<br>        paymentprocess po=new paymentprocess();<br>        System.out.println(po.processType(upi,10000));<br><br>     }<br> }</pre><h3>🎯 Benefits</h3><ul><li>You can <strong>add new payment methods</strong> (like CryptoPayment, NetBankingPayment) by simply creating a new class — without modifying PaymentProcessor.</li><li>PaymentProcessor is now <strong>closed for modification</strong> but <strong>open for extension</strong> — exactly what OCP wants.</li></ul><p><strong>OPEN for Extension and CLOSE for Modification</strong></p><p>“Open to extension” means that you should design your classes so that new functionality can be added as new requirements are generated. “Closed for modification” means that once you’ve written a class, you shouldn’t have to change its code to add new functionality.</p><p><strong>ProcessByPayment</strong> class now depends on <strong>PaymentMethod</strong> abstract class, allowing new payment type to be added without modifying the existing code. This adheres to the Open/Close Principle.</p><p><strong>Advantage of OCP</strong></p><p><strong>Flexibility </strong>the open/close principle, provides the ability to extend or modify the behavior of a system without changing its source code. This makes our code development more flexible and adaptable to changing requirements.</p><p><strong>Modularity </strong>Based on the principle, software code is divided into separate, interchangeable components that can be updated or extended without affecting the existing code.</p><p><strong>Maintainability </strong>the closed nature of the modules ensures that changes to one part of the software code don’t affect other parts. This will reduce the unintended bugs or complexity and make the system easier to maintain.</p><p><strong>Usability</strong> We can easily reuse the software code in other parts of the application.</p><p>This principle allows you to use the power of abstraction and inheritance to create a system that are open for extension and closed for modification</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2396b26d894" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SOLID PRINICPLES-Design of Classes -Single Responsibility Principle]]></title>
            <link>https://medium.com/@sathishparamasivam/prinicples-design-of-classes-4cd453a116d9?source=rss-7373a5770278------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cd453a116d9</guid>
            <category><![CDATA[object-oriented-program]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[oops-concepts]]></category>
            <dc:creator><![CDATA[Sathish Paramasivam]]></dc:creator>
            <pubDate>Wed, 30 Jul 2025 12:38:39 GMT</pubDate>
            <atom:updated>2025-08-06T13:25:57.940Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*YCm0FBxtw8bVhTCC9bDu6A.png" /></figure><h3><strong>SOLID</strong> is an acronym in software development representing five basic principles of object-oriented programming intended to make software designs more understandable, flexible, maintainable, and reusable.</h3><p>These principles, introduced by<strong> Robert C. Martin</strong>, help developers create code that is easier to modify, extend, and understand. <strong>Robert C. Martin</strong> collected ten principles dealing with object-oriented design. The first five of them — the so-called <strong>SOLID</strong> principles — deal with the design of classes:</p><p>Then there are three principles <strong>Release Reuse Equivalency Principle</strong>, <strong>Common Closure Principle</strong> , <strong>Common Reuse Principle</strong> about package cohesion:</p><p><strong>Acyclic Dependency Principle</strong>, <strong>Stable Dependency Principle</strong>, <strong>Stable Abstraction Principle </strong>about package coupling. In this article , I would like to leverage the SOLID Single Responsibility Principle</p><p>First Principle to be covered here is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*98pAglSIjrO-zYXt9v-PSA.png" /></figure><h3>Single Responsibility Principle (SRP)</h3><blockquote><em>A class should have </em><strong><em>only one reason to change</em></strong><em>, meaning it should have </em><strong><em>only one responsibility</em></strong><em>.</em></blockquote><p>We will model a banking system, Following class diagram illustrate one single class BankAccount does every thing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*TRvI3fdOppz62Y66E1aIpw.png" /><figcaption><strong>Class Diagram - Visual Representation of Responsibility Overload</strong></figcaption></figure><p>Here is the Java code, which violates the Single Responsibility Principle</p><pre>class BankAccount<br> {<br>      private String accountNumber;<br>      private String accountHolder;<br>      private double balance;<br><br>    public BankAccount(String accountNumber,String accountHolder,double balance) {<br>        this.accountNumber=accountNumber;<br>        this.accountHolder=accountHolder;<br>        this.balance=balance;<br><br>    }<br><br>    public void deposite(double amount)<br>     {<br>        balance+=amount;<br>        System.out.println(&quot;Deposited &quot;+amount);<br>        System.out.println(&quot;Balance After Deposite&quot;+balance);<br>    <br>     }<br><br>     public void withdraw(double amount)<br>      {<br>        if (balance&gt;amount)<br>        {<br>            balance-=amount;<br>            System.out.println(&quot;withdraw&quot;+amount);<br>            System.out.println(&quot;Balance Amount after withdraw&quot;+balance);<br>        }   <br>        else{<br>            System.out.println(&quot;Insufficient Balance&quot;);<br>        }<br>      }<br><br>      public void printAccount()<br>      {<br>        System.out.println(&quot;Accounts Details&quot;);<br>        System.out.println(&quot;Account Number&quot;+accountNumber);<br>        System.out.println(&quot;AccountHolder Name&quot;+accountHolder);<br>        System.out.println(&quot;Balance&quot;+balance);<br>      }<br><br>      public void savetoFile()<br>      {<br>        System.out.println(&quot;Logic for save to File here&quot;);<br>      }<br>      <br> }<br><br> class demoWoSRP<br>  {<br>    public static void main(String asd[])<br>        {<br>           BankAccount obj= new BankAccount(&quot;43248&quot;,&quot;sathish&quot;,120000);<br>           obj.deposite(10000);<br>           obj.withdraw(60000);<br>           obj.printAccount();<br>           obj.savetoFile();<br>         <br>        }<br>  }</pre><h3>💥 Without SRP (Single Responsibility Principle Violated)</h3><p>Everything is done in <strong>one class</strong> — it handles business logic, data printing, and persistence. This leads to:</p><ul><li>Tight coupling</li><li>Difficult maintenance</li><li>More reasons for the class to change</li></ul><p>❌ <strong>What Wrong ?</strong></p><p>BankAccount class is responsible for</p><p><strong>Business Logic:</strong> deposite/withDraw</p><p><strong>UI Logic : </strong>printAccount</p><p><strong>Persistence Logic :</strong> savetoFile</p><p>It violates the <strong>Single Responsibility Principle</strong>, because the class has multiple reason to change. changes to business rules, printing format, or file saving mechanism.</p><h3>Demerits (Single Responsibility Principle Violated)</h3><ul><li>Tight coupling</li><li>Difficult maintenance</li><li>More reasons for the class to change</li></ul><h3>Single Responsibility Principle Complaint Class</h3><p>Each class has a <strong>single responsibility</strong>, and <strong>one reason to change</strong>, aligning with SRP.</p><p>let’s visualize the following class diagram</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*JxItquzJrD5FurevHsfaZw.png" /></figure><p>Here we have three different class with single responsibility class BankAccount is responsible for business logic with deposit and withdraw of the amount,</p><p>AccountPrinter is an another class which has a single ton responsibility to print the account details simply responsible for Persentation logic</p><p>AccountPersistence is an another class, which deals the account information to be persisted into file</p><pre><br>class BankAccount{<br>        String AccountNumber,AccountHolder;<br>        double balance;<br><br>    public BankAccount(String AccountNumber,String AccountHolder,double balance) {<br>        this.AccountNumber=AccountNumber;<br>        this.AccountHolder=AccountHolder;<br>        this.balance=balance;<br>    }<br><br>    public void deposit(double  amount){<br>        balance+=amount;<br>        System.out.println(&quot;Balance After deposit&quot;+balance);<br>     }<br>     <br>    public void withDraw(double amount) {<br>       if(balance&gt;amount)<br>       {<br>        balance-=amount;<br>       }<br>       else{<br>        System.out.println(&quot;In sufficient Balance&quot;);<br>       }<br>    }<br><br>    public String getAccountNumber(){<br>       return AccountNumber;<br>    }<br>    public String getAccountHolder(){<br>        return AccountHolder;<br>    }<br><br>    public double getBalance(){<br>        return balance;<br>    }<br> }<br>    </pre><p>The following is the class responsible for presenting the account information</p><pre>class AccountPrinter<br>  {<br>    public void printAccountDetails(BankAccount account)<br>     {<br>        System.out.println(account.getAccountNumber());<br>        System.out.println(account.getAccountHolder());<br>        System.out.println(account.getBalance());<br>     }<br>  }</pre><p>And we have one more class which is responsible for writing a code related to the persistence of the account information, lets have that class too</p><pre>import java.io.FileWriter;<br><br>class AccountPersistence<br>   {<br>    public void savetoFile(BankAccount account)<br>    {<br>        String filename=account.AccountNumber+&quot;_account.txt&quot;;<br>        try{<br>                FileWriter writer = new FileWriter(filename);<br>                writer.write(account.getAccountNumber());<br>                writer.write(account.getAccountHolder());<br>                writer.write(&quot;Balance is&quot; +account.getBalance());<br>                writer.close();<br>            }catch(Exception d){}<br>        <br>    }<br>   }</pre><p>Single Responsibility Principle followed by seperating responsibilities</p><p>BankAccount …………….. Deposit/withDraw</p><p>AccountPrinter……………. Presentation Display Account Details</p><p>AccountPersistence………Writing account information or details to file</p><h3>✅ Key Characteristics of an SRP-Compliant Class</h3><p>Here’s what you’d expect in a class that follows Single Responsibility Principle:</p><h3>One Clear Purpose</h3><ul><li>The class does <strong>only one type of job</strong>.</li><li>It represents a <strong>single concept</strong> or <strong>cohesive behavior</strong></li></ul><p><strong>Example:</strong><br> BankAccount handles only deposit/withdrawal logic — not printing or saving data.</p><h3>Minimal and Focused Methods</h3><ul><li>All methods in the class contribute to its <strong>core responsibility</strong>.</li><li>No “extra” utilities or unrelated operations are mixed in.</li></ul><p><strong>Example:</strong><br> In AccountPrinter, you only see things like: printAccountDetails(BankAccount account )</p><h3>Low Coupling to Unrelated Concerns</h3><ul><li>It does <strong>not directly depend</strong> on unrelated classes or services (like file handling or UI)</li><li>If the output method changes (console to PDF), the business logic class remains untouched.</li></ul><h3>High Cohesion</h3><ul><li>All fields and methods in the class are <strong>closely related</strong>.</li><li>There’s a clear thematic grouping: e.g., all persistence-related logic lives in one class.</li></ul><h3>Easier to Test and Maintain</h3><ul><li>You can write <strong>unit tests</strong> for just one concern.</li><li>When a bug occurs or a requirement changes, you know <strong>exactly where to look</strong>.</li></ul><h3>Conclusion</h3><h3>✅ Conclusion: Applying the Single Responsibility Principle (SRP)</h3><p>The <strong>Single Responsibility Principle (SRP)</strong> is a foundational guideline in object-oriented design that promotes <strong>clean, modular, and maintainable code</strong>. By ensuring that each class has <strong>only one reason to change</strong>, SRP helps isolate functionality into focused units of behavior.</p><p>In the <strong>banking domain example</strong>, we clearly saw the difference between a <strong>monolithic class</strong> that handled multiple concerns (violating SRP) and a <strong>well-structured design</strong> where responsibilities were divided among:</p><ul><li>BankAccount → business logic</li><li>AccountPrinter → presentation logic</li><li>AccountPersistence → data persistence</li></ul><p>This separation leads to:</p><ul><li><strong>Easier testing</strong> (each class can be tested independently)</li><li><strong>Better maintainability</strong> (changes are localized)</li><li><strong>Greater flexibility</strong> (UI, logic, and storage can evolve independently)</li></ul><p>Ultimately, following SRP encourages <strong>robust, scalable, and professional-grade code</strong>, especially in real-world domains like banking where clarity, correctness, and reliability are critical.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cd453a116d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding Image from file Constructor-Exploring Flutter App]]></title>
            <link>https://medium.com/@sathishparamasivam/adding-image-from-file-constructor-exploring-flutter-app-cd23630ca948?source=rss-7373a5770278------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd23630ca948</guid>
            <dc:creator><![CDATA[Sathish Paramasivam]]></dc:creator>
            <pubDate>Thu, 05 Jun 2025 11:27:17 GMT</pubDate>
            <atom:updated>2025-06-05T11:31:17.800Z</atom:updated>
            <content:encoded><![CDATA[<p>Image.file Constructor</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*II5y5fZV9UyYg9Gu" /></figure><p>Image.file is used to create a widget , which is used to display a image stream extracted from the file.</p><p>The Image.file constructor in Flutter is used to display images from files on the device&#39;s file system. It allows you to load and display images that are not part of your application&#39;s asset bundle, such as images downloaded by the user or images captured by the camera.</p><p>Asset Images</p><p>An asset (sometimes its referred as resources) is a file that is bundled and deployed with your app, and is accessible at runtime. Common types of assets include static data (for example, JSON files), configuration files, icons, and images (JPEG, WebP, GIF, animated WebP/GIF, PNG, BMP, and WBMP).</p><p>We must configure these images in <strong>pubspec.yaml</strong> so that it can be used in the application.</p><p>Asset images and file images are totally different; asset images are the part of application.</p><p>But file images are not part of the application. These are the images present in your device already or it may be the images you captured with your phone, or you might get it by downloading.</p><p>Images which are locally available like images accessed through social media applications. Once we click on the images its getting downloaded and loaded into your device, once if you tap on the image which is loaded from your device rather than downloaded. Its stored locally in the device , even if network is turned off its possible to load the specific images.</p><p>We have this functionality in flutter. Your images are stored in the file (device directory itself) It is not the part of network because its store in the device , for this we may not use <strong>image.network()</strong></p><p>For that we have another constructor which is called as <strong>image.file()</strong></p><p>This constructor requires images to be in the form of file, it means that we have to access the file system of device.</p><p>For this we must take permission and this permission has been configured in the file called android manifest.</p><p>Open the file AndroidManifest.xml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*N8VMfPQ3EmDvPKvQswo7qQ.png" /></figure><p>and add the following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*1tUgd-Q2xeGZlwhPcXK74w.png" /></figure><p>Note ~ Erstwhile android version used READ_EXTERNAL_STORAGE</p><p>These specific code use an access permission for Reading your external storage</p><p>Most of the android devices protect the app being accessed by the local storage.</p><p>We need an additional configuration so that the app will access the storage for that we need</p><p>permission_handler: ^12.0.0+1</p><p>dependency , which will be available with 1.84 million downloads from <a href="https://pub.dev/packages/permission_handler">https://pub.dev/packages/permission_handler</a> repository , especially for dart and flutter devs.</p><p>open pubspect.yaml from the root of your application and add the above dependency and run flutter Pub get or click Pub get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*pmw_hjFEb-J6vGS_nCUC5A.png" /></figure><p>which resolving dependencies by downloading the packages once all set , we will move to the dart part of your flutter applications.</p><p>Requirements</p><p>flutter/material.dart</p><p>permission_handler/permission_handler.dart</p><p>dart:io</p><p>ensure your application has to import the above dependencies by</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*ZY9SUuTKgtE-vJsA7Jw-Mw.png" /></figure><p>Its an asynchronous operation so main of your application is annotated with async right to the parameters</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*jHzLHU1fIb8ms-aKUAtHQw.png" /></figure><p>WidgetsFlutterBinding.ensureInitialized() in Flutter is used to ensure that the Flutter engine and framework are properly initialized before any asynchronous operations, platform-specific code, or interactions with the engine are attempted. It&#39;s essentially a &quot;boot-up&quot; step that prepares the Flutter environment before your app starts running.</p><p>It establishes the binding between the Dart code (your app’s logic) and the Flutter framework, allowing communication with the native platform (Android/iOS).</p><p>When your app needs to perform tasks like initializing Firebase, reading from shared preferences, or fetching data before the UI renders, ensureInitialized() helps handle these asynchronously.</p><p>You typically call WidgetsFlutterBinding.ensureInitialized() at the beginning of your main() function, before calling runApp(), if you need to perform any of the above tasks before the UI is rendered.</p><pre>import &#39;dart:io&#39;;<br>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:permission_handler/permission_handler.dart&#39;;<br><br>void main() async {<br>  WidgetsFlutterBinding.ensureInitialized();<br>  await Permission.photos.request();<br>  runApp(myapp());<br>}<br><br>class myapp extends StatelessWidget {<br>  const myapp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: Scaffold(<br>        body: Image.file(File(&quot;/storage/emulated/0/DCIM/i-exceed.png&quot;)),<br>      ),<br>    );<br>  }<br>}</pre><p>where the important point here is the file path is from Emulator device</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*9LQgKIVRFxLr9O5O0-E-JQ.png" /></figure><p>and add the files to the</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*427zjiPjHScgAt0T_JgHWA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd23630ca948" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Single Point Precision Floating point 32bit (FP32) Conversion to Decimal]]></title>
            <link>https://medium.com/@sathishparamasivam/single-point-precision-floating-point-32bit-fp32-conversion-to-decimal-452bf0258153?source=rss-7373a5770278------2</link>
            <guid isPermaLink="false">https://medium.com/p/452bf0258153</guid>
            <dc:creator><![CDATA[Sathish Paramasivam]]></dc:creator>
            <pubDate>Mon, 14 Oct 2024 04:42:40 GMT</pubDate>
            <atom:updated>2024-10-14T04:42:40.296Z</atom:updated>
            <content:encoded><![CDATA[<h3>Math is essential for all your computing do Artificial Intelligence is it right!</h3><p>For Deep learning, which type of math is need for training and inferencing?</p><p>There are few ways to think about the irrational number, considered an example as pi (π=3⋅14159265…)</p><p>Here at the simple calculation as a kid in school will considered pi value as 3.14 , whereas higher level of educational calculation may look up to 10 decimal place to express the same number , in the context of computing its called as precision rather than decimal values.</p><p>Computational intelligence (Deep neural network)require even more higher precisions as parameters(weights and bias).</p><p>With the Higher precision level your machines need more computational resources ,memory storage it requires, which consume more power and its not economic for every one.</p><p>Since not every workflow required precision to be high, which allowed developers to optimize computational resource and speedup the training of models and inferencing.</p><p><strong>Single Precision Floating Point 32 (FP32)</strong></p><p>IEEE Standard 754 Floating Point Number is a conventional way of representing numbers in binary format. Number of bits in the exponents are used to determine its range,</p><p>Single Precision IEEE floating point number can be represented as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*laOpPNicSIXrxsJcXXFfVQ.png" /><figcaption><strong>Figure 1 IEEE 754 Single Precision Floating Point Number</strong></figcaption></figure><p><strong>Sign : </strong>In Single Precision 32 bit format the MSB which is used to represent the Sign magnitude positive(0) or negative (1).</p><p><strong>Exponent: </strong>The next eight bits are reserved for the Exponent, which is 2 raised to some power.</p><p><strong>Significand:</strong> The remaining 23 bits are used to represent the Significand (aka Mantissa).</p><p>Lets check the conversion of the 32bit binary to Floating point arithmetic</p><p><strong>0100 0011 0101 0100 0000 0000 0000 0000</strong></p><p>Most Significant Bit(0) represent the number is positive</p><p>Next 8 bits are used to represent the exponent which is 2 raised to some power</p><p>the binary digits are 1 0 0 0 0 1 1 0 , if you convert the binary to decimal it results in 134.</p><p>Now we have to make sure that we deduct the bias from the value, exponential bias is included in representing the value in IEEE FP.</p><p>Bias can be computed with the support of the following formula, where k is the number of bits reserved for exponent</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/81/1*FuLNSZWOJLa_zRXF2711PA.png" /></figure><p>that would results in 127</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/87/1*awl90OMIZwGN7hJVylDQbQ.png" /></figure><p>so the decimal value computed from the exponential binary digit is 134 , so any exponent value computer less than the bias(127) would results in negative exponent.</p><p>here 134 which is not less than the exponential bias(127) so its is positive exponent.</p><p>e=134–127 =7 so our exponential value is 7 , e=7</p><p>Now the next part is the Significand of the number the fractional bits are the remaining 23bits.</p><p><strong>101 0100 0000 0000 0000 0000</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*qHiU23kEknCcHQor1m0WiA.png" /><figcaption><strong>Significand aka Mantissa</strong></figcaption></figure><p>m=0.65625</p><p>Significantly we can have the Decimal as 212</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/185/1*KlumeRgHqZGTFYbxVby34g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*q0qfaEE1eHrSUKff4vwSIA.png" /><figcaption><strong>Fact Checked with Converter</strong></figcaption></figure><p>References</p><p><a href="https://www.h-schmidt.net/FloatConverter/IEEE754.html">https://www.h-schmidt.net/FloatConverter/IEEE754.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=452bf0258153" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LORA Low-Rank Adaptation of Large Language Models — Mathematical Approach — SVD]]></title>
            <link>https://medium.com/@sathishparamasivam/lora-low-rank-adaptation-of-large-language-models-mathematical-approach-svd-b6a41ef52bc5?source=rss-7373a5770278------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6a41ef52bc5</guid>
            <category><![CDATA[gemma]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[lora]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Sathish Paramasivam]]></dc:creator>
            <pubDate>Fri, 04 Oct 2024 12:59:04 GMT</pubDate>
            <atom:updated>2024-10-04T13:01:28.060Z</atom:updated>
            <content:encoded><![CDATA[<h3>LORA(Low-Rank Adaptation ) Mathematical-SVD</h3><p>LORA is a lightweight training technique which is used to significantly reduce the number of elements aka parameters , it works by assigning a smaller number of new weights into model, which makes much faster and memory efficient, which are easy to store.</p><p>Prior to study <strong>LORA </strong>we need to understand</p><p><strong>How do neural networks work?</strong></p><p>Lets imagine an input it may be vector of numbers and we have some hidden layer in a neural network which is usually represented by a matrix and then we have an another hidden layer and finally we have a output as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HnF4sD-4CD2zFa87kTh_KA.png" /><figcaption>Neural Network</figcaption></figure><p>Once we train the networks we have a target and what we did is we compare the output and target to produce a loss and finally we back propagate the loss to each of the weights of all the layers, in this case we have many weights and each of the weights will be modified by the loss functions.</p><p>What is Fine-Tuning ?</p><p>Fine-Tuning basically means that we have a pre-trained model and we want to fine-tune it on some other data that the original model may have not seen.</p><p>For example imagine we have our own data which is not know to the pre-trained large language model which is downloaded , which was trained with trillions of parameters (weights and bias). But we want to fine-tune it on our own data. so that the model can help our user to perform infer our own database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bas10y6ywhLmsgFe2fuTSA.png" /></figure><p>what we do is we train the entire model on new data as we alter all these weights using the new data.</p><p><strong>Problems</strong></p><p>We train the full network, which it computationally expensive for the average user when dealing with LLM , we need to run back propagation on all the weights.</p><p>Storage requirements are expensive, as we need to save the entire model on the disk.</p><p><strong>Solution to the Problem is LORA</strong></p><p>However we have a better solution to these problems with LORA , In LORA we start with an input and a pre-trained model with its weights, which we want to fine-tune it right.</p><p>We have a pre-trained model with weights and we freeze them basically, we inform PyTorch to never touch these weights just use them as read only and never run the backpropagation on these weights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*WQ4pLC7CAQWRoh51R4B01A.png" /></figure><p><strong>LORA</strong> allow us to train some dense layer in neural network indirectly by optimizing <strong>rank decomposition matrix </strong>of the dense layer of pre-trained model.</p><p>Here I Introduce Matrix B and Matrix A , Note the difference between the Original matrix of the pre-trained model and decomposition models B and A.</p><p>The dimension of the Frozen pre-trained model Matrix is <strong>d*k , </strong>let say d is 1000 and k is 5000 , we want to create two decomposition matrices that when multiplied together they produce the same dimension, we can see it here <strong>d*r </strong>of B Matrix<strong>, </strong>when its multiplied by k*r of A Matrix would results in <strong>d*k. </strong>We want r to be much lesser than d or k , <strong>r&lt;&lt;min(d,k).</strong></p><p>The weight of the pre-trained Matrix is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/110/1*7W3llKEyacXQBG4ebD6bTw.png" /></figure><p>where the weights of the decomposed matrices are</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/1*r5qUIZThghYOj8IeiyO1oA.png" /></figure><p>Suppose <strong>d is 1000 </strong>and<strong> k is equal to 5000</strong> , we have number of parameters lets call it as p =d*k , which is equal to 5,000,000, lets take the value for r as 5 then the parameters are d*r + r*k so 1000*5 + 5*5000 =30,000. But the advantage that when we multiply them together we still produce a same dimension, we have the possibility of accuracy , the decomposition matrices are the smaller representation of W so there is a possible for loss of information this is the whole idea behind the LORA.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*ML7xs1AseiKbnB7Mt_Qocg.png" /></figure><p>The matrix W contains a lot of parameters (weights and bias) that are actually not meaningful for our purpose they are actually not adding any information to the model they are just a combination of the other weights so they are redundant ,so we don’t need the whole matrix W , we can create a decomposition of W and finetune these decomposition matrices B and A and their respective output vectors are added coordinate wise and results in</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*cZ6K5TdKbgVnkdiNWGWYyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/149/1*QOHG44KUtx-R5R8sKXwRQw.png" /></figure><p>and we have our usual target we can calculate the loss and we only backpropagate the loss to the Matrix B and A , we never touch Original Pretrained W matrix its frozen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*44iLSkQu9MNT-rvR2G1R6g.png" /></figure><p><strong>What are the Benefits?</strong></p><p>Less parameter to train and store if d=1000,k=5000 (d * k) =5,000,000 Using r=5, we get (d*r)+(r*k)=5000+25000=30,000 . less than 11% of the pre-trained matrix.</p><p>Less parameter makes viable for less storage requirements</p><p>Faster back propagation , as we do not need to evaluate the gradient for most of the parameter.</p><p>Lets take a review of some mathematics of ranking and matrix decomposition.</p><p><strong>Matrix Decomposition</strong></p><p>lets start to import libraries torch and numpy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VfFSxTt-DRnQeFkpdLVL9Q.png" /></figure><p>Lets generate a Rank dificient matrix W</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RxxLY2W5-BAZEr3ctXQWtA.png" /></figure><p>the rank of the matrix is 2 we can check it out with numpy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SY4SMURBW-AY7tvrPqy_gw.png" /></figure><p>Now I am going to decompose the Matrix by an algorithm called svd ,which is going to produce three matrices u,s,v.</p><p>if you multiply u s and transpose of v it will results in W.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g6fMzDphAeSG_XD5Q-mXAg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wOoOa_KhDpcq_bJj-c6a2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W6IqW3h2hJlsgExd05ysMQ.png" /></figure><p>for the rank-r factorization, keep only the first r singular values (and corresponding columns of u and v)</p><p>transpose v_r to get the right dimensions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HeM7W5oEzEFLdceaio5VCQ.png" /></figure><p>the decomposition Matrix B and A with its dimension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EfU3etugcUZbsiTFV43zjg.png" /></figure><p>look into the above code by taking an account of x and bias as input and help out to create y by multiplying x with W original matrix and added with bias.</p><p>Similarly with B and A , note that the output is same even if B and A have much less parameters.</p><p>you can see the number of elements combined by B and A is 40 while the Original Matrix (W) with 100 parameters and produce the same output for the same Matrix A and B will capture the most of information of the Original matrix.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PxsYGX0gca5d7qdFFUENaw.png" /></figure><p>References</p><p><a href="https://github.com/sathishsivam/Gemini-/blob/main/LORA_Model_Math.ipynb">Gemini-/LORA_Model_Math.ipynb at main · sathishsivam/Gemini-</a></p><iframe src="https://drive.google.com/viewerng/viewer?url=https%3A//arxiv.org/pdf/2106.09685&amp;embedded=true" width="600" height="780" frameborder="0" scrolling="no"><a href="https://medium.com/media/1775feb6283f33913ab7344d90e26f8b/href">https://medium.com/media/1775feb6283f33913ab7344d90e26f8b/href</a></iframe><iframe src="https://drive.google.com/viewerng/viewer?url=https%3A//arxiv.org/pdf/2106.09685&amp;embedded=true" width="600" height="780" frameborder="0" scrolling="no"><a href="https://medium.com/media/1775feb6283f33913ab7344d90e26f8b/href">https://medium.com/media/1775feb6283f33913ab7344d90e26f8b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6a41ef52bc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ollama Run Large Language Models Locally]]></title>
            <link>https://medium.com/@sathishparamasivam/ollama-run-large-language-models-locally-f51626283781?source=rss-7373a5770278------2</link>
            <guid isPermaLink="false">https://medium.com/p/f51626283781</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ollama]]></category>
            <category><![CDATA[langchain]]></category>
            <category><![CDATA[localai]]></category>
            <dc:creator><![CDATA[Sathish Paramasivam]]></dc:creator>
            <pubDate>Thu, 26 Sep 2024 12:24:15 GMT</pubDate>
            <atom:updated>2024-09-26T12:24:15.260Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="ollama" src="https://cdn-images-1.medium.com/max/720/1*JzusuaHoQU28VZP6ddAXDg.png" /></figure><h3><strong>What is Local AI ?</strong></h3><p>In contrast with Cloud dependency of LLM , local artificial intelligence models aims to deliver AI capabilities on smaller devices. These models are lightweight and consume less computational energy and power, which reduce the operational cost considerably makes them more eco friendly</p><h3><strong>Merits of Local AI</strong></h3><p>By manipulating data locally on a machine, these models considerably minimize the need to transfer sensitive information over the internet, enhancing user privacy and data security.</p><p>Further, since local AI models can operate without constant internet connectivity, they are accessible in remote or underserved areas.</p><p>They offer faster response times, as they don’t require a network. Local AI models are particularly well-suited for cutting-edge computing scenarios, where real-time processing and low latency are critical</p><p>local AI models must be highly adaptable and capable of running on various local hardware configurations without compromising performance.</p><p>Running LLMs locally reduce the environmental impact by democratizing the capabilities of Artificial Intelligence.</p><h3>What is Ollama?</h3><p>Ollama (Omni-layer learning language Acquisition model) a framework for working with large language models(LLM) locally on your System.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*TjcR_XMncvvT6xQs6rkPpg.png" /></figure><h3>Features of Ollama</h3><p><strong>Extensive models Libraries: </strong>ollama brings you to connect with large language models including most popular meta llama3.2 goes with 1B and 3B models ,llama3.1 a new state-of-art model with 8B,70B,405B and ,High performing and efficient gemma2 available with three size 2B,9B,27B, you can explore all the available featured most popular models from the url <a href="https://ollama.com/library"><strong>https://ollama.com/library</strong></a></p><p>You should have at least 8 GB of RAM available to run the 7B models, 16 GB to run the 13B models, and 32 GB to run the 33B models.</p><p><strong>Integration: </strong>ollama seamlessly integrate with different frameworks ,programming languages and tools, which makes the AI engineers to incorporate models and make their workflow ease.</p><p><strong>Fine-tuning: </strong>ollama permits user have the influence to customize and fine-tune the LLM to align their needs.</p><p><strong>Downloads Installation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*XL4hxkEhQIV33HDaNuOsRw.png" /></figure><p>macOS require macOS 11 big sur or later</p><p>linux</p><p>Windows (Preview) require Windows 10 or later</p><p>Once download is completed</p><p>lets start work with models you can surf the availablity of models from the model library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*lIS92UH_a-Xp_OLDglQrvA.png" /></figure><p>let say we are going to make use of llama2 then from the command prompt and type ollama it will display the available commands as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*mKGSvI-07jbmfWLDudo0ew.png" /></figure><p>we can use <strong>ollama run llama2</strong></p><p>for the first time which will take time depends on the available memory in the form of manifesting file and download the entire model in the local machine itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*jiR14_wWQ3SAB3Afc6d9Vw.png" /></figure><p>like this you can definitely try multiple opensource model quickly.</p><h3>Customize a model</h3><p>There is an option where you can create your own <strong>Model file</strong></p><p>Ollama supports importing GGUF model</p><p><strong>What is GGUF model?</strong></p><p><strong>GGUF</strong> model is a file that use the <strong>GGUF</strong>(GPT- Generated Unified Format) to store the Large language Model (LLM).</p><p>GGUF is a binary format that’s designed to make it easier to store, process, and use LLMs</p><p><strong>Features of GGUF model</strong></p><p><strong>Fast loading and saving:</strong> GGUF is optimized for quick loading and saving of models</p><p><strong>Easy to read:</strong> GGUF files are designed to be easy to read</p><p><strong>Consumer-grade hardware:</strong> GGUF is designed to perform well on consumer-grade computer hardware</p><p><strong>Quick inspection:</strong> GGUF allows for quick inspection of tensors and metadata within the file</p><p><strong>Potential Demerits of GGUF</strong></p><p>Converting existing models to GGUF may require a significant amount of time.</p><p>Users and developers may need to get used to the new format</p><p>lets have an example of customize the Modelfile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*cBbg1PybbGK3etvlznWO-w.png" /></figure><p>Create a file named <strong>Modelfile</strong>, with a <strong>FROM</strong> instruction with the local filepath to the model you want to import.</p><p>Models from the Ollama library can be customized with a prompt. For example, to customize the <strong>llama2</strong> model:</p><p>In the above example am using</p><p><strong>From llama2</strong></p><p><strong>Set the temerature to 1 </strong>[higher is more creative, lower is more coherent]</p><p>followed by the PARAMETER temperature 1 and then set the SYSTEM messages as your custom prompt.</p><p>where I prompted</p><p><strong>SYSTEM “”” You are an AIVathi(named in Tamil my native language) an Instructor created by sathishsivam. you are responsible for answering the questions related Machine learning, deeplearning ,GenerativeAI.</strong></p><p><strong>“””</strong></p><p>This is my system prompt now let me show you how cud iam actually create my custom chat by using llama2 will be acting as AIVathi (AI Teaching Assitant)</p><p>Next step is to create and run the custom model AIVathi</p><p>Select the command line interface CLI, navigate to the workspace where your Modelfile is reside for me my workspace(Directory) is <strong>ollama_template</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*757AV7NEqQ-vKUfeMTT72w.png" /></figure><p>now the custom model is ready to run use the command <strong>ollama run aivathi </strong>from the command prompt as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*vTcLQpSKnnEnp_gcTbzahA.png" /></figure><h3>OllamaLLM</h3><p>Here I quote how to use langchain to interact with Ollama models</p><p>Installation <strong>%pip install -U langchain-ollama</strong></p><p>it have the capability to extract the models loaded by ollama</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*4oWU2iFW-y9PCDN089NR-Q.png" /></figure><p><strong>Conclusion</strong></p><p>Evolution of AI and its integration is mandatory, extracting the open source large language models to the local machines is enhanced with the support of Ollama framework. Here I dwell the power of ollama and how it will be used in command line to work with different models , how to customize the prompt and its capability of working with Modelfile is clearly coded.</p><p><strong>References</strong></p><ul><li><a href="https://ollama.com/">Ollama · Run AI models locally and in the cloud</a></li><li><a href="https://github.com/ollama/ollama">GitHub - ollama/ollama: Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.</a></li><li><a href="https://python.langchain.com/docs/integrations/llms/ollama/">OllamaLLM | 🦜️🔗 LangChain</a></li><li><a href="https://www.linkedin.com/pulse/rise-local-ai-should-democratize-technology-siddharth-pai-vihac/">The rise of local AI should democratize this technology</a></li></ul><p>follow me</p><p><a href="https://www.linkedin.com/in/sathishkumar-paramasivam-67628035?utm_source=share&amp;utm_campaign=share_via&amp;utm_content=profile&amp;utm_medium=ios_app">https://www.linkedin.com/in/sathishkumar-paramasivam-67628035?utm_source=share&amp;utm_campaign=share_via&amp;utm_content=profile&amp;utm_medium=ios_app</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f51626283781" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>