(concurring specially in part and dissenting in part).
[¶ 16.] I agree with the holding of the majority that:
Krebs is statutorily entitled to effective assistance of counsel on one occasion during habeas proceedings but I do not agree that he received it. I write specially to explain the rationale for said holding and I dissent to the result reached by the majority regarding prejudice.
[¶ 17.] I write specially to first point out that habeas corpus is not limited to violations of constitutional rights. Habeas corpus reaches jurisdictional error, constitutional error, all “causes” listed in SDCL 21-27-16(1) through (7) and other illegal detentions, including those resulting from failure to comply with “substantive statutory procedure.” Lange v. Weber, 1999 SD 138, ¶ 17, 602 N.W.2d 273, 276 (Sabers, J., concurring specially) (citing Security Sav. Bank v. Mueller, 308 N.W.2d 761, 762-63 (S.D.1981); O’Connor v. Leapley, 488 N.W.2d 421, 425 (S.D.1992) (Sabers, J., concurring specially); Petrilli v. Leapley, 491 N.W.2d 79, 86 (S.D.1992) (Sabers, J., concurring specially); Black v. Class, 1997 SD 22, ¶ 34, 560 N.W.2d 544, 552 (Sabers, J., concurring specially); Lykken v. Class, 1997 SD 29, ¶ 34, 561 N.W.2d 302, 309 (Sabers, J., dissenting)).
[¶ 18.] The right to effective assistance of counsel at trial is guaranteed by the Sixth Amendment of the United States Constitution and applies to trials in state courts through the Fourteenth Amendment of the United States Constitution. Gideon v. Wainwright, 372 U.S. 335, 342-45, 83 S.Ct. 792, 795-97, 9 L.Ed.2d 799, 804-06 (1963). However, the United States Supreme Court has declared that there is no constitutional right to an attorney in state post-conviction proceedings. Coleman v. Thompson, 501 U.S. 722, 752, 111 S.Ct. 2546, 2566, 115 L.Ed.2d 640, 671 (1991) (citations omitted). Therefore, whether a convicted criminal has the right to counsel during habeas proceedings is a question for states to determine.
[¶ 19.] The South Dakota Legislature has required that counsel be appointed for indigent prisoners in habeas proceedings:
If a person has been committed, detained, imprisoned or restrained of his liberty ... and if upon application made in good faith to the court or judge thereof, having jurisdiction, for a writ of ha-beas corpus, it is satisfactorily shown that the person is without means to prosecute the proceeding, the court or judge shall appoint counsel....
SDCL 21-27-4. Even though Krebs did not have a constitutional right to counsel during his first habeas proceeding, he did have a statutory right to counsel.
[¶ 20.] Obviously, this statutory right to counsel is not restricted to the appointment of a person who merely fulfills the requirements of obtaining a license to practice law in South Dakota. There is an inherent requirement that the attorney be competent and provide adequate representation. See Iovieno v. Comm’r of Correction, 242 Conn. 689, 699 A.2d 1003, 1010 (1997) (claim of ineffective assistance of post-conviction counsel is a viable claim because statute requires the appointment of post-conviction counsel) (citing Lozada v. Warden, 223 Conn. 834, 613 A.2d 818, 821-24 (1992)). The rationale is best explained by the Lozada court: “[i]t would *327be absurd to have the right to appointed counsel who is not required to be competent:”
‘[C]ounsel should be appointed in post conviction matters.... When counsel is so appointed he must be effective and competent. Otherwise, the appointment is a useless formality.’
Lozada, 613 A.2d at 821 (emphasis added) (quoting Cullins v. Crouse, 348 F.2d 887, 889 (10th Cir.1965)) (citing United States v. Wren, 682 F.Supp. 1237, 1241-42 (S.D.Ga.1988) (“an indigent federal probationer’s statutory right to appointed counsel at a probation revocation hearing ... ‘would be meaningless if it did not embody a requirement that counsel be effective as well as merely present.’”)). To require counsel and permit less than effective counsel during representation would be to assert that the purpose of this statute is meaningless, the purpose of our judicial system is meaningless and our Rules of Professional Conduct do not apply in habe-as.
[¶21.] Krebs is statutorily entitled to effective assistance of counsel on one occasion during habeas proceedings. Therefore, the issue is whether attorney Thompson rendered ineffective assistance of counsel in filing a “purported” Sweeney brief favorable to his withdrawal with the first habeas court. In order to prevail on a claim of ineffective assistance of counsel, Krebs must show that his counsel’s performance was deficient and that this deficient performance actually prejudiced his defense. Strickland, 466 U.S. at 687, 104 S.Ct. at 2064, 80 L.Ed.2d at 693. To show actual prejudice, Krebs must demonstrate that, but for trial counsel’s deficient performance, there is a reasonable probability that the result of the trial would have been different. Id.
[¶22.] Since 1992, we have required court-appointed attorneys to follow specific procedures when they believe that the ha-beas case is wholly frivolous. See Sweeney v. Leapley, 487 N.W.2d 617, 620 (S.D.1992) (recognizing that South Dakota affords more protection for defendants in habeas proceedings than required by the United States Supreme Court). Sweeney was based on Anders v. California, 386 U.S. 738, 744-45, 87 S.Ct. 1396, 1400, 18 L.Ed.2d 493, 498-99 (1967). After a thorough examination of the case, if the attorney determines that his client’s case is frivolous, he may request permission to withdraw. However, that request must “be accompanied by a brief referring to anything in the record that might arguably support the appeal.” Id. at 619. This does not mean that the brief set forth all the reasons why the attorney believes the case is frivolous. On the contrary, this means that the brief set forth the client’s arguments in the best manner possible. This is the only method which enables the court, rather than counsel, to determine whether the case is in fact frivolous.
[¶ 23.] Thompson filed a motion to withdraw, accompanied by a brief, in April of 1994. Krebs, however, argues that Thompson’s “no merit” brief was “written for the State — or, at the very least, to support Thompson’s own personal desires to be relieved of further representation.” More specifically, one of Krebs’ claims on habeas was that his trial counsel was ineffective in failing to interview or call an alibi witness for Krebs. Thompson did not even attempt to investigate the location or proffered testimony of the alibi witness. Instead, he drafted a Sweeney brief, which was devoid of the subject of the alibi witness. Clearly, this selective editing of the subject matter is contrary to the letter and spirit of Anders and our Sweeney decision. See Sweeney, 487 N.W.2d at 619 (stating that it is the court, not counsel, who “decided whether the case is wholly frivolous.”). The Sweeney brief is supposed to help, not harm, the petitioner. Thompson’s violation of the Sweeney requirements amounts to prejudicial ineffective assistance of counsel.
[¶ 24.] The purpose of the first habeas was to challenge the effectiveness of his attorney at trial. We have often stated *328that a direct appeal is not the appropriate method to assert ineffective assistance of counsel claims. State v. Cochrun, 434 N.W.2d 370, 373 (S.D.1989) (citations omitted); State v. Davis, 401 N.W.2d 721, 725-26 (S.D.1987) (citations omitted); State v. Tchida, 347 N.W.2d 338, 339 (S.D.1984); State v. McBride, 296 N.W.2d 551, 556 (S.D.1980). See also Fernandez v. Cook, 783 P.2d 547, 550 (Utah 1989) (stating: “[t]he sixth amendment right to effective assistance of counsel is imperiled if an alleged violation of that right cannot be raised for the first time in a habeas corpus proceeding when the allegedly ineffective trial counsel also represented the defendant on appeal and failed to raise the issue at that stage.”). Rather, habeas corpus is the more appropriate forum in which to assert these claims. Tchida, 347 N.W.2d at 339 (recognizing that one exception applies which allows the issue of incompetent counsel to be raised on direct appeal: “when the representation was ‘so casual that the trial record evidences a manifest usurpation of appellant’s constitutional rights.’ ”) (quoting State v. Phipps, 318 N.W.2d 128, 131 (S.D.1982)).
[¶ 25.] The State also argued that Krebs was not entitled to bring a second habeas proceeding based on the doctrine of res judicata. I disagree.
[¶ 26.] “The doctrine of res judicata serves as claim preclusion to prevent relit-igation of an issue actually litigated or which could have been properly raised and determined in a prior action.” SDDS, Inc. v. South Dakota, 1997 SD 114, ¶ 16, 569 N.W.2d 289, 295 (quoting Hogg v. Siebrecht, 464 N.W.2d 209, 211 (S.D.1990)). “The purpose behind the doctrine is to protect parties ‘from being subjected twice to the same cause of action, since public policy is best served when litigation has a finality.’ ” Id. (quoting Moe v. Moe, 496 N.W.2d 593, 595 (S.D.1993)).
[¶ 27.] In determining whether res judi-cata applies, this court considers, among other factors, whether there was a final judgment on the merits. See D.G. v. D.M.K., 1996 SD 144, ¶27, 557 N.W.2d 235, 240 (quoting Wintersteen v. Benning, 513 N.W.2d 920, 921 (S.D.1994) (other citations omitted)). “A judgment on the merits is one which is based on legal rights as distinguished from mere matters of practice, procedure and jurisdiction.” Chicago & Northwestern Railway Co. v. Gillis, 80 S.D. 617, 129 N.W.2d 532, 535 (1964) (citation omitted).
[¶ 28.] Because Krebs was deprived of his statutory right to effective assistance of habeas counsel, his first habeas was dismissed based on an improper Sweeney brief. Furthermore, neither Thompson nor the first habeas court advised Krebs that he could appeal the first habeas court’s decision, which accepted Thompson’s “no merit” brief. Therefore, his first habeas did not receive substantive consideration on the merits. Although Krebs receives that consideration under the majority opinion, I dissent as to the conclusion reached.
[¶ 29.] In summary, Krebs was provided ineffective assistance of counsel at trial. Therefore, pursuant to our rationale above, Krebs correctly brought his ineffective assistance of counsel claim in habeas court. However, he was provided with ineffective assistance of counsel during his first habeas proceeding. In the interest of justice and fairness, Krebs was entitled to effective assistance of counsel on one occasion. However, Krebs was denied this right at trial and during his habeas. Now, the majority opinion tells Krebs that he had a statutory right to assistance of counsel in habeas, and a right to effective counsel, but that he has not shown sufficient prejudice. I disagree and therefore, dissent.