[proofplan]
The Stone topology on $S_n(A)$ is generated by formula-defined sets $[\varphi]$. We first verify that this generating family is already stable under finite intersections, because conjunction of formulas represents intersection. Then we prove that each formula-defined set is closed as well as open, using completeness of types to identify its complement with the set defined by the negated formula.
[/proofplan]
[step:Show that formula-defined sets cover the type space]
Let $\top(\bar{x})$ denote the tautological $L(A)$-formula $x_1 = x_1$. Since every complete type $p \in S_n(A)$ contains every logical tautology, we have
\begin{align*}
[\top] = S_n(A).
\end{align*}
Hence the family $\mathcal{B}$ covers $S_n(A)$.
[/step]
[step:Represent finite intersections by conjunctions]
Let $\varphi_1(\bar{x}),\dots,\varphi_m(\bar{x})$ be $L(A)$-formulas, where $m \in \mathbb{N}$. Define the $L(A)$-formula
\begin{align*}
\psi(\bar{x}) := \varphi_1(\bar{x}) \wedge \cdots \wedge \varphi_m(\bar{x}).
\end{align*}
For any $p \in S_n(A)$, the deductive closure of the complete type $p$ gives
\begin{align*}
p \in [\psi]
&\iff \psi(\bar{x}) \in p \\
&\iff \varphi_i(\bar{x}) \in p \text{ for every } i \in \{1,\dots,m\} \\
&\iff p \in \bigcap_{i=1}^m [\varphi_i].
\end{align*}
Therefore
\begin{align*}
[\varphi_1] \cap \cdots \cap [\varphi_m] = [\varphi_1 \wedge \cdots \wedge \varphi_m].
\end{align*}
Thus $\mathcal{B}$ is closed under finite intersections.
[guided]
We need to check that the sets $[\varphi]$ are not merely a subbasis but already a basis. The key point is that intersecting finitely many formula conditions is the same as imposing one formula condition.
Let $\varphi_1(\bar{x}),\dots,\varphi_m(\bar{x})$ be $L(A)$-formulas, with $m \in \mathbb{N}$. Define a new $L(A)$-formula
\begin{align*}
\psi(\bar{x}) := \varphi_1(\bar{x}) \wedge \cdots \wedge \varphi_m(\bar{x}).
\end{align*}
This formula is allowed because first-order formulas are closed under finite conjunctions. Now take an arbitrary complete type $p \in S_n(A)$. Since $p$ is deductively closed, it contains the conjunction $\psi(\bar{x})$ exactly when it contains every conjunct $\varphi_i(\bar{x})$. Hence
\begin{align*}
p \in [\psi]
&\iff \psi(\bar{x}) \in p \\
&\iff \varphi_i(\bar{x}) \in p \text{ for every } i \in \{1,\dots,m\} \\
&\iff p \in [\varphi_i] \text{ for every } i \in \{1,\dots,m\} \\
&\iff p \in \bigcap_{i=1}^m [\varphi_i].
\end{align*}
Since this equivalence holds for every $p \in S_n(A)$, the two subsets of $S_n(A)$ are equal:
\begin{align*}
[\psi] = \bigcap_{i=1}^m [\varphi_i].
\end{align*}
Thus every finite intersection of formula-defined sets is again formula-defined.
[/guided]
[/step]
[step:Deduce that the formula-defined sets form a basis for the Stone topology]
The Stone topology on $S_n(A)$ is the topology generated by the family $\mathcal{B}$. Since $\mathcal{B}$ covers $S_n(A)$ and is closed under finite intersections, the open sets generated by $\mathcal{B}$ are exactly arbitrary unions of members of $\mathcal{B}$. Therefore $\mathcal{B}$ is a basis for the Stone topology on $S_n(A)$.
[/step]
[step:Identify complements using negation]
Let $\varphi(\bar{x})$ be an $L(A)$-formula. Define the $L(A)$-formula
\begin{align*}
\theta(\bar{x}) := \neg \varphi(\bar{x}).
\end{align*}
For every complete type $p \in S_n(A)$, completeness gives exactly one of $\varphi(\bar{x}) \in p$ and $\neg \varphi(\bar{x}) \in p$. Hence
\begin{align*}
S_n(A) \setminus [\varphi] = [\neg \varphi].
\end{align*}
Since $[\neg \varphi] \in \mathcal{B}$, it is open in the Stone topology. Therefore $[\varphi]$ is closed. Also $[\varphi]$ is open because it is a basis element. Thus $[\varphi]$ is clopen.
[/step]
[step:Conclude that the basis is clopen]
The formula $\varphi(\bar{x})$ was arbitrary, so every member $[\varphi]$ of $\mathcal{B}$ is clopen. Since $\mathcal{B}$ is a basis for the Stone topology, the sets $[\varphi]$, where $\varphi(\bar{x})$ ranges over all $L(A)$-formulas, form a basis of clopen subsets for $S_n(A)$.
[/step]